public ConstraintVehicleSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a game object which loads the test obstacles. GameObjectService.Objects.Add(new VehicleLevelObject(Services)); // Add a game object which controls a vehicle. var vehicleObject = new ConstraintVehicleObject(Services); GameObjectService.Objects.Add(vehicleObject); // Add a camera that is attached to the chassis of the vehicle. var vehicleCameraObject = new VehicleCameraObject(vehicleObject.Vehicle.Chassis, Services); GameObjectService.Objects.Add(vehicleCameraObject); GraphicsScreen.CameraNode = vehicleCameraObject.CameraNode; }
public ConstraintVehicleSample(Microsoft.Xna.Framework.Game game) : base(game) { // Add basic force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a game object which loads the test obstacles. GameObjectService.Objects.Add(new VehicleLevelObject(Services)); // Add a game object which controls a vehicle. var vehicleObject = new ConstraintVehicleObject(Services); GameObjectService.Objects.Add(vehicleObject); // Add a camera that is attached to the chassis of the vehicle. var vehicleCameraObject = new VehicleCameraObject(vehicleObject.Vehicle.Chassis, Services); GameObjectService.Objects.Add(vehicleCameraObject); GraphicsScreen.CameraNode = vehicleCameraObject.CameraNode; }
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(); }