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


            effect = Content.Load <Effect>("TerrainShader");
            effect.Parameters["AmbientColor"].SetValue(new Vector3(0.1f, 0.1f, 0.1f));
            effect.Parameters["DiffuseColor"].SetValue(new Vector3(0.3f, 0.1f, 0.1f));
            effect.Parameters["SpecularColor"].SetValue(new Vector3(0, 0, 0.2f));
            effect.Parameters["Shininess"].SetValue(20f);


            effect.Parameters["World"].SetValue(terrain.Transform.World);
            effect.Parameters["View"].SetValue(camera.View);
            effect.Parameters["Projection"].SetValue(camera.Projection);
            effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
            effect.Parameters["LightPosition"].SetValue(camera.Transform.Position + Vector3.Up * 10);
            effect.Parameters["CameraPosition"].SetValue(camera.Transform.Position);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                terrain.Draw();
            }

            base.Draw(gameTime);
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
            effect.Parameters["World"].SetValue(terrain.Transform.World);
            effect.Parameters["View"].SetValue(cameras[0].View);
            effect.Parameters["Projection"].SetValue(cameras[0].Projection);
            effect.Parameters["LightPosition"].SetValue(cameras[0].Transform.Position + Vector3.Up * 10);
            effect.Parameters["CameraPosition"].SetValue(cameras[0].Transform.Position);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                terrain.Draw();
            }

            player.Draw();

            foreach (Agent agent in agents)
            {
                agent.Draw();
            }

            bomb.Draw();

            spriteBatch.Begin();
            spriteBatch.DrawString(font, "Aliens Caught: " + player.aliensCaught, new Vector2(0, 25), Color.Black);
            spriteBatch.DrawString(font, "Time Spent: " + player.timeSpent, Vector2.Zero, Color.Black);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 3
0
        public void DrawArroundChunk(Chunk chunk)
        {
            isDrawing.Value = true;

            for (int x = -1; x <= 1; x++)
            {
                for (int z = -1; z <= 1; z++)
                {
                    var baseAddress = chunk.Address;
                    var address     = new ChunkAddress(baseAddress.X + x, baseAddress.Z + z);
                    terrainRenderer.Draw(address);
                }
            }
            isDrawing.Value = false;
        }
Exemplo n.º 4
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            GraphicsDevice.DepthStencilState = new DepthStencilState();

            effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
            effect.Parameters["World"].SetValue(terrain.Transform.World);
            effect.Parameters["View"].SetValue(camera.View);
            effect.Parameters["Projection"].SetValue(camera.Projection);
            effect.Parameters["LightPosition"].SetValue(camera.Transform.Position + Vector3.Up * 10);
            effect.Parameters["CameraPosition"].SetValue(camera.Transform.Position);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                terrain.Draw();
            }
            base.Draw(gameTime);
        }
Exemplo n.º 5
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            GraphicsDevice.DepthStencilState = new DepthStencilState();

            effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
            effect.Parameters["World"].SetValue(terrain.Transform.World);
            effect.Parameters["View"].SetValue(camera.View);
            effect.Parameters["Projection"].SetValue(camera.Projection);
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                terrain.Draw();
            }

            //spriteBatch.Begin();
            // Any 2D stuff goes here!
            //spriteBatch.End();
            base.Draw(gameTime);
        }
Exemplo n.º 6
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            GraphicsDevice.DepthStencilState = new DepthStencilState();


            foreach (Camera camera in cameras)
            {
                GraphicsDevice.Viewport = camera.Viewport;


                effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
                effect.Parameters["World"].SetValue(terrain.Transform.World);
                effect.Parameters["View"].SetValue(camera.View);
                effect.Parameters["Projection"].SetValue(camera.Projection);
                effect.Parameters["CameraPosition"].SetValue(camera.Transform.Position);
                effect.Parameters["LightPosition"].SetValue(light.Transform.Position);
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    terrain.Draw();
                }


                player.Get <Renderer>().Camera = camera;
                agent.Get <Renderer>().Camera  = camera;
                agent1.Get <Renderer>().Camera = camera;
                agent2.Get <Renderer>().Camera = camera;
                box.Get <Renderer>().Camera    = camera;
                player.Draw();
                agent.Draw();
                agent1.Draw();
                agent2.Draw();
                box.Draw();
            }
            spriteBatch.Begin();
            spriteBatch.DrawString(font, "# of Hits: " + hits, new Vector2(100, 50), Color.Red);
            spriteBatch.DrawString(font, "Time: " + Time.TotalGameTime, new Vector2(100, 70), Color.Red);
            spriteBatch.End();
            base.Draw(gameTime);
        }
