示例#1
0
        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);
            }
        }
示例#2
0
        public static PCameraInfo Create()
        {
            PCameraInfo ret = new PCameraInfo();

            ret.ResetDefault();
            return(ret);
        }
示例#3
0
        private static bool Compare(PCameraInfo f1, PCameraInfo f2)
        {
            bool ret = SoftMath.FloatEqual(f1.fieldOfView, f2.fieldOfView) && SoftMath.FloatEqual(f1.nearPlane, f2.nearPlane) &&
                       SoftMath.FloatEqual(f1.farPlane, f2.farPlane);

            return(ret);
        }
示例#4
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);
 }
示例#5
0
 public void SetPCamera(PCameraInfo info)
 {
     if (m_PCameraInfo != info)
     {
         m_PCameraInfo   = info;
         this.CameraType = SoftCameraType.P;
         DoMustUpdatePlanes();
         DoMustGlobalToLocalMatrixChg();
     }
 }
示例#6
0
        public SoftCamera AddPCamera(PCameraInfo 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.SetPCamera(info);
            if (AddCamera(cam))
            {
                cam.IsMainCamera = isMainCamera;
                return(cam);
            }

            return(null);
        }