コード例 #1
0
        void OnPostRenderListener(int cacheTextureId, NxrViewer.Eye eyeType)
        {
            if (NxrGlobal.isVR9Platform)
            {
                if (eyeType == NxrViewer.Eye.Right && Application.isMobilePlatform)
                {
                    if (NxrGlobal.DEBUG_LOG_ENABLED)
                    {
                        Debug.Log("OnPostRenderListener.PrepareFrame.Right");
                    }
                    NxrPluginEvent.Issue(NibiruRenderEventType.PrepareFrame);
                }
                return;
            }

            if (NxrViewer.USE_DTR && NxrGlobal.supportDtr)
            {
                // 左右眼绘制结束
                NibiruRenderEventType eventType = eyeType == NxrViewer.Eye.Left ? NibiruRenderEventType.LeftEyeEndFrame : NibiruRenderEventType.RightEyeEndFrame;
                // 左右眼绘制结束事件
                // int eyeTextureId = (int)cam.targetTexture.GetNativeTexturePtr();
                NxrPluginEvent.IssueWithData(eventType, cacheTextureId);
                if (NxrGlobal.DEBUG_LOG_ENABLED)
                {
                    Debug.Log("OnPostRender.eye[" + eyeType + "]");
                }
            }

            if (NxrViewer.USE_DTR && eyeType == NxrViewer.Eye.Right)
            {
                // NxrViewer.Instance.EnterXRMode();
            }
        }
コード例 #2
0
        public void UpdateEye(NxrViewer.Eye eyeTmp)
        {
#if UNITY_5_6_OR_NEWER
            this.eye = eyeTmp;
            fullRect = (eye == NxrViewer.Eye.Left ? new Rect(0, 0, 0.5f, 1) : new Rect(0.5f, 0, 0.5f, 1));
#endif
        }
コード例 #3
0
ファイル: NxrDevice.cs プロジェクト: Kong-W/HoloeverMR
 public override Vector3 GetEyeLocalPosition(NxrViewer.Eye eye)
 {
     if (eye == NxrViewer.Eye.Left)
     {
         return(new Vector3(NxrSDKApi.Instance.LeftEyeLocalPosition[0], NxrSDKApi.Instance.LeftEyeLocalPosition[1], NxrSDKApi.Instance.LeftEyeLocalPosition[2]));
     }
     else if (eye == NxrViewer.Eye.Right)
     {
         return(new Vector3(NxrSDKApi.Instance.RightEyeLocalPosition[0], NxrSDKApi.Instance.RightEyeLocalPosition[1], NxrSDKApi.Instance.RightEyeLocalPosition[2]));
     }
     return(Vector3.zero);
 }
コード例 #4
0
ファイル: NxrDevice.cs プロジェクト: Kong-W/HoloeverMR
 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]));
 }
コード例 #5
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
 protected void ComputeEyeFrustum(NxrViewer.Eye eyeType, float near, float far, float left, float right, float top, float bottom)
 {
     if (eyeType == NxrViewer.Eye.Left)
     {
         leftEyeDistortedProjection   = MakeProjection(left, top, right, bottom, near, far);
         leftEyeUndistortedProjection = MakeProjection(left, top, right, bottom, near, far);
     }
     else
     {
         rightEyeDistortedProjection   = MakeProjection(left, top, right, bottom, near, far);
         rightEyeUndistortedProjection = MakeProjection(left, top, right, bottom, near, far);
     }
 }
コード例 #6
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
 public void ComputeEyesForWin(NxrViewer.Eye eyeType, float near, float far, float left, float top, float right, float bottom)
 {
     Debug.Log("ComputeEyesForWin:" + eyeType + " | near=" + near + ",far=" + far + ",left=" + left + ",right=" + right + ",bottom=" + bottom + ",top=" + top);
     if (eyeType == NxrViewer.Eye.Left)
     {
         leftEyeUndistortedProjection = MakeProjection(left, top, right, bottom, near, far);
         leftEyeDistortedProjection   = leftEyeUndistortedProjection;
     }
     else
     {
         rightEyeUndistortedProjection = MakeProjection(left, top, right, bottom, near, far);
         rightEyeDistortedProjection   = rightEyeUndistortedProjection;
     }
     recommendedTextureSize = new Vector2(Screen.width, Screen.height);
 }
