Пример #1
0
 internal void Start(Transform transform)
 {
     if (HighLogic.LoadedSceneIsEditor)
     {
         lastLocalPosition = transform.localPosition;
         lastPos           = transform.position;
         lastCamPos        = JSIAdvPodsUtil.GetCameraByName("Main Camera").transform.position - Vector3.up; // just to force update on first frame
     }
 }
Пример #2
0
 internal void Update(Transform transform)
 {
     if (HighLogic.LoadedSceneIsEditor)
     {
         Vector3 camPos = JSIAdvPodsUtil.GetCameraByName("Main Camera").transform.position;
         if (camPos != lastCamPos || transform.position != lastPos)
         {
             lastCamPos = camPos;
             transform.localPosition = lastLocalPosition + (camPos - transform.position) * 0.001f;
             lastPos = transform.position;
         }
     }
 }
Пример #3
0
        internal void CreateIVACamera()
        {
            JSIAdvPodsUtil.Log_Debug("CreateIVACamera");
            //Create a new IVA camera if one does not exist.
            if (IVAcamera == null)
            {
                //Create a new Gameobject to attach everything to.
                //Attach the IVA Camera to it.
                if (baseGO == null)
                {
                    baseGO = new GameObject("JSIAdvTransparentPods");
                }
                IVAcamera            = baseGO.gameObject.AddComponent <Camera>();
                IVAcamera.clearFlags = CameraClearFlags.Depth;
                IVAcameraTransform   = IVAcamera.transform;
                if (HighLogic.LoadedSceneIsFlight)
                {
                    //Get the Main Flight camera.
                    Maincamera = FlightCamera.fetch.mainCamera;
                    //The IVA camera Transform needs to be parented to the InternalSpace Transform.
                    IVAcameraTransform.parent = InternalSpace.Instance.transform;
                    MaincameraTransform       = Maincamera.transform;
                }
                else //Editor
                {
                    //Get the Main Flight camera.
                    //Maincamera = EditorCamera.Instance.cam;
                    Maincamera = JSIAdvPodsUtil.GetCameraByName("Main Camera");
                    //The IVA camera Transform needs to be parented to the Main Camera Transform.
                    //IVAcameraTransform.parent = EditorCamera.Instance.transform;
                    IVAcameraTransform.parent = Maincamera.transform;
                    MaincameraTransform       = Maincamera.transform;
                }

                //Depth of 3 is above the Main Cameras.
                IVAcamera.depth        = 3f;
                IVAcamera.fieldOfView  = Maincamera.fieldOfView;
                IVAcamera.farClipPlane = 200f;
                //Show Only Kerbals and Internal Space layers.
                IVAcamera.cullingMask = 1114112;
                //Attach a Culler class to the camera to cull objects we don't want rendered.
                if (IVACamJSICameraCuller == null && HighLogic.LoadedSceneIsFlight)
                {
                    IVACamJSICameraCuller = IVAcamera.gameObject.AddComponent <JSIIVACameraEvents>();
                }

                IVAcamera.allowHDR = false;
            }
            //Finally turn the new camera on.
            TurnonIVACamera();
        }