public void UpdateIPD(float newIPD) { IPD = newIPD; float camOffset = newIPD / 2 * 0.1f * (1 / scaleMultiplier); MiraViewer.Instance.Left_Eye.transform.localPosition = new Vector3(-camOffset, 0, 0); MiraViewer.Instance.Right_Eye.transform.localPosition = new Vector3(camOffset, 0, 0); MiraPostRender distortionL = DistortionCamera.Instance.dcLeft.GetComponent <MiraPostRender>(); MiraPostRender distortionR = DistortionCamera.Instance.dcRight.GetComponent <MiraPostRender>(); distortionL.RecalculateDistortion(); distortionR.RecalculateDistortion(); }
/// <summary> /// /// </summary> /// <param name="Camera">Name of the Camera thats need to be added Right or Left.</param> public void AddCamera(char Camera) { GameObject go = new GameObject("DistortionCamera" + Camera, typeof(Camera)); Camera cam = go.GetComponent <Camera>(); { cam.clearFlags = CameraClearFlags.SolidColor; cam.backgroundColor = new Color(0f, 0f, 0f, 0f); cam.orthographic = true; cam.orthographicSize = 29.25f; cam.nearClipPlane = 0.3f; cam.farClipPlane = 99.21f; cam.depth = 999; if (Camera == 'L') { cam.rect = new Rect(0.5f, 0f, 0.5f, 1f); cam.cullingMask = 0; } else { cam.rect = new Rect(0f, 0f, 0.5f, 1f); cam.cullingMask = 0; } } go.AddComponent <MeshFilter>(); MiraPostRender mpost = go.AddComponent <MiraPostRender>(); if (Camera == 'L') { mpost.eye = MiraPostRender.Eye.Left; m_dcLeft = cam; } else { mpost.eye = MiraPostRender.Eye.Right; m_dcRight = cam; } mpost.InitializeDistortion(stereoFov, MiraArController.Instance.IPD); mpost.DistortionMesh(); }