Пример #1
0
    public TerrainSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      _graphicsScreen = new DeferredGraphicsScreen(Services);
      _graphicsScreen.DrawReticle = true;
      GraphicsService.Screens.Insert(0, _graphicsScreen);
      GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

      Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

      var scene = _graphicsScreen.Scene;
      Services.Register(typeof(IScene), null, scene);

      // Add gravity and damping to the physics simulation.
      Simulation.ForceEffects.Add(new Gravity());
      Simulation.ForceEffects.Add(new Damping());

      // Add a custom game object which controls the camera.
      var cameraGameObject = new CameraObject(Services, 5000);
      cameraGameObject.ResetPose(new Vector3F(0, 2, 5), 0, 0);
      GameObjectService.Objects.Add(cameraGameObject);
      _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

      // Add standard game objects.
      GameObjectService.Objects.Add(new GrabObject(Services));
      GameObjectService.Objects.Add(new ObjectCreatorObject(Services));
      GameObjectService.Objects.Add(new LavaBallsObject(Services));
      GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
      {
        EnableCloudShadows = false,
        FogSampleAngle = 0.1f,
        FogSaturation = 1,
      });

      var fogObject = new FogObject(Services) { AttachToCamera = true };
      GameObjectService.Objects.Add(fogObject);

      // Set nice fog values.
      // (Note: If we change the fog values here, the GUI in the Options window is not
      // automatically updated.)
      fogObject.FogNode.IsEnabled = true;
      fogObject.FogNode.Fog.Start = 100;
      fogObject.FogNode.Fog.End = 2500;
      fogObject.FogNode.Fog.Start = 100;
      fogObject.FogNode.Fog.HeightFalloff = 0.25f;

      // Add an ocean at height 0.
      GameObjectService.Objects.Add(new OceanObject(Services));

      // Add the terrain.
      var terrainObject = new TerrainObject(Services);
      GameObjectService.Objects.Add(terrainObject);

      SampleFramework.ShowOptionsWindow();
    }
Пример #2
0
        public TerrainHoleSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            _graphicsScreen             = new DeferredGraphicsScreen(Services);
            _graphicsScreen.DrawReticle = true;
            GraphicsService.Screens.Insert(0, _graphicsScreen);
            GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

            Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

            var scene = _graphicsScreen.Scene;

            Services.Register(typeof(IScene), null, scene);

            // Add standard game objects.
            var cameraGameObject = new CameraObject(Services, 5000);

            cameraGameObject.ResetPose(new Vector3(0, 2, 0), 0, 0);
            GameObjectService.Objects.Add(cameraGameObject);
            _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

            Simulation.ForceEffects.Add(new Gravity());
            Simulation.ForceEffects.Add(new Damping());
            GameObjectService.Objects.Add(new GrabObject(Services));
            GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
            {
                EnableCloudShadows = false,
            });
            GameObjectService.Objects.Add(new ObjectCreatorObject(Services));

            // Create terrain.
            _terrainObject = new TerrainObject(Services);
            GameObjectService.Objects.Add(_terrainObject);

            UpdateHoleTexture();

            CreateGuiControls();
        }
Пример #3
0
    public TerrainHoleSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      _graphicsScreen = new DeferredGraphicsScreen(Services);
      _graphicsScreen.DrawReticle = true;
      GraphicsService.Screens.Insert(0, _graphicsScreen);
      GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

      Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

      var scene = _graphicsScreen.Scene;
      Services.Register(typeof(IScene), null, scene);

      // Add standard game objects.
      var cameraGameObject = new CameraObject(Services, 5000);
      cameraGameObject.ResetPose(new Vector3F(0, 2, 0), 0, 0);
      GameObjectService.Objects.Add(cameraGameObject);
      _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

      Simulation.ForceEffects.Add(new Gravity());
      Simulation.ForceEffects.Add(new Damping());
      GameObjectService.Objects.Add(new GrabObject(Services));
      GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
      {
        EnableCloudShadows = false,
      });
      GameObjectService.Objects.Add(new ObjectCreatorObject(Services));

      // Create terrain.
      _terrainObject = new TerrainObject(Services);
      GameObjectService.Objects.Add(_terrainObject);

      UpdateHoleTexture();

      CreateGuiControls();
    }
