Ejemplo n.º 1
0
        /// <summary>
        /// Test simple diffuse shader
        /// </summary>
        public static void TestSimpleDiffuseShader()
        {
            PlaneRenderer testPlane = null;

            TestGame.Start("TestSimpleDiffuseShader",
                delegate
                {
                    testPlane = new PlaneRenderer(
                        Vector3.Zero, new Plane(new Vector3(0, 0, 1), 0),
                        new Material("CityGround", "CityGroundNormal"), 25.0f);
                },
                delegate
                {
                    testPlane.Render(ShaderEffect.simple, "Diffuse20");
                });
        }
Ejemplo n.º 2
0
        /// <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!
                    RacingGameManager.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
                    RacingGameManager.Player.FreeCamera = false;
                },
                delegate
                {
                    // Test slow computers by slowing down the framerate with Ctrl
                    if (Input.Keyboard.IsKeyDown(Keys.LeftControl))
                        Thread.Sleep(75);

                    RacingGameManager.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 = RacingGameManager.Player.UpdateCarMatrixAndCamera();

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

                    BaseGame.UI.RenderGameBackground();
                    // Show car and ground plane
                    RacingGameManager.CarModel.RenderCar(
                        0, Color.White, false, carMatrix);
                    plane.Render();

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

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

              /*
                    for (int num = -100; num < 100; num++)
                    {
                        // Add 1.5m for the size of our dummy guard rail object.
                        guardRailModel.Render(new Vector3(-11.5f, num * 2.5f, 0));
                        guardRailModel.Render(new Vector3(+11.5f, num * 2.5f, 0));
                    } // for (num)
                    BaseGame.DrawLine(
                        new Vector3(-10, -1000, 0.1f),
                        new Vector3(-10, +1000, 0.1f));
                    BaseGame.DrawLine(
                        new Vector3(+10, -1000, 0.1f),
                        new Vector3(+10, +1000, 0.1f));
               */
                    BaseGame.MeshRenderManager.Render();

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

                    RacingGameManager.Player.DisplayPhysicsValuesAndHelp();
                });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Test car physics on a plane (xy) for testing the car controlling.
        /// </summary>
        public static void TestCarPhysicsOnPlane()
        {
            PlaneRenderer plane = null;

            TestGame.Start("TestCarPhysicsOnPlane",
                delegate
                {
                    plane = new PlaneRenderer(Vector3.Zero,
                        new Plane(new Vector3(0, 0, 1), 0),
                        new Material("CityGround", "CityGroundNormal"), 500.0f);

                    // Put car on the ground and use standard direction and up vectors
                    RacingGameManager.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
                    RacingGameManager.Player.FreeCamera = false;
                    RacingGameManager.Player.ZoomInTime = 0;
                    RacingGameManager.Player.SetCameraPosition(new Vector3(0, -5, 8));
                },
                delegate
                {
                    // Test slow computers by slowing down the framerate with Ctrl
                    if (Input.Keyboard.IsKeyDown(Keys.LeftControl))
                        Thread.Sleep(75);

                    RacingGameManager.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 = RacingGameManager.Player.UpdateCarMatrixAndCamera();

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

                    BaseGame.UI.RenderGameBackground();
                    // Show car and ground plane
                    RacingGameManager.CarModel.RenderCar(
                        1, Color.White, false, carMatrix);
                    plane.Render();

                    // Just add brake tracks (we don't render the landscape here)
                    RacingGameManager.Landscape.RenderBrakeTracks();
                    BaseGame.MeshRenderManager.Render();

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

                    RacingGameManager.Player.DisplayPhysicsValuesAndHelp();
                });
        }