public DistortionSample(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); Services.Register(typeof(IScene), null, _graphicsScreen.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); GameObjectService.Objects.Add(cameraGameObject); _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode; GameObjectService.Objects.Add(new GrabObject(Services)); GameObjectService.Objects.Add(new StaticSkyObject(Services)); // Skybox + some lights. //GameObjectService.Objects.Add(new GroundObject(Services)); // Add a ground plane with some detail to see the water refractions. Simulation.RigidBodies.Add(new RigidBody(new PlaneShape(new Vector3F(0, 1, 0), 0))); GameObjectService.Objects.Add(new StaticObject(Services, "Gravel/Gravel", 1, new Pose(new Vector3F(0, 0.001f, 0)))); GameObjectService.Objects.Add(new DudeObject(Services)); GameObjectService.Objects.Add(new DynamicObject(Services, 1)); GameObjectService.Objects.Add(new DynamicObject(Services, 2)); GameObjectService.Objects.Add(new DynamicObject(Services, 3)); GameObjectService.Objects.Add(new DynamicObject(Services, 5)); GameObjectService.Objects.Add(new DynamicObject(Services, 6)); GameObjectService.Objects.Add(new DynamicObject(Services, 7)); GameObjectService.Objects.Add(new ObjectCreatorObject(Services)); GameObjectService.Objects.Add(new FogObject(Services)); GameObjectService.Objects.Add(new CampfireObject(Services)); GameObjectService.Objects.Add(new LavaBallsObject(Services)); // Add a few palm trees. Random random = new Random(12345); for (int i = 0; i < 10; i++) { Vector3F position = new Vector3F(random.NextFloat(-3, -8), 0, random.NextFloat(0, -5)); Matrix33F orientation = Matrix33F.CreateRotationY(random.NextFloat(0, ConstantsF.TwoPi)); float scale = random.NextFloat(0.5f, 1.2f); GameObjectService.Objects.Add(new StaticObject(Services, "PalmTree/palm_tree", scale, new Pose(position, orientation))); } // Add DistortionFilter to post-processors. _distortionFilter = new DistortionFilter(GraphicsService, ContentManager); _graphicsScreen.PostProcessors.Add(_distortionFilter); // Add 3 particle systems. // The ParticleSystems are added to the IParticleSystemService. // The ParticleSystemNodes are added to the Scene of the DistortionFilter - not the usual Scene! _fireDistortionParticleSystemNode = new ParticleSystemNode(CreateFireDistortionParticleSystem()) { PoseLocal = new Pose(new Vector3F(0, 0f, -1), Matrix33F.CreateRotationX(ConstantsF.PiOver2)), }; ParticleSystemService.ParticleSystems.Add(_fireDistortionParticleSystemNode.ParticleSystem); _distortionFilter.Scene.Children.Add(_fireDistortionParticleSystemNode); _explosionDistortionParticleSystemNode = new ParticleSystemNode(CreateExplosionDistortionParticleSystem()) { PoseLocal = new Pose(new Vector3F(0, 0, -1)), }; ParticleSystemService.ParticleSystems.Add(_explosionDistortionParticleSystemNode.ParticleSystem); _distortionFilter.Scene.Children.Add(_explosionDistortionParticleSystemNode); _novaDistortionParticleSystemNode = new ParticleSystemNode(CreateNovaDistortionParticleSystem()) { PoseLocal = new Pose(new Vector3F(0, 0.5f, -1), Matrix33F.CreateRotationX(ConstantsF.PiOver2)), }; ParticleSystemService.ParticleSystems.Add(_novaDistortionParticleSystemNode.ParticleSystem); _distortionFilter.Scene.Children.Add(_novaDistortionParticleSystemNode); }