Пример #4
0
    public TerrainDecalSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      _graphicsScreen = new DeferredGraphicsScreen(Services);
      _graphicsScreen.DrawReticle = true;
      GraphicsService.Screens.Insert(0, _graphicsScreen);
      GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

      Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

      var scene = _graphicsScreen.Scene;
      Services.Register(typeof(IScene), null, scene);

      // Add gravity and damping to the physics simulation.
      Simulation.ForceEffects.Add(new Gravity());
      Simulation.ForceEffects.Add(new Damping());

      // Add a custom game object which controls the camera.
      var cameraObject = new CameraObject(Services, 5000);
      cameraObject.ResetPose(new Vector3F(0, 2, 5), 0, 0);
      GameObjectService.Objects.Add(cameraObject);
      _graphicsScreen.ActiveCameraNode = cameraObject.CameraNode;

      // Add standard game objects.
      GameObjectService.Objects.Add(new GrabObject(Services));
      GameObjectService.Objects.Add(new ObjectCreatorObject(Services));
      GameObjectService.Objects.Add(new LavaBallsObject(Services));
      GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
      {
        EnableCloudShadows = false,
      });
      GameObjectService.Objects.Add(new FogObject(Services));

      // Create terrain.
      _terrainObject = new TerrainObject(Services);
      GameObjectService.Objects.Add(_terrainObject);

      // Add a blood decal to the terrain.
      var decal0 = new TerrainDecalLayer(GraphicsService)
      {
        Pose = GetRandomPose(),
        Width = 2,
        Height = 2,
        DiffuseColor = new Vector3F(0.08f),
        SpecularColor = new Vector3F(0.2f),
        SpecularPower = 100,
        DiffuseTexture = ContentManager.Load<Texture2D>("Decals/Decal_diffuse_mask"), // Original: "Decals/Blood_diffuse_mask",
        NormalTexture =  GraphicsService.GetDefaultNormalTexture(),   // Original: ContentManager.Load<Texture2D>("Decals/Blood_normal"),
        SpecularTexture = GraphicsService.GetDefaultTexture2DWhite(), // Original: ContentManager.Load<Texture2D>("Decals/Blood_specular"),
        FadeOutStart = 3,
        FadeOutEnd = 5,
        Alpha = 0.9f,
      };
      AddDecal(decal0);

      // Add a black blood decal (oil spill?)
      var decal1 = new TerrainDecalLayer(GraphicsService)
      {
        Pose = GetRandomPose(),
        Width = 2,
        Height = 2,
        DiffuseColor = new Vector3F(0.0f),
        SpecularColor = new Vector3F(0.5f),
        SpecularPower = 100,
        DiffuseTexture = ContentManager.Load<Texture2D>("Decals/Decal_diffuse_mask"), // Original: "Decals/Blood_diffuse_mask",
        NormalTexture = GraphicsService.GetDefaultNormalTexture(),   // Original: ContentManager.Load<Texture2D>("Decals/Blood_normal"),
        SpecularTexture = GraphicsService.GetDefaultTexture2DWhite(), // Original: ContentManager.Load<Texture2D>("Decals/Blood_specular"),
        FadeOutStart = 3,
        FadeOutEnd = 5,
      };
      AddDecal(decal1);

      // Add more random decals. The decals can share materials!
      var decal0Material = decal0.Material;
      for (int i = 0; i < 50; i++)
      {
        var decal = new TerrainDecalLayer(decal0Material)
        {
          Pose = GetRandomPose(),
          Width = 2,
          Height = 2,
        };
        AddDecal(decal);
      }
    }
