Inheritance: Microsoft.Xna.Framework.Game
Exemplo n.º 1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (JitterDemo game = new JitterDemo())
     {
         game.Run();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread()]
        static void Main(string[] args)
        {
            using (JitterDemo game = new JitterDemo())
            {
                //Jitter.DynamicTree dt = new Jitter.DynamicTree();

                //JBBox jb;
                //jb.Min = JVector.Zero;
                //jb.Max = JVector.One;

                //JBBox jb2;
                //jb2.Min = JVector.Zero;
                //jb.Max = JVector.One * 2.0f;

                //dt.CreateProxy(ref jb, 1);
                //dt.CreateProxy(ref jb, 2);

                //JBBox testBox;
                //testBox.Min = JVector.Zero;
                //testBox.Max = JVector.One *20.0f;

                //dt.Query(bla, ref testBox);
                //dt.MoveProxy


                game.Run();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread()]
        static void Main(string[] args)
        {
            using (JitterDemo game = new JitterDemo())
            {
                //Jitter.DynamicTree dt = new Jitter.DynamicTree();

                //JBBox jb;
                //jb.Min = JVector.Zero;
                //jb.Max = JVector.One;

                //JBBox jb2;
                //jb2.Min = JVector.Zero;
                //jb.Max = JVector.One * 2.0f;

                //dt.CreateProxy(ref jb, 1);
                //dt.CreateProxy(ref jb, 2);

                //JBBox testBox;
                //testBox.Min = JVector.Zero;
                //testBox.Max = JVector.One *20.0f;

                //dt.Query(bla, ref testBox);
                //dt.MoveProxy


                game.Run();
            }



        }
Exemplo n.º 4
0
        public void Draw(GameTime gameTime, Matrix view, Matrix projection) //override //, Matrix view, Matrix projection //override //GameTime gameTime,  GameTime gameTime,
        {
            JitterDemo demo = Game as JitterDemo;

            //GraphicsDevice.BlendState = BlendState.Opaque;
            //GraphicsDevice.DepthStencilState = DepthStencilState.None;

            //basicEffect.View = demo.Camera.View;
            //basicEffect.Projection = demo.Camera.Projection;
            basicEffect.View       = view;       // demo.Camera.View;
            basicEffect.Projection = projection; // demo.Camera.Projection;
            //basicEffect.TextureEnabled = false;

            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                if (lineIndex > 0)
                {
                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, LineList, 0, lineIndex / 2);
                }

                if (triangleIndex > 0)
                {
                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.TriangleList, TriangleList, 0, triangleIndex / 3);
                }
            }

            lineIndex     = 0;
            triangleIndex = 0;

            base.Draw(gameTime);
        }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     using (JitterDemo game = new JitterDemo())
     {
         game.Run();
     }
 }
Exemplo n.º 6
0
        public override void Draw(GameTime gameTime)
        {
            JitterDemo demo = Game as JitterDemo;

            GraphicsDevice.VertexDeclaration = quadVertexDecl;

            GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Wrap;

            quadEffect.Begin();

            quadEffect.View       = demo.Camera.View;
            quadEffect.Projection = demo.Camera.Projection;

            quadEffect.SpecularColor = new Vector3(0.1f, 0.1f, 0.1f);

            foreach (EffectPass pass in quadEffect.CurrentTechnique.Passes)
            {
                pass.Begin();

                GraphicsDevice.DrawUserIndexedPrimitives
                <VertexPositionNormalTexture>(
                    PrimitiveType.TriangleList,
                    Vertices, 0, 4,
                    Indexes, 0, 2);

                pass.End();
            }
            quadEffect.End();

            base.Draw(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            JitterDemo demo = Game as JitterDemo;

            basicEffect.View       = demo.Camera.View;
            basicEffect.Projection = demo.Camera.Projection;



            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                if (lineIndex > 0)
                {
                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(
                        PrimitiveType.LineList, LineList, 0, lineIndex / 2);
                }

                if (triangleIndex > 0)
                {
                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(
                        PrimitiveType.TriangleList, TriangleList, 0, triangleIndex / 3);
                }
            }

            lineIndex     = 0;
            triangleIndex = 0;

            base.Draw(gameTime);
        }
Exemplo n.º 8
0
        public override void Draw(GameTime gameTime)
        {
            if (LineList.Count + PointList.Count == 0)
            {
                return;
            }

            JitterDemo demo = Game as JitterDemo;

            basicEffect.View       = demo.Camera.View;
            basicEffect.Projection = demo.Camera.Projection;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                GraphicsDevice.RenderState.PointSize = 5;
                GraphicsDevice.VertexDeclaration     = new VertexDeclaration(GraphicsDevice, VertexPositionColor.VertexElements);

                if (PointList.Count > 0)
                {
                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.PointList, PointList.ToArray(), 0, PointList.Count);
                }

                if (LineList.Count > 0)
                {
                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, LineList.ToArray(), 0, LineList.Count / 2);
                }

                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }
        public override void Initialize()
        {
            base.Initialize();
            primitive = new TerrainPrimitive(GraphicsDevice,
                                             (int a, int b) =>
                                             { return((float)(Math.Sin(a * 0.1f) * Math.Cos(b * 0.1f)) * 3); });

            JitterDemo demo = this.Game as JitterDemo;

            TerrainShape terrainShape = new TerrainShape(primitive.heights, 1.0f, 1.0f);

            terrainBody          = new RigidBody(terrainShape);
            terrainBody.IsStatic = true;
            terrainBody.Tag      = true;

            demo.World.AddBody(terrainBody);

            World = Matrix.CreateTranslation(-50, 0, -50);
        }
        public override void Draw(GameTime gameTime)
        {
            JitterDemo demo = this.Game as JitterDemo;

            GraphicsDevice.SamplerStates[0]  = SamplerState.AnisotropicWrap;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            effect.View       = demo.Camera.View;
            effect.Projection = demo.Camera.Projection;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                GraphicsDevice.DrawUserIndexedPrimitives
                <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                              vertices, 0, 4, indices, 0, 2);
            }

            base.Draw(gameTime);
        }
