Inheritance: Behavior
Beispiel #1
0
        /// <summary>
        /// Update the behavior
        /// </summary>
        /// <param name="gameTime">The current game time.</param>
        protected override void Update(TimeSpan gameTime)
        {
            if (this.vrProvider == null)
            {
                this.vrProvider = this.Owner.FindComponent <VRProvider>(false);
            }

            if (this.vrProvider == null || !this.vrProvider.IsConnected)
            {
                return;
            }

            var eyePoses          = this.vrProvider.EyePoses;
            var trackerCameraPose = this.vrProvider.TrackerCameraPose;

            // Left eye camera
            this.UpdateCamera(this.LeftEyeCamera, (int)VREyeType.LeftEye);
            this.UpdateCamera(this.RightEyeCamera, (int)VREyeType.RightEye);

            // Camera tracker
            this.TrackerAnchorTransform.LocalPosition    = trackerCameraPose.Position;
            this.TrackerAnchorTransform.LocalOrientation = trackerCameraPose.Orientation;

            // Center
            this.CenterEyeAnchorTransform.LocalPosition    = eyePoses[(int)VREyeType.CenterEye].Position;
            this.CenterEyeAnchorTransform.LocalOrientation = eyePoses[(int)VREyeType.CenterEye].Orientation;

            if (this.LeftEyeCamera.RenderTarget == this.RightEyeCamera.RenderTarget)
            {
                this.RightEyeCamera.ClearFlags = ClearFlags.DepthAndStencil;
            }
            else
            {
                this.RightEyeCamera.ClearFlags = ClearFlags.All;
            }

            if (this.UpdatedAnchors != null)
            {
                this.UpdatedAnchors(this);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Update the behavior
        /// </summary>
        /// <param name="gameTime">The current game time.</param>
        protected override void Update(TimeSpan gameTime)
        {
            if (this.vrProvider == null)
            {
                this.vrProvider = this.Owner.FindComponent <VRProvider>(false);
            }

            if (this.vrProvider == null || !this.vrProvider.IsConnected)
            {
                return;
            }

            var eyeProperties     = this.vrProvider.EyesProperties;
            var trackerCameraPose = this.vrProvider.TrackerCameraPose;

            // Eye cameras
            this.UpdateCamera(this.LeftEyeCamera, (int)VREyeType.LeftEye);
            this.UpdateCamera(this.RightEyeCamera, (int)VREyeType.RightEye);

            // Camera tracker
            this.TrackerAnchorTransform.LocalPosition    = trackerCameraPose.Position;
            this.TrackerAnchorTransform.LocalOrientation = trackerCameraPose.Orientation;

            // Update controllers
            foreach (var vrController in this.vrControllers)
            {
                int index;
                switch (vrController.Role)
                {
                case VRControllerRole.LeftHand:
                    index = this.vrProvider.LeftControllerIndex;
                    break;

                case VRControllerRole.RightHand:
                    index = this.vrProvider.RightControllerIndex;
                    break;

                default:
                    index = vrController.ControllerIndex;
                    break;
                }

                var states = this.vrProvider.ControllerStates;

                VRGenericControllerState newState;
                if ((index >= 0) &&
                    (states != null) &&
                    (index < states.Length))
                {
                    newState = states[index];
                }
                else
                {
                    newState = default(VRGenericControllerState);
                }

                vrController.UpdateState(newState);
            }

            // Center
            var centerEyePose = eyeProperties[(int)VREyeType.CenterEye].Pose;

            this.CenterEyeAnchorTransform.LocalPosition    = centerEyePose.Position;
            this.CenterEyeAnchorTransform.LocalOrientation = centerEyePose.Orientation;

            if (this.LeftEyeCamera.RenderTarget == this.RightEyeCamera.RenderTarget)
            {
                this.RightEyeCamera.ClearFlags = ClearFlags.DepthAndStencil;
            }
            else
            {
                this.RightEyeCamera.ClearFlags = ClearFlags.All;
            }

            if (this.UpdatedAnchors != null)
            {
                this.UpdatedAnchors(this);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Update the behavior
        /// </summary>
        /// <param name="gameTime">The current game time.</param>
        protected override void Update(TimeSpan gameTime)
        {
            if (this.vrProvider == null)
            {
                this.vrProvider = this.Owner.FindComponent<VRProvider>(false);
            }

            if (this.vrProvider == null || !this.vrProvider.IsConnected)
            {
                return;
            }

            var eyePoses = this.vrProvider.EyePoses;
            var trackerCameraPose = this.vrProvider.TrackerCameraPose;

            // Left eye camera
            this.UpdateCamera(this.LeftEyeCamera, (int)VREyeType.LeftEye);
            this.UpdateCamera(this.RightEyeCamera, (int)VREyeType.RightEye);

            // Camera tracker
            this.TrackerAnchorTransform.LocalPosition = trackerCameraPose.Position;
            this.TrackerAnchorTransform.LocalOrientation = trackerCameraPose.Orientation;

            // Center
            this.CenterEyeAnchorTransform.LocalPosition = eyePoses[(int)VREyeType.CenterEye].Position;
            this.CenterEyeAnchorTransform.LocalOrientation = eyePoses[(int)VREyeType.CenterEye].Orientation;

            if (this.LeftEyeCamera.RenderTarget == this.RightEyeCamera.RenderTarget)
            {
                this.RightEyeCamera.ClearFlags = ClearFlags.DepthAndStencil;
            }
            else
            {
                this.RightEyeCamera.ClearFlags = ClearFlags.All;
            }

            if (this.UpdatedAnchors != null)
            {
                this.UpdatedAnchors(this);
            }
        }