コード例 #7
0
 void OnPreRenderListener(int cacheTextureId, NxrViewer.Eye eyeType)
 {
     if (NxrGlobal.isVR9Platform)
     {
         return;
     }
     if (NxrViewer.USE_DTR && NxrGlobal.supportDtr)
     {
         // 左右眼绘制开始
         NibiruRenderEventType eventType = eyeType == NxrViewer.Eye.Left ? NibiruRenderEventType.LeftEyeBeginFrame : NibiruRenderEventType.RightEyeBeginFrame;
         NxrPluginEvent.IssueWithData(eventType, cacheTextureId);
         if (NxrGlobal.DEBUG_LOG_ENABLED)
         {
             Debug.Log("OnPreRender.eye[" + eyeType + "]");
         }
     }
 }
コード例 #8
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
        public Rect GetViewport(NxrViewer.Eye eye,
                                NxrViewer.Distortion distortion = NxrViewer.Distortion.Distorted)
        {
            switch (eye)
            {
            case NxrViewer.Eye.Left:
                return(distortion == NxrViewer.Distortion.Distorted ?
                       leftEyeDistortedViewport : leftEyeUndistortedViewport);

            case NxrViewer.Eye.Right:
                return(distortion == NxrViewer.Distortion.Distorted ?
                       rightEyeDistortedViewport : rightEyeUndistortedViewport);

            default:
                return(new Rect());
            }
        }
コード例 #9
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
        public Matrix4x4 GetProjection(NxrViewer.Eye eye,
                                       NxrViewer.Distortion distortion = NxrViewer.Distortion.Distorted)
        {
            switch (eye)
            {
            case NxrViewer.Eye.Left:
                return(distortion == NxrViewer.Distortion.Distorted ?
                       leftEyeDistortedProjection : leftEyeUndistortedProjection);

            case NxrViewer.Eye.Right:
                return(distortion == NxrViewer.Distortion.Distorted ?
                       rightEyeDistortedProjection : rightEyeUndistortedProjection);

            default:
                return(Matrix4x4.identity);
            }
        }
コード例 #10
0
        // Helper routine for creation of a stereo eye.
        private void CreateEye(NxrViewer.Eye eye)
        {
            string nm = name + (eye == NxrViewer.Eye.Left ? " Left" : " Right");

            NxrEye[] eyes    = GetComponentsInChildren <NxrEye>();
            NxrEye   mNxrEye = null;

            if (eyes != null && eyes.Length > 0)
            {
                foreach (NxrEye mEye in eyes)
                {
                    if (mEye.eye == eye)
                    {
                        mNxrEye = mEye;
                        break;
                    }
                }
            }
            // 创建新的
            if (mNxrEye == null)
            {
                GameObject go = new GameObject(nm);
                go.transform.SetParent(transform, false);
                go.AddComponent <Camera>().enabled = false;
                mNxrEye = go.AddComponent <NxrEye>();
            }

            if (NxrOverrideSettings.OnEyeCameraInitEvent != null)
            {
                NxrOverrideSettings.OnEyeCameraInitEvent(eye, mNxrEye.gameObject);
            }

            mNxrEye.Controller = this;
            mNxrEye.eye        = eye;
            mNxrEye.CopyCameraAndMakeSideBySide(this);
            mNxrEye.OnPostRenderListener += OnPostRenderListener;
            mNxrEye.OnPreRenderListener  += OnPreRenderListener;
            NxrViewer.Instance.eyes[eye == NxrViewer.Eye.Left ? 0 : 1] = mNxrEye;
            Debug.Log("CreateEye:" + nm + (eyes == null));
        }
コード例 #11
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
 public virtual Vector3 GetEyeLocalPosition(NxrViewer.Eye eye)
 {
     return(Vector3.zero);
 }
コード例 #12
0
ファイル: BaseARDevice.cs プロジェクト: Kong-W/HoloeverMR
 public virtual Quaternion GetEyeLocalRotation(NxrViewer.Eye eye)
 {
     return(Quaternion.identity);
 }