public void UpdateCamera(Camera camera)
        {
            if (camera == null)
            {
                return;
            }
            bool isMainCam = camera.CompareTag("MainCamera");
            var  trans     = camera.transform;

            this.Position     = trans.position;
            this.LookAt       = trans.forward;
            this.Up           = trans.up;
            this.IsMainCamera = isMainCam;
            this.Depth        = (int)camera.depth;
            if (camera.orthographic)
            {
                OCameraInfo info = OCameraInfo.Create();
                info.Size      = camera.orthographicSize;
                info.nearPlane = camera.nearClipPlane;
                info.farPlane  = camera.farClipPlane;
                this.SetOCamera(info);
            }
            else
            {
                PCameraInfo info = PCameraInfo.Create();
                info.nearPlane   = camera.nearClipPlane;
                info.farPlane    = camera.farClipPlane;
                info.fieldOfView = camera.fieldOfView;
                this.SetPCamera(info);
            }
        }
        public static OCameraInfo Create()
        {
            OCameraInfo ret = new OCameraInfo();

            ret.ResetDefault();
            return(ret);
        }
Beispiel #3
0
 // 添加UNITY摄影机
 public SoftCamera AddCamera(UnityEngine.Camera cam)
 {
     if (cam != null)
     {
         bool isMainCamera = cam.CompareTag("MainCamera");
         if (cam.orthographic)
         {
             OCameraInfo info = OCameraInfo.Create();
             info.Size      = cam.orthographicSize;
             info.nearPlane = cam.nearClipPlane;
             info.farPlane  = cam.farClipPlane;
             var trans = cam.transform;
             return(AddOCamera(info, trans.position, trans.up, trans.forward, (int)cam.depth, isMainCamera));
         }
         else
         {
             PCameraInfo info = PCameraInfo.Create();
             info.nearPlane   = cam.nearClipPlane;
             info.farPlane    = cam.farClipPlane;
             info.fieldOfView = cam.fieldOfView;
             var trans = cam.transform;
             return(AddPCamera(info, trans.position, trans.up, trans.forward, (int)cam.depth, isMainCamera));
         }
     }
     return(null);
 }
 public void SetOCamera(OCameraInfo info)
 {
     if (m_OCameraInfo != info)
     {
         m_OCameraInfo   = info;
         this.CameraType = SoftCameraType.O;
         DoMustUpdatePlanes();
         DoMustGlobalToLocalMatrixChg();
     }
 }
Beispiel #5
0
        // 添加
        public SoftCamera AddOCamera(OCameraInfo info, Vector3 pos, Vector3 up, Vector3 lookAt, int depth, bool isMainCamera = false)
        {
            SoftCamera cam = new SoftCamera(this);

            cam.Position = pos;
            cam.Up       = up;
            cam.LookAt   = lookAt;
            cam.Depth    = depth;
            cam.SetOCamera(info);
            if (AddCamera(cam))
            {
                cam.IsMainCamera = isMainCamera;
                return(cam);
            }
            return(null);
        }
        private static bool Compare(OCameraInfo f1, OCameraInfo f2)
        {
            bool ret = SoftMath.FloatEqual(f1.Size, f2.Size) && SoftMath.FloatEqual(f1.nearPlane, f2.nearPlane) && SoftMath.FloatEqual(f1.farPlane, f2.farPlane);

            return(ret);
        }