Пример #5
0
        public ParallaxTerrainSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            _graphicsScreen             = new DeferredGraphicsScreen(Services);
            _graphicsScreen.DrawReticle = true;
            GraphicsService.Screens.Insert(0, _graphicsScreen);
            GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

            Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

            var scene = _graphicsScreen.Scene;

            Services.Register(typeof(IScene), null, scene);

            // Add standard game objects.
            var cameraGameObject = new CameraObject(Services, 5000);

            cameraGameObject.ResetPose(new Vector3(0, 2, 0), 0, 0);
            GameObjectService.Objects.Add(cameraGameObject);
            _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

            Simulation.ForceEffects.Add(new Gravity());
            Simulation.ForceEffects.Add(new Damping());
            GameObjectService.Objects.Add(new GrabObject(Services));
            GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
            {
                EnableCloudShadows = false,
            });
            GameObjectService.Objects.Add(new ObjectCreatorObject(Services));

            // Create terrain.
            _terrainObject = new TerrainObject(Services);
            GameObjectService.Objects.Add(_terrainObject);

            // To see parallax occlusion mapping, we need a detail texture with a height map.
            // In this sample we reuse the pavement texture of the ParallaxMappingSample and
            // add it to the terrain.
            for (int row = 0; row < 2; row++)
            {
                for (int column = 0; column < 2; column++)
                {
                    var    terrainTile = _terrainObject.TerrainNode.Terrain.Tiles[row * 2 + column];
                    string tilePostfix = "-" + row + "-" + column; // e.g. "-0-1"

                    var materialPavement = new TerrainMaterialLayer(GraphicsService)
                    {
                        DiffuseColor         = new Vector3(1),
                        SpecularColor        = new Vector3(5),
                        SpecularPower        = 20,
                        DiffuseTexture       = ContentManager.Load <Texture2D>("Parallax/AgedPavement_diffuse"),
                        NormalTexture        = ContentManager.Load <Texture2D>("Parallax/AgedPavement_normal"),
                        SpecularTexture      = ContentManager.Load <Texture2D>("Parallax/AgedPavement_specular"),
                        HeightTexture        = ContentManager.Load <Texture2D>("Parallax/AgedPavement_height"),
                        TileSize             = 0.005f * 512,
                        BlendTexture         = ContentManager.Load <Texture2D>("Terrain/Terrain001-Blend-Grass" + tilePostfix),
                        BlendTextureChannel  = 0,
                        BlendHeightInfluence = 0.5f,
                        BlendThreshold       = 0.5f,
                        BlendRange           = 0.5f,
                    };

                    terrainTile.Layers.Add(materialPavement);
                }
            }

            // Replace the terrain effects with effects which support parallax occlusion mapping.
            UpdateTerrainMaterial(true);

            CreateGuiControls();
        }
Пример #6
0
        public RoadSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            _graphicsScreen             = new DeferredGraphicsScreen(Services);
            _graphicsScreen.DrawReticle = true;
            GraphicsService.Screens.Insert(0, _graphicsScreen);
            GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

            Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

            var scene = _graphicsScreen.Scene;

            Services.Register(typeof(IScene), null, scene);

            // Add gravity and damping to the physics simulation.
            Simulation.ForceEffects.Add(new Gravity());
            Simulation.ForceEffects.Add(new Damping());

            // Add a custom game object which controls the camera.
            var cameraGameObject = new CameraObject(Services, 5000);

            cameraGameObject.ResetPose(new Vector3(0, 2, 5), 0, 0);
            GameObjectService.Objects.Add(cameraGameObject);

            // Add the vehicle object from the vehicle sample.
            var vehicleObject = new ConstraintVehicleObject(Services);

            GameObjectService.Objects.Add(vehicleObject);

            // Add the car-follow-camera from the vehicle sample.
            var vehicleCameraObject = new VehicleCameraObject(vehicleObject.Vehicle.Chassis, Services);

            GameObjectService.Objects.Add(vehicleCameraObject);

            // Now, we have two CameraNodes. The graphics screen uses the camera node of the CameraObject,
            // as usual.
            _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;
            // The CameraObject should not react to input.
            cameraGameObject.IsEnabled = false;
            // The CameraNode of the VehicleCameraObject controls the other CameraNode.
            vehicleCameraObject.CameraNode.SceneChanged += (s, e) =>
            {
                cameraGameObject.CameraNode.SetLastPose(false);
                cameraGameObject.CameraNode.PoseWorld = vehicleCameraObject.CameraNode.PoseWorld;
            };

            // Add standard game objects.
            GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
            {
                EnableCloudShadows = false,
                FogSampleAngle     = 0.1f,
                FogSaturation      = 1,
            });

            var fogObject = new FogObject(Services)
            {
                AttachToCamera = true
            };

            GameObjectService.Objects.Add(fogObject);

            // Set nice default fog values.
            // (Note: If we change the fog values here, the GUI in the options window is not
            // automatically updated.)
            fogObject.FogNode.IsEnabled         = true;
            fogObject.FogNode.Fog.Start         = 100;
            fogObject.FogNode.Fog.End           = 2500;
            fogObject.FogNode.Fog.Start         = 100;
            fogObject.FogNode.Fog.HeightFalloff = 0.25f;

            // Add the terrain
            _terrainObject = new TerrainObject(Services);
            GameObjectService.Objects.Add(_terrainObject);

            // Add the TerrainRoadLayer to the terrain.
            CreateRoad();

            // Modify the terrain height values.
            ClampTerrainToRoad();
        }
