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(); } }
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 }
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); }
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])); }
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); } }
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); }
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 + "]"); } } }
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()); } }
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); } }
// 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)); }
public virtual Vector3 GetEyeLocalPosition(NxrViewer.Eye eye) { return(Vector3.zero); }
public virtual Quaternion GetEyeLocalRotation(NxrViewer.Eye eye) { return(Quaternion.identity); }