Exemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            if (graphics.GraphicsDevice.RenderState.AlphaBlendEnable)
            {
                graphics.GraphicsDevice.RenderState.AlphaBlendEnable = false;
            }
            if (!graphics.GraphicsDevice.RenderState.DepthBufferEnable)
            {
                graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;
            }
            if (!graphics.GraphicsDevice.RenderState.DepthBufferWriteEnable)
            {
                graphics.GraphicsDevice.RenderState.DepthBufferWriteEnable = true;
            }

            //Water Reflection/Refraction
            if (IsActive)
            {
                if (heightmap != null && water != null && bDrawWater)
                {
                    DrawRefractionMap();
                }
                if (water != null && bDrawWater && skybox != null)
                {
                    DrawReflectionMap();
                }
            }

            if (bDrawPostEffect)
            {
                PreRender();
            }

            if (grid != null && bDrawGrid)
            {
                grid.Draw(camera.view, camera.projection);
            }

            if (skybox != null && bDrawSkybox)
            {
                skybox.Draw(camera.view, camera.projection);
            }

            if (heightmap != null && heightmap.bUpdateAndDraw)
            {
                heightmap.Draw(camera.view, camera.projection);
            }


            if (water != null && bDrawWater)
            {
                water.Draw(camera.view, camera.projection, camera.reflectionView, reflectionMap, refractionMap);
            }

            base.Draw(gameTime);

            if (bDrawSun && sun != null && camera != null)
            {
                sun.Draw(camera.view, camera.projection);
            }

            if (bDrawPostEffect)
            {
                PostRender();
            }

            if (hud != null)
            {
                hud.Draw();
            }

            if (consoleHUD != null && (consoleHUD.state == ConsoleHUD.State.Opening || consoleHUD.state == ConsoleHUD.State.Opened || consoleHUD.state == ConsoleHUD.State.Closing))
            {
                consoleHUD.Draw();
            }
        }