private static void ToMainCamera() { if (_cam != null) { _cam.transform.parent = _origParent; _cam.transform.localPosition = _origPosition; _cam.transform.localRotation = _origRotation; _cam.SetFoV(_origFoV); _cam.ActivateUpdate(); if (FlightGlobals.ActiveVessel != null && HighLogic.LoadedSceneIsFlight) { _cam.SetTarget(FlightGlobals.ActiveVessel.transform, FlightCamera.TargetMode.Vessel); } _origParent = null; } if (_currentCamera != null) { _currentCamera.ltCamActive = false; } _currentCamera = null; Camera.main.nearClipPlane = _origClip; }
protected static void RestoreMainCamera() { DebugOutput("RestoreMainCamera"); sCam.transform.parent = sOrigParent; sCam.transform.localPosition = sOrigPosition; sCam.transform.localRotation = sOrigRotation; Camera.main.nearClipPlane = sOrigClip; sCurrentCamera.mt.SetCameraMode(CameraFilter.eCameraMode.Normal); sCam.SetFoV(sOrigFov); sCam.ActivateUpdate(); if (FlightGlobals.ActiveVessel != null && HighLogic.LoadedScene == GameScenes.FLIGHT) { //sCam.SetTarget(FlightGlobals.ActiveVessel.transform, FlightCamera.TargetMode.Transform); sCam.SetTarget(FlightGlobals.ActiveVessel.transform, FlightCamera.TargetMode.Vessel); } sOrigParent = null; if (sCurrentCamera != null) { sCurrentCamera.camActive = false; } sCurrentCamera = null; }
internal void StartFX() { warpTrailInner.GetComponent <Renderer> ().enabled = true; warpTrailOuter.GetComponent <Renderer> ().enabled = true; warpPlaneA.GetComponent <Renderer> ().enabled = true; warpPlaneB.GetComponent <Renderer> ().enabled = true; warpPlaneC.GetComponent <Renderer> ().enabled = true; warpPlaneD.GetComponent <Renderer> ().enabled = true; camera.SetFoV(160); }
protected static void RestoreMainCamera() { DebugOutput("RestoreMainCamera"); if (sCam != null) { sCam.transform.parent = sOrigParent; sCam.transform.localPosition = sOrigPosition; sCam.transform.localRotation = sOrigRotation; sCam.SetFoV(sOrigFov); sCam.ActivateUpdate(); if (FlightGlobals.ActiveVessel != null && HighLogic.LoadedScene == GameScenes.FLIGHT) { //sCam.SetTarget(FlightGlobals.ActiveVessel.transform, FlightCamera.TargetMode.Transform); sCam.SetTarget(FlightGlobals.ActiveVessel.transform, FlightCamera.TargetMode.Vessel); } sOrigParent = null; } if (sCurrentCamera != null) { sCurrentCamera.mt.SetCameraMode(CameraFilter.eCameraMode.Normal); sCurrentCamera.camActive = false; } sCurrentCamera = null; Camera.main.nearClipPlane = sOrigClip; ///////////////////////////////////// if (sOrigVesselTransformPart != null) { if (GameSettings.MODIFIER_KEY.GetKey(false)) { #if false ModuleDockingNode mdn = sOrigVesselTransformPart.FindModuleImplementing <ModuleDockingNode>(); if (mdn != null) { sOrigVesselTransformPart.SetReferenceTransform(mdn.controlTransform); } else #endif { // sOrigVesselTransformPart.SetReferenceTransform(sOrigVesselTransformPart.GetReferenceTransform()); } FlightGlobals.ActiveVessel.SetReferenceTransform(sOrigVesselTransformPart, true); ScreenMessages.PostScreenMessage(locControlPointRestored + " " + sOrigVesselTransformPart.partInfo.title); sOrigVesselTransformPart = null; } } ///////////////////////////////////// }
public void FixedUpdate() { if (isDazzling) { currentFOV = Mathf.Lerp(currentFOV, userFOV, 0.04f); currentDistance = Mathf.Lerp(currentDistance, userDistance, 0.04f); mainCam.SetFoV(currentFOV); mainCam.SetDistance(currentDistance); print("Distance: " + currentDistance); if (userFOV + 0.25 >= currentFOV) { mainCam.SetFoV(userFOV); mainCam.SetDistance(userDistance); print("Done messing with camera!"); isDazzling = false; } } }
int posCounter = 0; //debug void FixedUpdate() { /* * if(FloatingOrigin.fetch.offset!=lastOffset) * { * lastOffset = FloatingOrigin.fetch.offset; * OnFloatingOriginShift(lastOffset); * } */ if (FlightGlobals.ActiveVessel != null && (vessel == null || vessel != FlightGlobals.ActiveVessel)) { vessel = FlightGlobals.ActiveVessel; } if (vessel != null) { lastVesselPosition = vessel.transform.position; cameraParent.transform.position = manualPosition + (vessel.findWorldCenterOfMass() - vessel.rigidbody.velocity * Time.fixedDeltaTime); } //stationary camera if (isStationaryCamera) { if (posCounter < 3) { posCounter++; Debug.Log("flightCamera position: " + flightCamera.transform.position); flightCamera.transform.position = resetPositionFix; if (hasSavedRotation) { flightCamera.transform.rotation = savedRotation; } } if (flightCamera.Target != null) { flightCamera.setTarget(null); //dont go to next vessel if vessel is destroyed } if (camTarget != null) { Vector3 lookPosition = camTarget.position; if (camTarget.rigidbody) { lookPosition += camTarget.rigidbody.velocity * Time.fixedDeltaTime; } flightCamera.transform.rotation = Quaternion.LookRotation(lookPosition - flightCamera.transform.position, cameraUp); lastTargetPosition = lookPosition; } else if (hasTarget) { flightCamera.transform.rotation = Quaternion.LookRotation(lastTargetPosition - flightCamera.transform.position, cameraUp); } if (vessel != null) { if (referenceMode == ReferenceModes.Surface) { flightCamera.transform.position -= Time.fixedDeltaTime * Mathf.Clamp((float)vessel.srf_velocity.magnitude, 0, maxRelV) * vessel.srf_velocity.normalized; } else if (referenceMode == ReferenceModes.Orbit) { flightCamera.transform.position -= Time.fixedDeltaTime * Mathf.Clamp((float)vessel.obt_velocity.magnitude, 0, maxRelV) * vessel.obt_velocity.normalized; } else if (referenceMode == ReferenceModes.InitialVelocity) { Vector3 camVelocity = Vector3.zero; if (useOrbital && initialOrbit != null) { camVelocity = (initialOrbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy - vessel.GetObtVelocity()); } else { camVelocity = (initialVelocity - vessel.srf_velocity); } flightCamera.transform.position += camVelocity * Time.fixedDeltaTime; } } //mouse panning, moving Vector3 forwardLevelAxis = (Quaternion.AngleAxis(-90, cameraUp) * flightCamera.transform.right).normalized; Vector3 rightAxis = (Quaternion.AngleAxis(90, forwardLevelAxis) * cameraUp).normalized; //free move if (enableKeypad) { if (Input.GetKey(fmUpKey)) { manualPosition += cameraUp * freeMoveSpeed * Time.fixedDeltaTime; } else if (Input.GetKey(fmDownKey)) { manualPosition -= cameraUp * freeMoveSpeed * Time.fixedDeltaTime; } if (Input.GetKey(fmForwardKey)) { manualPosition += forwardLevelAxis * freeMoveSpeed * Time.fixedDeltaTime; } else if (Input.GetKey(fmBackKey)) { manualPosition -= forwardLevelAxis * freeMoveSpeed * Time.fixedDeltaTime; } if (Input.GetKey(fmLeftKey)) { manualPosition -= flightCamera.transform.right * freeMoveSpeed * Time.fixedDeltaTime; } else if (Input.GetKey(fmRightKey)) { manualPosition += flightCamera.transform.right * freeMoveSpeed * Time.fixedDeltaTime; } //keyZoom if (Input.GetKey(fmZoomInKey)) { zoomExp = Mathf.Clamp(zoomExp + (keyZoomSpeed * Time.fixedDeltaTime), 1, 8); } else if (Input.GetKey(fmZoomOutKey)) { zoomExp = Mathf.Clamp(zoomExp - (keyZoomSpeed * Time.fixedDeltaTime), 1, 8); } } if (camTarget == null && Input.GetKey(KeyCode.Mouse1)) { flightCamera.transform.rotation *= Quaternion.AngleAxis(Input.GetAxis("Mouse X") * 1.7f, Vector3.up); //*(Mathf.Abs(Mouse.delta.x)/7) flightCamera.transform.rotation *= Quaternion.AngleAxis(-Input.GetAxis("Mouse Y") * 1.7f, Vector3.right); flightCamera.transform.rotation = Quaternion.LookRotation(flightCamera.transform.forward, cameraUp); } if (Input.GetKey(KeyCode.Mouse2)) { manualPosition += flightCamera.transform.right * Input.GetAxis("Mouse X") * 2; manualPosition += forwardLevelAxis * Input.GetAxis("Mouse Y") * 2; } manualPosition += cameraUp * 10 * Input.GetAxis("Mouse ScrollWheel"); //autoFov if (camTarget != null && autoFOV) { float cameraDistance = Vector3.Distance(camTarget.position, flightCamera.transform.position); float targetFoV = Mathf.Clamp((7000 / (cameraDistance + 100)) - 4, 2, 60); //flightCamera.SetFoV(targetFoV); manualFOV = targetFoV; } //FOV if (!autoFOV) { zoomFactor = Mathf.Exp(zoomExp) / Mathf.Exp(1); manualFOV = 60 / zoomFactor; updateFOV = (currentFOV != manualFOV); if (updateFOV) { currentFOV = Mathf.Lerp(currentFOV, manualFOV, 0.1f); flightCamera.SetFoV(currentFOV); updateFOV = false; } } else { currentFOV = Mathf.Lerp(currentFOV, manualFOV, 0.1f); flightCamera.SetFoV(currentFOV); } lastPosition = flightCamera.transform.position; lastRotation = flightCamera.transform.rotation; if (airspeedNoiseTransform) { airspeedNoiseTransform.position = vessel.transform.position; } } if (hasDied && Time.time - diedTime > 2) { RevertCamera(); } }