/// <summary>
 /// Test single model
 /// </summary>
 public static void TestSingleModel()
 {
     Model testModel = null;
     TestGame.Start("TestSingleModel",
         delegate
         {
             testModel = new Model("Hotel01");//"OilTanks");
         },
         delegate
         {
             //BaseGame.Device.RenderState.DepthBufferEnable = true;
             testModel.Render(Matrix.Identity);
         });
 }
        /// <summary>
        /// Test car physics on a plane (xy) with some dummy guard rail for
        /// simple colision checking.
        /// </summary>
        public static void TestCarPhysicsOnPlaneWithGuardRails()
        {
            PlaneRenderer plane = null;
            // Use a simple object to simulate our guard rails we have in the game.
            Model guardRailModel = null;

            TestGame.Start("TestCarPhysicsOnPlaneWithGuardRails",
                delegate
                {
                    plane = new PlaneRenderer(Vector3.Zero,
                        new Plane(new Vector3(0, 0, 1), 0),
                        new Material("CityGround", "CityGroundNormal"), 500.0f);
                        //new Material("Road", "RoadNormal"), 500.0f);
                    guardRailModel = new Model("RoadColumnSegment");

                    // Put car 10m above the ground to test gravity and ground plane!
                    SpeedyRacerManager.Player.SetCarPosition(
                        new Vector3(0, 0, 10),
                        new Vector3(0, 1, 0),
                        new Vector3(0, 0, 1));

                    // Make sure we are not in free camera mode and can control the car
                    SpeedyRacerManager.Player.FreeCamera = false;
                },
                delegate
                {
                    // Test slow computers by slowing down the framerate with Ctrl
                    if (Input.Keyboard.IsKeyDown(Keys.LeftControl))
                        Thread.Sleep(75);

                    SpeedyRacerManager.Player.SetGroundPlaneAndGuardRails(
                        new Vector3(0, 0, 0), new Vector3(0, 0, 1),
                        // Use our guardrails, always the same in this test!
                        new Vector3(-10, 0, 0), new Vector3(-10, 10, 0),
                        new Vector3(+10, 0, 0), new Vector3(+10, 10, 0));
                    Matrix carMatrix = SpeedyRacerManager.Player.UpdateCarMatrixAndCamera();

                    // Generate shadows, just the car does shadows
                    ShaderEffect.shadowMapping.GenerateShadows(
                        delegate
                        {
                            SpeedyRacerManager.CarModel.GenerateShadow(carMatrix);
                        });
                    // Render shadows (on both the plane and the car)
                    ShaderEffect.shadowMapping.RenderShadows(
                        delegate
                        {
                            SpeedyRacerManager.CarModel.UseShadow(carMatrix);
                            plane.UseShadow();
                        });

                    BaseGame.UI.RenderGameBackground();
                    // Show car and ground plane
                    SpeedyRacerManager.CarModel.RenderCar(false, carMatrix);
                    plane.Render();

                    // Just add brake tracks (we don't render the landscape here)
                    SpeedyRacerManager.Landscape.RenderBrakeTracks();

              guardRailModel.Render(new Vector3(-11.5f, 2.5f, 0));

                    BaseGame.MeshRenderManager.Render();

                    // Add shadows
                    ShaderEffect.shadowMapping.ShowShadows();

                    SpeedyRacerManager.Player.DisplayPhysicsValuesAndHelp();
                });
        }
        /// <summary>
        /// Test windmill animation, we do a custom animation since XNA
        /// does not support animated files yet.
        /// </summary>
        public static void TestWindmillAnimation()
        {
            Model testModel = null;
            TestGame.Start("TestWindmillAnimation",
                delegate
                {
                    testModel = new Model("Windmill");
                },
                delegate
                {
                    BaseGame.UI.RenderGameBackground();

                    BaseGame.Device.RenderState.DepthBufferEnable = true;
                    testModel.Render(Matrix.Identity);
                    testModel.Render(new Vector3(40, 15, 0));

                    BaseGame.UI.PostScreenGlowShader.Show();
                });
        }
        /// <summary>
        /// Test create render to texture
        /// </summary>
        public static void TestCreateRenderToTexture()
        {
            Model testPlate = null;
            RenderToTexture renderToTexture = null;

            TestGame.Start(
                delegate
                {
                    testPlate = new Model("CarSelectionPlate");
                    renderToTexture = new RenderToTexture(
                        //SizeType.ShadowMap1024);
                        //.QuarterScreen);
                        SizeType.FullScreen);
                        //SizeType.HalfScreen);
                },
                delegate
                {
                    bool renderToTextureWay =
                        Input.Keyboard.IsKeyUp(Keys.Space) &&
                        Input.GamePadAPressed == false;
                    if (renderToTextureWay)
                    {
                        // Set render target to our texture
                        renderToTexture.SetRenderTarget();

                        // Clear background
                        renderToTexture.Clear(Color.Blue);

                        // Draw background lines
                        BaseGame.DrawLine(new Point(0, 200), new Point(200, 0), Color.Blue);
                        BaseGame.DrawLine(new Point(0, 0), new Point(400, 400), Color.Red);
                        BaseGame.FlushLineManager2D();

                        // And draw object
                        testPlate.Render(Matrix.CreateScale(1.5f));
                        // And flush render manager to draw all objects
                        BaseGame.MeshRenderManager.Render();

                        // Resolve
                        renderToTexture.Resolve();

                        // Reset background buffer
                        BaseGame.ResetRenderTarget(true);

                        // Show render target in a rectangle on our screen
                        renderToTexture.RenderOnScreen(
                            //tst:
                            new Rectangle(100, 100, 256, 256));
                            //BaseGame.ResolutionRect);
                    } // if (renderToTextureWay)
                    else
                    {
                        // Copy backbuffer way, render stuff normally first
                        // Clear background
                        BaseGame.Device.Clear(Color.Blue);

                        // Draw background lines
                        BaseGame.DrawLine(new Point(0, 200), new Point(200, 0), Color.Blue);
                        BaseGame.DrawLine(new Point(0, 0), new Point(400, 400), Color.Red);
                        BaseGame.FlushLineManager2D();

                        // And draw object
                        testPlate.Render(Matrix.CreateScale(1.5f));
                    } // else

                    TextureFont.WriteText(2, 30,
                        "renderToTexture.Width=" + renderToTexture.Width);
                    TextureFont.WriteText(2, 60,
                        "renderToTexture.Height=" + renderToTexture.Height);
                    TextureFont.WriteText(2, 90,
                        "renderToTexture.Valid=" + renderToTexture.Valid);
                    TextureFont.WriteText(2, 120,
                        "renderToTexture.XnaTexture=" + renderToTexture.XnaTexture);
                    TextureFont.WriteText(2, 150,
                        "renderToTexture.ZBufferSurface=" + renderToTexture.ZBufferSurface);
                    TextureFont.WriteText(2, 180,
                        "renderToTexture.Filename=" + renderToTexture.Filename);
                });
        }