コード例 #1
0
            // TODO: instead of an Action, maybe pass an interface?
            // I think that might be easier to use. Hard to document
            // what each action arguments should be.
            public void DrawScene(GameTime gameTime, SpriteBatch spriteBatch, IStereoSceneDrawer sceneDrawer)
            {
                DrawSceneForEye(LeftEye, gameTime, renderTargetLeft, sceneDrawer);
                DrawSceneForEye(RightEye, gameTime, renderTargetRight, sceneDrawer);

                var leftRectangle = new Rectangle(
                    LeftEye.Viewport.X, LeftEye.Viewport.Y,
                    LeftEye.Viewport.Width, LeftEye.Viewport.Height);

                var rightRectangle = new Rectangle(
                    RightEye.Viewport.X, RightEye.Viewport.Y,
                    LeftEye.Viewport.Width, RightEye.Viewport.Height);

                graphicsDeviceManager.GraphicsDevice.SetRenderTarget(null);
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque /*, null, null, null, distortionShader*/);
                spriteBatch.Draw(renderTargetLeft, leftRectangle, Color.White);
                spriteBatch.End();

                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque /*, null, null, null, distortionShader*/);
                spriteBatch.Draw(renderTargetRight, rightRectangle, Color.White);
                spriteBatch.End();
                // TODO: implement monoscopic rendering, which will basically just call DrawScene
                // once with the full ViewPort and a non-stereo view matrix/projection.
            }
コード例 #2
0
 private void DrawSceneForEye(VREye eye, GameTime gameTime, RenderTarget2D renderTarget, IStereoSceneDrawer sceneDrawer)
 {
     graphicsDeviceManager.GraphicsDevice.SetRenderTarget(renderTarget);
     graphicsDeviceManager.GraphicsDevice.DepthStencilState = new DepthStencilState()
     {
         DepthBufferEnable = true
     };
     graphicsDeviceManager.GraphicsDevice.Clear(Color.Navy);
     sceneDrawer.DrawScene(
         gameTime: gameTime,
         viewport: graphicsDeviceManager.GraphicsDevice.Viewport,
         // Note: The transform is in view space, but VREye.Translation is in world
         // space, so we need to negate it here.
         stereoTransform: Matrix.CreateTranslation(Vector3.Negate(eye.Translation)),
         view: eye.Transform,
         projection: eye.Projection);
 }