Exemplo n.º 7
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            GraphicsDevice.DepthStencilState = new DepthStencilState();
            GraphicsDevice.Clear(background);

            if (currentScene == scenes["Play"])
            {
                foreach (Camera camera in cameras)
                {
                    effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
                    effect.Parameters["World"].SetValue(terrain.Transform.World);
                    effect.Parameters["View"].SetValue(camera.View);
                    effect.Parameters["Projection"].SetValue(camera.Projection);
                    effect.Parameters["CameraPosition"].SetValue(camera.Transform.Position);
                    effect.Parameters["LightPosition"].SetValue(light.Transform.Position);
                    foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Apply();
                        terrain.Draw();
                    }

                    pacman.Draw();
                    Inky.Draw();
                    Blinky.Draw();
                    Pinky.Draw();
                    Clyde.Draw();
                    powerUp.Draw();
                }
                spriteBatch.Begin();
                spriteBatch.DrawString(font, "# of Hits: " + hits, new Vector2(100, 50), Color.White);
                spriteBatch.DrawString(font, "Time left: " + Time.TotalGameTime, new Vector2(100, 70), Color.White);
                spriteBatch.DrawString(font, "WASD to move", new Vector2(100, 90), Color.White);
                spriteBatch.End();
            }
            currentScene.Draw();

            base.Draw(gameTime);
        }
Exemplo n.º 8
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
            effect.Parameters["World"].SetValue(terrain.Transform.World);
            effect.Parameters["View"].SetValue(camera.View);
            effect.Parameters["Projection"].SetValue(camera.Projection);
            effect.Parameters["CameraPosition"].SetValue(camera.Position);
            effect.Parameters["LightPosition"].SetValue(light.Transform.Position);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                terrain.Draw();
            }

            player.Draw();

            agent1.Draw();
            agent2.Draw();
            agent3.Draw();

            /*
             * t1.Draw();
             * t2.Draw();
             * t3.Draw();
             * t4.Draw();
             * t5.Draw();
             */

            spriteBatch.Begin();
            spriteBatch.DrawString(font, "Hits: " + (hits - 1), new Vector2(50, 50), Color.Red);
            spriteBatch.DrawString(font, "Time: " + Time.TotalGameTime, new Vector2(50, 100), Color.Red);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 9
0
        private void DrawMain(BoundingFrustum viewFrustum)
        {
            graphicsDevice.SetRenderTarget(mainRT);
            graphicsDevice.Clear(clearColor);

            if (level.Type == LevelType.Outdoor)
            {
                terrainRenderer.Draw(level.Terrain);
                terrainRenderer.Draw(level.TerrainPlane);
            }
            else
            {
                surfaceRenderer.DrawSurface(level.Surface);
            }

            foreach (Mesh mesh in level.MeshList)
            {
                if (viewFrustum.Intersects(mesh.AABB))
                {
                    meshRenderer.DrawMesh(mesh, viewFrustum);
                }
            }

            foreach (ShootingTarget target in level.ShootingTargetList)
            {
                target.Draw(meshRenderer, viewFrustum);
            }

            foreach (Billboard billboard in level.BillboardList)
            {
                billboardRenderer.DrawLighting(billboard, camera.Up, camera.Look);
            }

            level.Sky.DrawClouds();

            if (level.WaterHeight != Level.WATER_DISABLED_HEIGHT)
            {
                waterRenderer.Draw(level.Water, reflectionRT, mainRT);
            }

            // Draw post processing
            if (postProcessingEffectsEnabled)
            {
                graphicsDevice.RasterizerState = RasterizerState.CullNone;

                graphicsDevice.SetRenderTarget(occlusionRT);
                graphicsDevice.Clear(Color.Black);

                // Draw light into occlusion map
                lightRenderer.Draw(level.Light, camera.Up, camera.Look);

                // Copy Occlusion data from the Alpha channel of main render target
                postEffects.DrawCopyOcclusion(mainRT);

                graphicsDevice.SetRenderTarget(bloomRT);
                graphicsDevice.Clear(Color.Black);

                // Draw lightscattering into bloom map
                postEffects.DrawLightScattering(occlusionRT);

                // Apply bloom lighting to output the final image
                graphicsDevice.SetRenderTarget(null);
                postEffects.ApplyBloom(mainRT, bloomRT);
            }
        }