Пример #7
0
    public ParallaxTerrainSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      _graphicsScreen = new DeferredGraphicsScreen(Services);
      _graphicsScreen.DrawReticle = true;
      GraphicsService.Screens.Insert(0, _graphicsScreen);
      GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

      Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

      var scene = _graphicsScreen.Scene;
      Services.Register(typeof(IScene), null, scene);

      // Add standard game objects.
      var cameraGameObject = new CameraObject(Services, 5000);
      cameraGameObject.ResetPose(new Vector3F(0, 2, 0), 0, 0);
      GameObjectService.Objects.Add(cameraGameObject);
      _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

      Simulation.ForceEffects.Add(new Gravity());
      Simulation.ForceEffects.Add(new Damping());
      GameObjectService.Objects.Add(new GrabObject(Services));
      GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
      {
        EnableCloudShadows = false,
      });
      GameObjectService.Objects.Add(new ObjectCreatorObject(Services));

      // Create terrain.
      _terrainObject = new TerrainObject(Services);
      GameObjectService.Objects.Add(_terrainObject);

      // To see parallax occlusion mapping, we need a detail texture with a height map.
      // In this sample we reuse the pavement texture of the ParallaxMappingSample and 
      // add it to the terrain.
      for (int row = 0; row < 2; row++)
      {
        for (int column = 0; column < 2; column++)
        {
          var terrainTile = _terrainObject.TerrainNode.Terrain.Tiles[row * 2 + column];
          string tilePostfix = "-" + row + "-" + column; // e.g. "-0-1"

          var materialPavement = new TerrainMaterialLayer(GraphicsService)
          {
            DiffuseColor = new Vector3F(1),
            SpecularColor = new Vector3F(5),
            SpecularPower = 20,
            DiffuseTexture = ContentManager.Load<Texture2D>("Parallax/AgedPavement_diffuse"),
            NormalTexture = ContentManager.Load<Texture2D>("Parallax/AgedPavement_normal"),
            SpecularTexture = ContentManager.Load<Texture2D>("Parallax/AgedPavement_specular"),
            HeightTexture = ContentManager.Load<Texture2D>("Parallax/AgedPavement_height"),
            TileSize = 0.005f * 512,
            BlendTexture = ContentManager.Load<Texture2D>("Terrain/Terrain001-Blend-Grass" + tilePostfix),
            BlendTextureChannel = 0,
            BlendHeightInfluence = 0.5f,
            BlendThreshold = 0.5f,
            BlendRange = 0.5f,
          };

          terrainTile.Layers.Add(materialPavement);
        }
      }

      // Replace the terrain effects with effects which support parallax occlusion mapping.
      UpdateTerrainMaterial(true);

      CreateGuiControls();
    }
