Пример #1
0
        /// <summary>
        /// Updates the <see cref="Camera.projectionMatrix"/> of the <see cref="renderCamera"/>
        /// which creates a holographic projection effect.
        /// </summary>
        /// <param name="screen">The screen the camera is facing.</</param>
        /// <param name="eyes">The eye position in world space.</param>
        /// <param name="nearClipPlane">The near clip plane of the camera.</param>
        /// <param name="farClipPlane">The far clip plane of the camera.</param>
        public void UpdateCameraProjection(VirtualScreen screen, Vector3 eyes,
                                           float nearClipPlane, float farClipPlane)
        {
            // Use the world position of the specified eye anchor
            // to calculate the local position in the screen coordinate system.
            // Finally use the local position to compute the projection matrix
            // for the holographic projection.
            // Additionally correct the projection with a bimber matrix if
            // necessary.
            var local      = screen.transform.InverseTransformPoint(eyes);
            var projection = VirtualProjection.ComputeHolographicProjectionMatrix(local,
                                                                                  nearClipPlane, farClipPlane, screen.width, screen.height);
            var bimber = this.m_Calibration.projectionCorrection ? this.m_BimberMatrix : Matrix4x4.identity;

            this.m_Camera.nearClipPlane    = nearClipPlane;
            this.m_Camera.farClipPlane     = farClipPlane;
            this.m_Camera.projectionMatrix = bimber * projection;
        }
Пример #2
0
        public static VirtualCamera CreateCamera(VirtualEnvironment environment,
                                                 VirtualScreen.Kind kind, VirtualEyes.StereoTarget target)
        {
            var camera = new GameObject($"Virtual Camera {kind}")
                         .AddComponent <VirtualCamera>();

            if (target != VirtualEyes.StereoTarget.Mono)
            {
                camera.name += target == VirtualEyes.StereoTarget.Left ? " L" : " R";
            }

            camera.stereoTarget       = target;
            camera.screenKind         = kind;
            camera.transform.parent   = environment.transform;
            camera.transform.position = environment.eyes.transform.position;
            camera.transform.rotation = environment.transform.rotation * VirtualScreen.GetLocalRotation(kind);

            return(camera);
        }