예제 #1
0
        protected override void Draw(GameTime gameTime)
        {
            // draw scene for both eyes into respective rendertarget
            for (int eye = 0; eye < 2; eye++)
            {
                GraphicsDevice.SetRenderTarget(renderTargetEye[eye]);
                GraphicsDevice.Clear(new Color(130, 180, 255));

                Matrix view       = rift.GetEyeViewMatrix(eye, playerMatrix);
                Matrix projection = rift.GetProjectionMatrix(eye);

                //manyCubes.Draw(view, projection);

                //base.Draw(gameTime);
            }

            // submit rendertargets to the Rift
            int result = rift.SubmitRenderTargets(renderTargetEye[0], renderTargetEye[1]);

            // show left eye view also on the monitor screen
            DrawEyeViewIntoBackbuffer(0);
        }
예제 #2
0
 public override Matrix GetProjectionMatrix(int eye)
 {
     return(_oculusRift.GetProjectionMatrix(eye));
 }
        protected override void Draw(GameTime gameTime) //override
        {
            //riftWatch.Restart();


            // draw scene for both eyes into respective rendertarget
            for (int eye = 0; eye < 2; eye++)
            {
                activeBodies = 0;

                GraphicsDevice.SetRenderTarget(renderTargetEye[eye]);
                GraphicsDevice.Clear(Color.CornflowerBlue);

                GraphicsDevice.BlendState        = BlendState.Opaque;
                GraphicsDevice.DepthStencilState = DepthStencilState.Default;

                Matrix view       = rift.GetEyeViewMatrix(eye, playerMatrix);
                Matrix projection = rift.GetProjectionMatrix(eye);
                //manyCubes.Draw(view, projection);

                DrawCloth();
                //DrawIslands();

                //BasicEffect.View = view;// Camera.View;
                //BasicEffect.Projection = projection;// Camera.Projection;
                //BasicEffect.DiffuseColor = Color.LightGray.ToVector3();

                /*// Draw all shapes
                 * foreach (RigidBody body in World.RigidBodies)
                 * {
                 *
                 *
                 *  if (body.Shape is ConvexHullShape)
                 *  {
                 *
                 *  }
                 *  else
                 *  {
                 *      if (body.IsActive)
                 *      {
                 *          activeBodies++;
                 *      }
                 *
                 *      if (body.Tag is int || body.IsParticle)
                 *      {
                 *          continue;
                 *      }
                 *      AddBodyToDrawList(body);
                 *  }
                 * }
                 *
                 #region Debug Draw All Contacts
                 * //foreach (Arbiter a in World.ArbiterMap)
                 * //{
                 * //    foreach (Contact c in a.ContactList)
                 * //    {
                 * //        DebugDrawer.DrawLine(c.Position1 + 0.5f * JVector.Left, c.Position1 + 0.5f * JVector.Right, Color.Green);
                 * //        DebugDrawer.DrawLine(c.Position1 + 0.5f * JVector.Up, c.Position1 + 0.5f * JVector.Down, Color.Green);
                 * //        DebugDrawer.DrawLine(c.Position1 + 0.5f * JVector.Forward, c.Position1 + 0.5f * JVector.Backward, Color.Green);
                 *
                 * //        DebugDrawer.DrawLine(c.Position2 + 0.5f * JVector.Left, c.Position2 + 0.5f * JVector.Right, Color.Red);
                 * //        DebugDrawer.DrawLine(c.Position2 + 0.5f * JVector.Up, c.Position2 + 0.5f * JVector.Down, Color.Red);
                 * //        DebugDrawer.DrawLine(c.Position2 + 0.5f * JVector.Forward, c.Position2 + 0.5f * JVector.Backward, Color.Red);
                 * //    }
                 * //}
                 *
                 #endregion
                 *
                 *
                 * if (primitives.Length > 0)
                 * {
                 *  foreach (Primitives3D.GeometricPrimitive prim in primitives)
                 *  {
                 *
                 *      prim.Draw(BasicEffect, view, projection);
                 *  }
                 *
                 * }
                 *
                 *
                 *
                 *
                 * if (convexObj.Count > 0)
                 * {
                 *  foreach (ConvexHullObject prim in convexObj)
                 *  {
                 *
                 *      prim.Draw(gameTime, view, projection);
                 *  }
                 * }
                 *
                 *
                 *
                 * //manyCubes.UnDraw(view, projection);
                 */
                DrawJitterDebugInfo();

                if (DebugDrawer != null)
                {
                    //Demo.GraphicsDevice.BlendState = BlendState.Opaque;
                    //Demo.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

                    DebugDrawer.Draw(gameTime, view, projection);
                }

                PhysicScenes[currentScene].Draw(gameTime, view, projection, eye); //gameTime, view, projection, eye

                //base.Draw(gameTime);
            }



            //GraphicsDevice.Clear(backgroundColor);
            //GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            //BasicEffect.View = Camera.View;
            //BasicEffect.Projection = Camera.Projection;

            GraphicsDevice.RasterizerState = cullMode;
            GraphicsDevice.RasterizerState = normal;

            base.Draw(gameTime);

            // submit rendertargets to the Rift


            //riftWatch.Restart();

            /*if (startOVRDrawThread == 0)
             * {
             *  Thread main_thread_update = new Thread(() =>
             *  {
             *  _thread_looper:
             *
             *      try
             *      {
             *
             *      }
             *      catch (Exception ex)
             *      {
             *
             *      }
             *      Thread.Sleep(0);
             *      goto _thread_looper;
             *
             *      //ShutDown();
             *      //ShutDownGraphics();
             *
             *  }, 0);
             *
             *  main_thread_update.IsBackground = true;
             *  main_thread_update.SetApartmentState(ApartmentState.STA);
             *  main_thread_update.Start();
             *  startOVRDrawThread = 1;
             * }*/


            result = rift.SubmitRenderTargets(renderTargetEye[0], renderTargetEye[1]);

            //Console.WriteLine(riftWatch.Elapsed.Milliseconds);


            // show left eye view also on the monitor screen
            DrawEyeViewIntoBackbuffer(0);
            //DrawEyeViewIntoBackbuffer(1);
            //Console.WriteLine(riftWatch.Elapsed.Milliseconds);
        }