Ejemplo n.º 1
0
        private void Initialize()
        {
            graphicsDevice = ScreenManager.GraphicsDevice;
            content        = ScreenManager.Content;
            spriteBatch    = ScreenManager.SpriteBatch;
            font           = ScreenManager.Font;
            MeshManager.InitializeManager(graphicsDevice, content);

            screenWidth  = graphicsDevice.Viewport.Width;
            screenHeight = graphicsDevice.Viewport.Height;

            clearColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);

            // Create Render Targets
            mainRT = new RenderTarget2D(graphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color,
                                        DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents);
            reflectionRT = new RenderTarget2D(graphicsDevice, screenWidth / 2, screenHeight / 2, true, SurfaceFormat.Color,
                                              DepthFormat.Depth24Stencil8);
            occlusionRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color,
                                             DepthFormat.None);
            bloomRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color,
                                         DepthFormat.None);

            postEffects = new PostProcessingEffects(graphicsDevice,
                                                    content.Load <Effect>(@"Effects\PostProcessingEffects"));

            // Create renderers
            lightRenderer = new LightRenderer(graphicsDevice,
                                              content.Load <Effect>(@"Effects\Light"));
            terrainRenderer = new TerrainRenderer(graphicsDevice,
                                                  content.Load <Effect>(@"Effects\Terrain"));
            surfaceRenderer = new SurfaceRenderer(graphicsDevice,
                                                  content.Load <Effect>(@"Effects\Surface"));
            waterRenderer = new WaterRenderer(graphicsDevice,
                                              content.Load <Effect>(@"Effects\Water"));
            billboardRenderer = new BillboardRenderer(graphicsDevice,
                                                      content.Load <Effect>(@"Effects\Billboard"));
            meshRenderer = new MeshRenderer(graphicsDevice,
                                            content.Load <Effect>(@"Effects\Mesh"));

            // Create camera
            camera                 = new FirstPersonCamera();
            camera.AspectRatio     = graphicsDevice.Viewport.AspectRatio;
            camera.AABBSize        = new Vector2(1.0f, 8.0f);
            camera.DrawDistance    = 10000.0f;
            camera.MoveSpeed       = 25.0f;
            camera.FreeFlyEnabled  = false;
            camera.PitchMinDegrees = -75.0f;
            camera.PitchMaxDegrees = 60.0f;
            camera.Projection      = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                                                                         camera.AspectRatio, 0.1f, 10000.0f);

            secretSFX = content.Load <SoundEffect>(@"SoundEffects\shotgun_pump");

            // Load level data
            LoadLevel(@"Levels\" + levelFileName);
        }