Ejemplo n.º 1
0
        private void UpdateStereoPerspective()
        {
            Camera camera = this.Camera;

            // Apply camera settings to the frustum.
            this._frustum.NearClip     = camera.nearClipPlane;
            this._frustum.FarClip      = camera.farClipPlane;
            this._frustum.CameraOffset = this._cameraOffset;

            this._frustum.Ipd = Mathf.Lerp(
                0, camera.stereoSeparation, this._stereoWeight);

            this._frustum.HeadPose = PoseExtensions.Lerp(
                this._frustum.DefaultHeadPose,
                this._headTarget.Pose,
                this._stereoWeight);

            // Update the camera's view matrices for the
            // center, left, and right eyes.
            camera.transform.SetLocalPose(this.GetLocalPose(ZEye.Center));

            camera.SetStereoViewMatrix(
                Camera.StereoscopicEye.Left,
                this._frustum.GetViewMatrix(ZEye.Left, this.WorldScale) *
                this._monoWorldToCameraMatrix);

            camera.SetStereoViewMatrix(
                Camera.StereoscopicEye.Right,
                this._frustum.GetViewMatrix(ZEye.Right, this.WorldScale) *
                this._monoWorldToCameraMatrix);

            // Update the camera's projection matrices for the
            // center, left, and right eyes.
            camera.projectionMatrix =
                this._frustum.GetProjectionMatrix(ZEye.Center);

            camera.SetStereoProjectionMatrix(
                Camera.StereoscopicEye.Left,
                this._frustum.GetProjectionMatrix(ZEye.Left));

            camera.SetStereoProjectionMatrix(
                Camera.StereoscopicEye.Right,
                this._frustum.GetProjectionMatrix(ZEye.Right));
        }