コード例 #1
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
 public virtual void Destroy()
 {
     if (device == this)
     {
         device = null;
     }
 }
コード例 #2
0
ファイル: NxrEye.cs プロジェクト: zhangli987/HMS_V1
        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);
            }
        }
コード例 #3
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
        public static BaseARDevice GetDevice()
        {
            if (device == null)
            {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                device = new EditorDevice();
#elif ANDROID_DEVICE
                device = new AndroidDevice();
#else
                throw new InvalidOperationException("Unsupported device.");
#endif
            }
            return(device);
        }