Exemplo n.º 11
0
        public override void Draw(GameTime gameTime)
        {
            JitterDemo demo = Game as JitterDemo;

            basicEffect.View       = demo.Camera.View;
            basicEffect.Projection = demo.Camera.Projection;

            basicEffect.TextureEnabled = false;
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                if (triangleIndex > 0)
                {
                    int triangles = triangleIndex / 3;
                    int loop      = 0;

                    while (triangles > 20000)
                    {
                        int numToDraw = 20000;
                        triangles -= numToDraw;

                        GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(
                            PrimitiveType.TriangleList, TriangleList, loop * 3 * 20000, numToDraw);

                        loop++;
                    }

                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(
                        PrimitiveType.TriangleList, TriangleList, loop * 3 * 20000, triangles);
                }

                if (lineIndex > 0)
                {
                    int lines = lineIndex / 2;
                    int loop  = 0;

                    while (lines > 20000)
                    {
                        int numToDraw = 20000;
                        lines -= numToDraw;

                        GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(
                            PrimitiveType.LineList, LineList, loop * 2 * 20000, numToDraw);

                        loop++;
                    }
                    GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(
                        PrimitiveType.LineList, LineList, loop * 2 * 20000, lines);
                }
            }

            basicEffect.TextureEnabled = true;

            sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, basicEffect);

            foreach (var point in points)
            {
                sb.Draw(pointTex, point.point, null, point.color, 0, new Vector2(5, 5), 0.01f, SpriteEffects.None, 0);
            }

            foreach (var s in strings)
            {
                sb.DrawString(font, s.text, s.point, s.color);
            }

            sb.End();

            points.Clear();
            strings.Clear();

            lineIndex     = 0;
            triangleIndex = 0;

            base.Draw(gameTime);
        }
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread()]
        static void Main(string[] args)
        {
            using (game = new JitterDemo())
            {
                //Jitter.DynamicTree dt = new Jitter.DynamicTree();

                //JBBox jb;
                //jb.Min = JVector.Zero;
                //jb.Max = JVector.One;

                //JBBox jb2;
                //jb2.Min = JVector.Zero;
                //jb.Max = JVector.One * 2.0f;

                //dt.CreateProxy(ref jb, 1);
                //dt.CreateProxy(ref jb, 2);

                //JBBox testBox;
                //testBox.Min = JVector.Zero;
                //testBox.Max = JVector.One *20.0f;

                //dt.Query(bla, ref testBox);
                //dt.MoveProxy


                /*if (startOVRDrawThread == 0)
                 * {
                 *  Thread main_thread_update = new Thread(() =>
                 *  {
                 *      OculusRift rift = new OculusRift();
                 *      RenderTarget2D[] renderTargetEye = new RenderTarget2D[2];
                 *
                 *  _thread_looper:
                 *
                 *      try
                 *      {
                 *          if (game != null)
                 *          {
                 *
                 *
                 *              if (game.hasInit == 1)
                 *              {
                 *                  //Console.WriteLine("test1");
                 *                  int result = rift.Init(game.GraphicsDevice);
                 *
                 *                  if (result != 0)
                 *                  {
                 *                      throw new InvalidOperationException("rift.Init result: " + result);
                 *                  }
                 *                  for (int eye = 0; eye < 2; eye++)
                 *                  {
                 *                      renderTargetEye[eye] = rift.CreateRenderTargetForEye(eye);
                 *                  }
                 *
                 *                  game.hasInit = 2;
                 *              }
                 *
                 *              if (game.hasInit == 2)
                 *              {
                 *                  ///Console.WriteLine("test2");
                 *                  /*for (int eye = 0; eye < 2; eye++)
                 *                  {
                 *
                 *                      game.GraphicsDevice.SetRenderTarget(renderTargetEye[eye]);
                 *                      game.GraphicsDevice.Clear(Color.CornflowerBlue);
                 *
                 *                      game.GraphicsDevice.BlendState = BlendState.Opaque;
                 *                      game.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                 *
                 *                  }
                 *
                 *                  var result = rift.SubmitRenderTargets(renderTargetEye[0], renderTargetEye[1]);
                 *
                 *                  //game.GraphicsDevice.SetRenderTarget(null);
                 *                  //game.GraphicsDevice.Clear(Color.CornflowerBlue);
                 *              }
                 *          }
                 *      }
                 *      catch (Exception ex)
                 *      {
                 *
                 *      }
                 *
                 *      Thread.Sleep(1);
                 *      goto _thread_looper;
                 *
                 *      //ShutDown();
                 *      //ShutDownGraphics();
                 *
                 *  }, 0);
                 *
                 *  main_thread_update.IsBackground = true;
                 *  main_thread_update.SetApartmentState(ApartmentState.STA);
                 *  main_thread_update.Start();
                 *
                 *  startOVRDrawThread = 1;
                 * }*/
                game.Run();
            }
        }