Пример #8
0
        public TerrainSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            _graphicsScreen             = new DeferredGraphicsScreen(Services);
            _graphicsScreen.DrawReticle = true;
            GraphicsService.Screens.Insert(0, _graphicsScreen);
            GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

            Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

            var scene = _graphicsScreen.Scene;

            Services.Register(typeof(IScene), null, scene);

            // Add gravity and damping to the physics simulation.
            Simulation.ForceEffects.Add(new Gravity());
            Simulation.ForceEffects.Add(new Damping());

            // Add a custom game object which controls the camera.
            var cameraGameObject = new CameraObject(Services, 5000);

            cameraGameObject.ResetPose(new Vector3F(0, 2, 5), 0, 0);
            GameObjectService.Objects.Add(cameraGameObject);
            _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

            // Add standard game objects.
            GameObjectService.Objects.Add(new GrabObject(Services));
            GameObjectService.Objects.Add(new ObjectCreatorObject(Services));
            GameObjectService.Objects.Add(new LavaBallsObject(Services));
            GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
            {
                EnableCloudShadows = false,
                FogSampleAngle     = 0.1f,
                FogSaturation      = 1,
            });

            var fogObject = new FogObject(Services)
            {
                AttachToCamera = true
            };

            GameObjectService.Objects.Add(fogObject);

            // Set nice fog values.
            // (Note: If we change the fog values here, the GUI in the Options window is not
            // automatically updated.)
            fogObject.FogNode.IsEnabled         = true;
            fogObject.FogNode.Fog.Start         = 100;
            fogObject.FogNode.Fog.End           = 2500;
            fogObject.FogNode.Fog.Start         = 100;
            fogObject.FogNode.Fog.HeightFalloff = 0.25f;

            // Add an ocean at height 0.
            GameObjectService.Objects.Add(new OceanObject(Services));

            // Add the terrain.
            var terrainObject = new TerrainObject(Services);

            GameObjectService.Objects.Add(terrainObject);

            SampleFramework.ShowOptionsWindow();
        }
Пример #9
0
        public TerrainDecalSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            _graphicsScreen             = new DeferredGraphicsScreen(Services);
            _graphicsScreen.DrawReticle = true;
            GraphicsService.Screens.Insert(0, _graphicsScreen);
            GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

            Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

            var scene = _graphicsScreen.Scene;

            Services.Register(typeof(IScene), null, scene);

            // Add gravity and damping to the physics simulation.
            Simulation.ForceEffects.Add(new Gravity());
            Simulation.ForceEffects.Add(new Damping());

            // Add a custom game object which controls the camera.
            var cameraObject = new CameraObject(Services, 5000);

            cameraObject.ResetPose(new Vector3F(0, 2, 5), 0, 0);
            GameObjectService.Objects.Add(cameraObject);
            _graphicsScreen.ActiveCameraNode = cameraObject.CameraNode;

            // Add standard game objects.
            GameObjectService.Objects.Add(new GrabObject(Services));
            GameObjectService.Objects.Add(new ObjectCreatorObject(Services));
            GameObjectService.Objects.Add(new LavaBallsObject(Services));
            GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
            {
                EnableCloudShadows = false,
            });
            GameObjectService.Objects.Add(new FogObject(Services));

            // Create terrain.
            _terrainObject = new TerrainObject(Services);
            GameObjectService.Objects.Add(_terrainObject);

            // Add a blood decal to the terrain.
            var decal0 = new TerrainDecalLayer(GraphicsService)
            {
                Pose            = GetRandomPose(),
                Width           = 2,
                Height          = 2,
                DiffuseColor    = new Vector3F(0.08f),
                SpecularColor   = new Vector3F(0.2f),
                SpecularPower   = 100,
                DiffuseTexture  = ContentManager.Load <Texture2D>("Decals/Decal_diffuse_mask"), // Original: "Decals/Blood_diffuse_mask",
                NormalTexture   = GraphicsService.GetDefaultNormalTexture(),                    // Original: ContentManager.Load<Texture2D>("Decals/Blood_normal"),
                SpecularTexture = GraphicsService.GetDefaultTexture2DWhite(),                   // Original: ContentManager.Load<Texture2D>("Decals/Blood_specular"),
                FadeOutStart    = 3,
                FadeOutEnd      = 5,
                Alpha           = 0.9f,
            };

            AddDecal(decal0);

            // Add a black blood decal (oil spill?)
            var decal1 = new TerrainDecalLayer(GraphicsService)
            {
                Pose            = GetRandomPose(),
                Width           = 2,
                Height          = 2,
                DiffuseColor    = new Vector3F(0.0f),
                SpecularColor   = new Vector3F(0.5f),
                SpecularPower   = 100,
                DiffuseTexture  = ContentManager.Load <Texture2D>("Decals/Decal_diffuse_mask"), // Original: "Decals/Blood_diffuse_mask",
                NormalTexture   = GraphicsService.GetDefaultNormalTexture(),                    // Original: ContentManager.Load<Texture2D>("Decals/Blood_normal"),
                SpecularTexture = GraphicsService.GetDefaultTexture2DWhite(),                   // Original: ContentManager.Load<Texture2D>("Decals/Blood_specular"),
                FadeOutStart    = 3,
                FadeOutEnd      = 5,
            };

            AddDecal(decal1);

            // Add more random decals. The decals can share materials!
            var decal0Material = decal0.Material;

            for (int i = 0; i < 50; i++)
            {
                var decal = new TerrainDecalLayer(decal0Material)
                {
                    Pose   = GetRandomPose(),
                    Width  = 2,
                    Height = 2,
                };
                AddDecal(decal);
            }
        }
