public static void TestTrackScreenshot()
        {
            Track track = null;
            Model testModel = null;

            TestGame.Start(
                delegate
                {
                    track = new Track("TrackSimple", null);
                    testModel = new Model("SpeedyRacer");
                },
                delegate
                {
                    SpeedyRacerManager.Player.SetCarPosition(
                        track.points[(int)(track.points.Count*0.93f)].pos +
                        new Vector3(0, -50, 0),
                        new Vector3(0, 1, 0), new Vector3(0, 0, 1));
                    track.roadMaterial.ambientColor = Color.Gray;

                    track.Render();

                    /*
                    testModel.RenderCar(0, Color.White,
                        Matrix.CreateRotationX(Input.MousePos.X/400.0f) *
                        Matrix.CreateTranslation(
                        track.points[(int)(track.points.Count * 0.95f)].pos));
                     */
                });
        }
        /// <summary>
        /// Load car stuff
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Load car model
            carModel = new Model("SpeedyRacer");

            // Load landscape
            landscape = new Landscape();

            // Load extra textures
            brakeTrackMaterial = new Material("track");
        }
 /// <summary>
 /// Test camera
 /// </summary>
 public static void TestCamera()
 {
     Model carModel = null;
     TestGame.Start("TestCamera",
         delegate // Init
         {
             carModel = new Model("SpeedyRacer");
         },
         delegate // Render loop
         {
             // Just show background ... free camera is handled automatically.
             SpeedyRacerManager.UI.RenderGameBackground();
             carModel.RenderCar(false, Matrix.Identity);
         });
 }
        /// <summary>
        /// Test render track
        /// </summary>
        //[Test]
        public static void TestRenderTrack()
        {
            Track track = null;
            Model testModel = null;

            TestGame.Start(
                delegate
                {
                    track = new Track("TrackSimple", null);
                    testModel = new Model("AlphaPalm2");
                },
                delegate
                {
                    //SpeedyRacerManager.Player.SetCarPosition(track.points[0].pos,
                    //	new Vector3(0, 1, 0), new Vector3(0, 0, 1));

                    //ShowGroundGrid();
                    //ShowTrackLines(track);

                    ShowUpVectors(track);
                    track.Render();

                    //testModel.Render(track.StartPosition);
                });
        }
        /// <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>
 /// Change model
 /// </summary>
 /// <param name="setNewModel">Set new model</param>
 public void ChangeModel(Model setNewModel)
 {
     model = setNewModel;
 }
            /// <summary>
            /// Create landscape object
            /// </summary>
            /// <param name="setModel">Set model</param>
            /// <param name="setMatrix">Set matrix</param>
            public LandscapeObject(Model setModel, Matrix setMatrix)
            {
                if (setModel == null)
                    throw new ArgumentNullException("setModel");

                model = setModel;
                matrix = setMatrix;
                isBanner = StringHelper.Contains(model.Name,
                    // Also include signs no reason to receive shadows for them!
                    // Faster and looks better!
                    new string[] { "banner", "sign" });
            }
        /// <summary>
        /// Test shadow mapping
        /// </summary>
        public static void TestShadowMapping()
        {
            Model testPile = null;
            int carNumber = 0;

            TestGame.Start("TestShadowMapping",
                delegate
                {
                    testPile = new Model("GuardRailHolder");
                },
                delegate
                {
                    BaseGame.UI.PostScreenGlowShader.Start();

                    if (Input.Keyboard.IsKeyUp(Keys.LeftAlt) &&
                        Input.GamePadXPressed == false)
                    {
                        // Generate shadows
                        ShaderEffect.shadowMapping.GenerateShadows(
                            delegate
                            {
                                SpeedyRacerManager.CarModel.GenerateShadow(Matrix.CreateRotationZ(0.85f));
                            });

                        // Render shadows
                        ShaderEffect.shadowMapping.RenderShadows(
                            delegate
                            {
                                SpeedyRacerManager.CarModel.UseShadow(Matrix.CreateRotationZ(0.85f));
                            });
                    } // if

                    SpeedyRacerManager.ClearBackground();
                    BaseGame.UI.RenderGameBackground();

                    SpeedyRacerManager.CarModel.RenderCar(
                        false, Matrix.CreateRotationZ(0.85f));

                    // And flush render manager to draw all objects
                    BaseGame.MeshRenderManager.Render();

                    if (Input.Keyboard.IsKeyUp(Keys.LeftAlt) &&
                        Input.GamePadXPressed == false)
                    {
                        ShaderEffect.shadowMapping.ShowShadows();
                    } // if

                    if (Input.KeyboardSpaceJustPressed ||
                        Input.GamePadBJustPressed)
                        carNumber = (carNumber + 1) % 3;

                    if (Input.Keyboard.IsKeyDown(Keys.LeftShift) ||
                        Input.GamePadAPressed)
                    {
                        //if (Input.KeyboardRightPressed)// == false)
                        ShaderEffect.shadowMapping.shadowMapTexture.RenderOnScreen(
                            new Rectangle(10, 10, 256, 256));
                        //if (Input.KeyboardLeftPressed)// == false)
                        ShaderEffect.shadowMapping.shadowMapBlur.SceneMapTexture.
                            RenderOnScreen(
                            new Rectangle(10 + 256 + 10, 10, 256, 256));
                        if (ShaderEffect.shadowMapping.shadowMapBlur.BlurMapTexture.Valid)
                            ShaderEffect.shadowMapping.shadowMapBlur.BlurMapTexture.
                                RenderOnScreen(
                                new Rectangle(10 + 256 + 10+256+10, 10, 256, 256));
                    } // if (Input.Keyboard.IsKeyDown)

                    //tst:
                    BaseGame.UI.PostScreenGlowShader.Show();

                    int xPos = 2, yPos = 30;
            #if XBOX360
                    xPos += BaseGame.XToRes(26);
                    yPos += BaseGame.YToRes(22);
            #endif
                    TextureFont.WriteText(xPos, yPos,
                        "Press left Shift or A to show all shadow pass textures.");
                    TextureFont.WriteText(xPos, yPos+30,
                        "Press Space or B to toggles the car model.");
                    TextureFont.WriteText(xPos, yPos+60,
                        "Press Alt or X to skip shadow map rendering.");
                });
        }
        /// <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);
                });
        }