Пример #1
0
        public void UpdateCameraProjection()
        {
            if (NxrGlobal.hasInfinityARSDK)
            {
                return;
            }
            // Debug.Log("NxrEye->UpdateStereoValues,"+eye.ToString());
            Matrix4x4 proj = NxrViewer.Instance.Projection(eye);

            Debug.Log("NxrEye->UpdateCameraProjection," + eye.ToString() + "/" + proj.ToString());
            bool useDFT = NxrViewer.USE_DTR && !NxrGlobal.supportDtr;

            //DTR不需要修正
            if (!NxrViewer.Instance.IsWinPlatform && (Application.isEditor || useDFT))
            {
                if (monoCamera == null)
                {
                    monoCamera = controller.GetComponent <Camera>();
                }
                // Fix aspect ratio and near/far clipping planes.
                float nearClipPlane = monoCamera.nearClipPlane;
                float farClipPlane  = monoCamera.farClipPlane;

                float near = (NxrGlobal.fovNear >= 0 && NxrGlobal.fovNear < nearClipPlane) ? NxrGlobal.fovNear : nearClipPlane;
                float far  = (NxrGlobal.fovFar >= 0 && NxrGlobal.fovFar > farClipPlane) ? NxrGlobal.fovFar : farClipPlane;
                // DFT & 编辑器模式修正投影矩阵
                Debug.Log(eye.ToString() + ", " + cam.rect.ToString());
                NxrCameraUtils.FixProjection(cam.rect, near, far, ref proj);
            }

            // Set the eye camera's projection for rendering.
            cam.projectionMatrix = proj;
            NxrViewer.Instance.UpdateEyeCameraProjection(eye);

            float   ipd           = NxrViewer.Instance.Profile.viewer.lenses.separation;
            Vector3 localPosition = (eye == NxrViewer.Eye.Left ? -ipd / 2 : ipd / 2) * Vector3.right;

            if (localPosition.x != transform.localPosition.x)
            {
                transform.localPosition = localPosition;
            }

            BaseARDevice nxrDevice = NxrViewer.Instance.GetDevice();

            if (nxrDevice != null && nxrDevice.IsSptEyeLocalRotPos())
            {
                transform.localRotation = nxrDevice.GetEyeLocalRotation(eye);
                transform.localPosition = nxrDevice.GetEyeLocalPosition(eye);
                Debug.Log(eye + ". Local Rotation : " + transform.localRotation.eulerAngles.ToString());
                Debug.Log(eye + ". Local Position : " + transform.localPosition.x + "," + transform.localPosition.y + "," + transform.localPosition.z);
            }
        }
Пример #2
0
 public override Quaternion GetEyeLocalRotation(NxrViewer.Eye eye)
 {
     float[] eulerAngles = new float[3];
     if (eye == NxrViewer.Eye.Left)
     {
         NxrCameraUtils.RotationMatrixToEulerAngles(ref eulerAngles, NxrSDKApi.Instance.LeftEyeLocalRotation);
     }
     else if (eye == NxrViewer.Eye.Right)
     {
         NxrCameraUtils.RotationMatrixToEulerAngles(ref eulerAngles, NxrSDKApi.Instance.RightEyeLocalRotation);
     }
     return(Quaternion.Euler(eulerAngles[0], eulerAngles[1], eulerAngles[2]));
 }