Пример #10
0
    public RoadSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      _graphicsScreen = new DeferredGraphicsScreen(Services);
      _graphicsScreen.DrawReticle = true;
      GraphicsService.Screens.Insert(0, _graphicsScreen);
      GameObjectService.Objects.Add(new DeferredGraphicsOptionsObject(Services));

      Services.Register(typeof(DebugRenderer), null, _graphicsScreen.DebugRenderer);

      var scene = _graphicsScreen.Scene;
      Services.Register(typeof(IScene), null, scene);

      // Add gravity and damping to the physics simulation.
      Simulation.ForceEffects.Add(new Gravity());
      Simulation.ForceEffects.Add(new Damping());

      // Add a custom game object which controls the camera.
      var cameraGameObject = new CameraObject(Services, 5000);
      cameraGameObject.ResetPose(new Vector3F(0, 2, 5), 0, 0);
      GameObjectService.Objects.Add(cameraGameObject);

      // Add the vehicle object from the vehicle sample.
      var vehicleObject = new ConstraintVehicleObject(Services);
      GameObjectService.Objects.Add(vehicleObject);

      // Add the car-follow-camera from the vehicle sample.
      var vehicleCameraObject = new VehicleCameraObject(vehicleObject.Vehicle.Chassis, Services);
      GameObjectService.Objects.Add(vehicleCameraObject);

      // Now, we have two CameraNodes. The graphics screen uses the camera node of the CameraObject,
      // as usual.
      _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;
      // The CameraObject should not react to input.
      cameraGameObject.IsEnabled = false;
      // The CameraNode of the VehicleCameraObject controls the other CameraNode.
      vehicleCameraObject.CameraNode.SceneChanged += (s, e) =>
      {
        cameraGameObject.CameraNode.SetLastPose(false);
        cameraGameObject.CameraNode.PoseWorld = vehicleCameraObject.CameraNode.PoseWorld;
      };

      // Add standard game objects.
      GameObjectService.Objects.Add(new DynamicSkyObject(Services, true, false, true)
      {
        EnableCloudShadows = false,
        FogSampleAngle = 0.1f,
        FogSaturation = 1,
      });

      var fogObject = new FogObject(Services) { AttachToCamera = true };
      GameObjectService.Objects.Add(fogObject);

      // Set nice default fog values.
      // (Note: If we change the fog values here, the GUI in the options window is not
      // automatically updated.)
      fogObject.FogNode.IsEnabled = true;
      fogObject.FogNode.Fog.Start = 100;
      fogObject.FogNode.Fog.End = 2500;
      fogObject.FogNode.Fog.Start = 100;
      fogObject.FogNode.Fog.HeightFalloff = 0.25f;

      // Add the terrain
      _terrainObject = new TerrainObject(Services);
      GameObjectService.Objects.Add(_terrainObject);

      // Add the TerrainRoadLayer to the terrain.
      CreateRoad();

      // Modify the terrain height values.
      ClampTerrainToRoad();
    }