/// <inheritdoc /> public override void Draw(GameTime gameTime) { #region Pass 1 GraphicsDevice.DepthStencilState = DepthStencilState.Default; // Set the render target as our shadow map, we are drawing the depth into this texture GraphicsDevice.SetRenderTarget(SceneRenderTarget); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1f, 0); Model.Draw(Matrix.Identity, Camera.View, Camera.Projection); #endregion #region Pass 1 // No depth needed GraphicsDevice.DepthStencilState = DepthStencilState.None; // Set the render target to null, we are drawing to the screen GraphicsDevice.SetRenderTarget(null); Effect.Parameters["baseTexture"].SetValue(SceneRenderTarget); FullScreenQuad.Draw(Effect); #endregion AxisLines.Draw(Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { if (currentBlurType.Equals(BlurType.NONE)) { DrawRegular(); } else if (currentBlurType.Equals(BlurType.SIMPLE)) { DrawSimpleBlur(); } else { DrawSeparatedBlur(); } Game.SpriteBatch.Begin(); Game.SpriteBatch.DrawString(spriteFont, "Con las teclas 'J', 'K' y 'L' se cambia el modo de Blur", new Vector2(50, 50), Color.Black); Game.SpriteBatch.DrawString(spriteFont, "Modo de Blur: " + currentBlurType, new Vector2(50, 80), Color.Black); Game.SpriteBatch.End(); AxisLines.Draw(Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { // Set the background color to black, and use the default depth configuration Game.Background = Color.Black; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); // We get the base transform for each mesh var modelMeshesBaseTransforms = new Matrix[Model.Bones.Count]; Model.CopyAbsoluteBoneTransformsTo(modelMeshesBaseTransforms); foreach (var modelMesh in Model.Meshes) { // We set the main matrices for each mesh to draw var worldMatrix = modelMeshesBaseTransforms[modelMesh.ParentBone.Index]; // World is used to transform from model space to world space Effect.Parameters["World"].SetValue(worldMatrix); // InverseTransposeWorld is used to rotate normals Effect.Parameters["InverseTransposeWorld"].SetValue(Matrix.Transpose(Matrix.Invert(worldMatrix))); // WorldViewProjection is used to transform from model space to clip space Effect.Parameters["WorldViewProjection"].SetValue(worldMatrix * Camera.View * Camera.Projection); // Once we set these matrices we draw modelMesh.Draw(); } lightBox.Draw(LightBoxWorld, Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); time += Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); var mesh = Model.Meshes.FirstOrDefault(); if (mesh != null) { foreach (var part in mesh.MeshParts) { part.Effect = Effect; Effect.Parameters["World"].SetValue(mesh.ParentBone.Transform); Effect.Parameters["View"].SetValue(Camera.View); Effect.Parameters["Projection"].SetValue(Camera.Projection); //Effect.Parameters["WorldViewProjection"].SetValue(Camera.WorldMatrix * Camera.View * Camera.Projection); Effect.Parameters["ModelTexture"].SetValue(Texture); Effect.Parameters["Time"].SetValue(time); } mesh.Draw(); } base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); Box.Draw(Matrix.CreateRotationY(BoxRotation) * BoxWorld, Camera.View, Camera.Projection); Quad.Draw(QuadWorld, Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); Model1.Draw(Matrix.CreateScale(0.1f) * Matrix.CreateTranslation(Vector3.UnitX * -8), Camera.View, Camera.Projection); Model2.Draw(Matrix.CreateScale(2.8f) * Matrix.CreateTranslation(new Vector3(8, -5, 0)), Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); // Calculate the camera matrices. var time = Convert.ToSingle(gameTime.TotalGameTime.TotalSeconds); // Draw the tank model. TankModel.Draw(TankWorld * Matrix.CreateRotationY(time * 0.1f), Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.Black; var viewProjection = Camera.View * Camera.Projection; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.SetRenderTarget(DepthRenderTarget); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1f, 0); DrawSpheres(DrawDepthEffect, viewProjection); // Set the render target as null, we are drawing on the screen! GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1f, 0); DrawSpheres(Effect, viewProjection); RasterizerState rasterizerState = new RasterizerState(); rasterizerState.CullMode = CullMode.None; GraphicsDevice.RasterizerState = rasterizerState; if (ShowArrows) { Arrows.ForEach(arrow => arrow.Draw(Matrix.Identity, Camera.View, Camera.Projection)); } // Debug our shadowmap! // Show a simple quad with the texture DebugTextureEffect.Parameters["World"].SetValue(Matrix.CreateScale(0.2f) * Matrix.CreateTranslation(new Vector3(-0.75f, -0.75f, 0f))); DebugTextureEffect.Parameters["baseTexture"].SetValue(DepthRenderTarget); FullScreenQuad.Draw(DebugTextureEffect); Game.SpriteBatch.Begin(); Game.SpriteBatch.DrawString(SpriteFont, "Con la tecla 'J' se prende y apaga el modo Wireframe", new Vector2(50, 50), Color.Yellow); Game.SpriteBatch.DrawString(SpriteFont, "Con la tecla 'K' se prenden y apagan las flechas", new Vector2(50, 80), Color.LightYellow); Game.SpriteBatch.DrawString(SpriteFont, "Con la tecla 'L' se habilita y deshabilita el back-face culling", new Vector2(50, 110), Color.LightGreen); Game.SpriteBatch.End(); AxisLines.Draw(Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { if (EffectOn) { DrawEnvironmentMap(); } else { DrawRegular(); } GraphicsDevice.DepthStencilState = DepthStencilState.None; AxisLines.Draw(Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.Black; AxisLines.Draw(View, Projection); var originalRasterizerState = GraphicsDevice.RasterizerState; var rasterizerState = new RasterizerState(); rasterizerState.CullMode = CullMode.None; Game.Graphics.GraphicsDevice.RasterizerState = rasterizerState; //TODO why I have to set 1 in the alpha channel in the fx file? SkyBox.Draw(View, Projection, CameraPosition); GraphicsDevice.RasterizerState = originalRasterizerState; base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.Black; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); // Render the sun. DrawGeometry(Sun, SunTranslation); // Render the earth. DrawGeometry(Earth, EarthTranslation); // Render the moon. DrawGeometry(Moon, MoonTranslation); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); GraphicsDevice.SetVertexBuffer(Vertices); GraphicsDevice.Indices = Indices; Effect.World = BoxWorld; Effect.View = Camera.View; Effect.Projection = Camera.Projection; foreach (var pass in Effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, Indices.IndexCount / 3); } base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.Black; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.SetVertexBuffer(TerrainVertexBuffer); GraphicsDevice.Indices = TerrainIndexBuffer; // Render terrain. Effect.View = Camera.View; Effect.Projection = Camera.Projection; foreach (var pass in Effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, PrimitiveCount); } AxisLines.Draw(Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { if (EffectOn) { DrawBloom(); } else { DrawRegular(); } Game.SpriteBatch.Begin(); Game.SpriteBatch.DrawString(SpriteFont, "Con la tecla 'J' se prende y apaga el efecto", new Vector2(50, 50), Color.Black); Game.SpriteBatch.DrawString(SpriteFont, "Efecto " + (EffectOn ? "prendido" : "apagado"), new Vector2(50, 80), Color.Black); Game.SpriteBatch.End(); AxisLines.Draw(Camera.View, Camera.Projection); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); DrawGeometry(Box, BoxPosition, Yaw, Pitch, Roll); DrawGeometry(Cylinder, CylinderPosition, Yaw, Pitch, Roll); DrawGeometry(Sphere, SpherePosition, -Yaw, Pitch, Roll); DrawGeometry(Teapot, TeapotPosition, Yaw, -Pitch, Roll); DrawGeometry(Torus, TorusPosition, Yaw, Pitch, -Roll); var triangleEffect = Triangle.Effect; triangleEffect.World = Matrix.Identity; triangleEffect.View = Camera.View; triangleEffect.Projection = Camera.Projection; triangleEffect.LightingEnabled = false; Triangle.Draw(triangleEffect); base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; AxisLines.Draw(Effect.View, Effect.Projection); // Set our vertex buffer. GraphicsDevice.SetVertexBuffer(Vertices); foreach (var pass in Effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawPrimitives( // We’ll be rendering one triangles. PrimitiveType.TriangleList, // The offset, which is 0 since we want to start at the beginning of the floorVerts array. 0, // The number of triangles to draw. 1); } base.Draw(gameTime); }
/// <inheritdoc /> public override void Draw(GameTime gameTime) { Game.Background = Color.CornflowerBlue; Game.GraphicsDevice.DepthStencilState = DepthStencilState.Default; AxisLines.Draw(Camera.View, Camera.Projection); // dibujo el terreno terrain.Draw(Matrix.Identity, Camera.View, Camera.Projection); // computo 3 puntos sobre la superficie del heighmap var dir = new Vector2(MathF.Cos(angle), MathF.Sin(angle)); var tan = new Vector2(-MathF.Sin(angle), MathF.Cos(angle)); var pos_ade = pos + dir * 100; var pos_der = pos + tan * 100; var PosAdelante = new Vector3(pos_ade.X, terrain.Height(pos_ade.X, pos_ade.Y), pos_ade.Y); var PosDerecha = new Vector3(pos_der.X, terrain.Height(pos_der.X, pos_der.Y), pos_der.Y); var matWorld = CalcularMatrizOrientacion(10, shipPos, PosAdelante, PosDerecha); // dibujo el mesh foreach (var mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; effect.World = matWorld; effect.View = Camera.View; effect.Projection = Camera.Projection; } mesh.Draw(); } base.Draw(gameTime); }