public void Shutdown() { // Release the position object. Position = null; // Release the FPS object. FPS = null; // Release the camera object. Camera = null; // Release the foliage object. Foliage?.ShutDown(); Foliage = null; // Release the ground model object. GroundModel?.Shutdown(); GroundModel = null; // Release the user interface object. UserInterface?.ShutDown(); UserInterface = null; // Release the shader manager object. ShaderManager?.ShutDown(); ShaderManager = null; // Release the input object. Input?.Shutdown(); Input = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
private bool Render() { // Clear the buffer to begin the scene. D3D.BeginScene(0f, 0f, 0f, 1f); // Generate the view matrix based on the camera position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. Matrix viewMatrix = Camera.ViewMatrix; Matrix worldMatrix = D3D.WorldMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Turn on alpha blending. D3D.TurnOnAlphaBlending(); // Put the particle system vertex and index buffers on the graphics pipeline to prepare them for drawing. ParticleSystem.Render(D3D.DeviceContext); // Render the model using the texture shader. if (!ParticleShader.Render(D3D.DeviceContext, ParticleSystem.IndexCount, worldMatrix, viewMatrix, projectionMatrix, ParticleSystem.Texture.TextureResource)) { return(false); } // Turn off alpha blending. D3D.TurnOffAlphaBlending(); // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public bool Render() { // Clear the buffer to begin the scene. D3D.BeginScene(0f, 0f, 0f, 1f); // Generate the view matrix based on the camera position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. var viewMatrix = Camera.ViewMatrix; var worldMatrix = D3D.WorldMatrix; var projectionMatrix = D3D.ProjectionMatrix; // Rotate the world matrix by the rotation value so that the triangle will spin. Rotate(); // Construct the frustum. // Rotate the world matrix by the rotation value so that the triangle will spin. Matrix.RotationY(Rotation, out worldMatrix); // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. BumpMapModel.Render(D3D.DeviceContext); // Render the model using the color shader. if (!BumpMapShader.Render(D3D.DeviceContext, BumpMapModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, BumpMapModel.TextureCollection.Select(item => item.TextureResource).ToArray(), Light.Direction, Light.DiffuseColour)) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public bool Render() { // Clear the buffer to begin the scene. D3D.BeginScene(0f, 0f, 0f, 1f); // Generate the view matrix based on the camera position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. var viewMatrix = Camera.ViewMatrix; var worldMatrix = D3D.WorldMatrix; var projectionMatrix = D3D.ProjectionMatrix; // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. Model.Render(D3D.DeviceContext); // Render the model using the multitexture shader. if (!MultiTextureLightShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.TextureCollection.Select(item => item.TextureResource).ToArray())) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
private bool RenderSceneToTexture() { // Set the render target to be the render to texture. RenderTexture.SetRenderTarget(D3D.DeviceContext); // Clear the render to texture. RenderTexture.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f); // Get the world matrix from the d3d object. Matrix worldMatrix = D3D.WorldMatrix; // Generate the light view matrix based on the light's position. Light.GenerateViewMatrix(); // Get the view and orthographic matrices from the light object. Matrix lightViewMatrix = Light.ViewMatrix; Matrix lightOrthoMatrix = Light.OrthoMatrix; // Translate to the position of the tree. Vector3 treePosition = TreeModel.GetPosition(); Matrix.Translation(treePosition.X, treePosition.Y, treePosition.Z, out worldMatrix); // Render the tree trunk with the depth shader. TreeModel.RenderTrunk(D3D.DeviceContext); if (!DepthShader.Render(D3D.DeviceContext, TreeModel.TrunkIndexCount, worldMatrix, lightViewMatrix, lightOrthoMatrix)) { return(false); } // Render the tree leaves using the depth transparency shader. TreeModel.RenderLeaves(D3D.DeviceContext); if (!TransparentDepthShader.Render(D3D.DeviceContext, TreeModel.LeafIndexCount, worldMatrix, lightViewMatrix, lightOrthoMatrix, TreeModel.LeafTexture.TextureResource)) { return(false); } // Reset the world matrix. worldMatrix = D3D.WorldMatrix; // Translate to the position of the ground model. Vector3 groundPosition = GroundModel.GetPosition(); Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix); // Render the ground model with the depth shader. GroundModel.Render(D3D.DeviceContext); if (!DepthShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, lightViewMatrix, lightOrthoMatrix)) { return(false); } // Reset the render target back to the original back buffer and not the render to texture anymore. D3D.SetBackBufferRenderTarget(); // Reset the viewport back to the original. D3D.ResetViewPort(); return(true); }
private bool Render2DTextureScene() { // Clear the buffers to begin the scene. D3D.BeginScene(1.0f, 0.0f, 0.0f, 0.0f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, and ortho matrices from the camera and d3d objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix viewMatrix = Camera.ViewMatrix; Matrix orthoMatrix = D3D.OrthoMatrix; // Turn off the Z buffer to begin all 2D rendering. D3D.TurnZBufferOff(); // Put the full screen ortho window vertex and index buffers on the graphics pipeline to prepare them for drawing. FullScreenWindow.Render(D3D.DeviceContext); // Render the full screen ortho window using the texture shader and the full screen sized blurred render to texture resource. if (!TextureShader.Render(D3D.DeviceContext, FullScreenWindow.IndexCount, worldMatrix, viewMatrix, orthoMatrix, UpSampleTexure.ShaderResourceView)) { return(false); } // Turn the Z buffer back on now that all 2D rendering has completed. D3D.TurnZBufferOn(); // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
private bool RenderFadingScene() { // Turn off the Z buffer to begin all 2D rendering. D3D.TurnZBufferOff(); // Get the world, view, and orthotic matrices from camera and d3d objects. var viewMatrix = Camera.ViewMatrix; var worldMatrix = D3D.WorldMatrix; var orthoMatrix = D3D.OrthoMatrix; // Put the bitmap vertex and index buffers on the graphics pipeline to prepare them for drawing. if (!Bitmap.Render(D3D.DeviceContext, 0, 0)) { return(false); } // Render the bitmap using the fade shader. if (!FadeShader.Render(D3D.DeviceContext, Bitmap.IndexCount, worldMatrix, viewMatrix, orthoMatrix, RenderTexture.ShaderResourceView, FadePercentage)) { return(false); } // Turn the Z buffer back on now that all 2D rendering has completed. D3D.TurnZBufferOn(); return(true); }
public void Shutdown() { // Release the light object. Light = null; // Release the camera object. Camera = null; // Release the texture shader object. TextureShader?.ShutDown(); TextureShader = null; // Release the debug window object. DebugWindow?.Shutdown(); DebugWindow = null; // Release the render to texture object. RenderTexture?.Shutdown(); RenderTexture = null; // Release the light shader object. LightShader?.ShutDown(); LightShader = null; // Release the model object. Model?.Shutdown(); Model = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
private bool Render(float rotation) { // Clear the buffer to begin the scene. D3D.BeginScene(0f, 0f, 0f, 1f); // Generate the view matrix based on the camera position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. var viewMatrix = Camera.ViewMatrix; var worldMatrix = D3D.WorldMatrix; var projectionMatrix = D3D.ProjectionMatrix; var orthoMatrix = D3D.OrthoMatrix; // Turn off the Z buffer to begin all 2D rendering. D3D.TurnZBufferOff(); // Put the bitmap vertex and index buffers on the graphics pipeline to prepare them for drawing. if (!Bitmap.Render(D3D.DeviceContext, 100, 100)) { return(false); } // Render the bitmap with the texture shader. if (!TextureShader.Render(D3D.DeviceContext, Bitmap.IndexCount, worldMatrix, viewMatrix, orthoMatrix, Bitmap.Texture.TextureResource)) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public bool Render() { Rotate(); // Clear the buffer to begin the scene as Black. D3D.BeginScene(0, 0, 0, 1f); if (FadeDone) { // If fading in is complete the render the scene as normal to the back buffer. if (!RenderScene()) { return(false); } } else { // If fading is not complete then render the scene to a texture and fade that texture in. if (!RenderToTexture() || !RenderFadingScene()) { return(false); } } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public void Shutdown() { // Release the model object. if (Bitmap != null) { Bitmap.Shutdown(); Bitmap = null; } // Release the color shader object. if (TextureShader != null) { TextureShader.Shuddown(); TextureShader = null; } // Release the camera object. if (Camera != null) { Camera = null; } // Release the Direct3D object. if (D3D != null) { D3D.Shutdown(); D3D = null; } }
private bool RenderSceneToTexture() { // Set the render target to be the render to texture. RenderTexture.SetRenderTarget(D3D.DeviceContext); // Clear the render to texture. RenderTexture.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, projection, ortho, and base view matrices from the camera and Direct3D objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix viewMatrix = Camera.ViewMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Render the terrain using the depth shader. TerrainModel.Render(D3D.DeviceContext); if (!DepthShader.Render(D3D.DeviceContext, TerrainModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix)) { return(false); } // Reset the render target back to the original back buffer and not the render to texture anymore. D3D.SetBackBufferRenderTarget(); // Reset the viewport back to the original. D3D.ResetViewPort(); return(true); }
public bool Render() { // Clear the buffers to begin the scene. D3D.BeginScene(0, 0, 0, 1f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, and projection matrices from the camera and d3d objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix viewMatrix = Camera.ViewMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. FloorModel.Render(D3D.DeviceContext); // Render the model using the depth shader. if (!DepthShader.Render(D3D.DeviceContext, FloorModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix)) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
private bool Render() { // Clear the scene. D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, projection, ortho, and base view matrices from the camera and Direct3D objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix viewCameraMatrix = Camera.ViewMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; Matrix orthoMatrix = D3D.OrthoMatrix; // Render the terrain using the terrain shader. TerrainModel.Render(D3D.DeviceContext); if (!TerrainShader.Render(D3D.DeviceContext, TerrainModel.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, Light.Direction, ColourTexture1.TextureResource, ColourTexture2.TextureResource, ColourTexture3.TextureResource, ColourTexture4.TextureResource, AlphaTexture1.TextureResource, NormalTexture1.TextureResource, NormalTexture2.TextureResource)) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public bool Render() { // Clear the buffer to begin the scene. D3D.BeginScene(0, 0, 0, 1f); // Render the refraction of the scene to a texture. if (!RenderRefractionToTexture()) { return(false); } // Render the reflection of the scene to a texture. if (!RenderReflectionToTexture()) { return(false); } // Render the scene as normal to the back buffer. if (!RenderScene()) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
private bool Render(float rotation) { // Clear the buffer to begin the scene. D3D.BeginScene(0f, 0f, 0f, 1f); // Generate the view matrix based on the camera position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. var viewMatrix = Camera.ViewMatrix; var worldMatrix = D3D.WorldMatrix; var projectionMatrix = D3D.ProjectionMatrix; // Rotate the world matrix by the rotation value so that the triangle will spin. Matrix.RotationY(rotation, out worldMatrix); // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. Model.Render(D3D.DeviceContext); // Render the model using the color shader. if (!LightShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.Texture.TextureResource, Light.Direction, Light.AmbientColor, Light.DiffuseColor, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower)) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public void Shutdown() { // Release the position object. Position = null; // Release the light object. Light = null; // Release the fps object. FPS = null; // Release the camera object. Camera = null; // Release the text object. Text?.Shutdown(); Text = null; // Release the cpu object. CPU?.Shutdown(); CPU = null; // Release the terrain shader object. TerrainBumpMapShader?.ShutDown(); TerrainBumpMapShader = null; // Release the tree object. TerrainModel?.ShutDown(); TerrainModel = null; // Release the input object. Input?.Shutdown(); Input = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
public void Shutdown() { // Release the color shader object. if (LightShader != null) { LightShader.Shuddown(); LightShader = null; Light = null; } // Release the model object. if (Model != null) { Model.Shutdown(); Model = null; } // Release the camera object. if (Camera != null) { Camera = null; } // Release the Direct3D object. if (D3D != null) { D3D.Shutdown(); D3D = null; } }
public bool Render() { // Increment the texture translation position. TextureTranslate(); // Clear the buffer to begin the scene as Black. D3D.BeginScene(0, 0, 0, 1f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. Matrix viewMatrix = Camera.ViewMatrix; Matrix worldMatrix = D3D.WorldMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. Model.Render(D3D.DeviceContext); // Render the model with the texture translation shader. if (!TranslateShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.TextureCollection.Select(item => item.TextureResource).ToArray(), TextureTranslation)) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public void Shutdown() { // Release the light object. Light = null; // Release the view point object. ViewPoint = null; // Release the camera object. Camera = null; // Release the projection texture object. ProjectionTexture?.ShutDown(); ProjectionTexture = null; // Release the projection shader object. ProjectionShader?.ShutDown(); ProjectionShader = null; // Release the ground model object. GroundModel?.Shutdown(); GroundModel = null; // Release the cube model object. CubeModel?.Shutdown(); CubeModel = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
public void Shutdown() { // Release the light object. Light = null; Light2 = null; // Release the camera object. Camera = null; // Release the second render to texture object. RenderTexture2?.Shutdown(); RenderTexture2 = null; // Release the shadow shader object. ShadowShader?.ShutDown(); ShadowShader = null; // Release the depth shader object. DepthShader?.ShutDown(); DepthShader = null; /// Release the render to texture object. RenderTexture?.Shutdown(); RenderTexture = null; // Release the ground model object. GroundModel?.Shutdown(); GroundModel = null; // Release the sphere model object. SphereModel?.Shutdown(); SphereModel = null; // Release the cube model object. CubeModel?.Shutdown(); CubeModel = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
private bool RenderRefractionToTexture() { // Setup a clipping plane based on the height of the water to clip everything above it to create a refraction. Vector4 clipPlane = new Vector4(0.0f, -1.0f, 0.0f, WaterModel.WaterHeight + 0.1f); // Set the render target to be the refraction render to texture. RefractionTexture.SetRenderTarget(D3D.DeviceContext); // Clear the refraction render to texture. RefractionTexture.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the matrices from the camera and d3d objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix viewMatrix = Camera.ViewMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Render the terrain using the reflection shader and the refraction clip plane to produce the refraction effect. TerrainModel.Render(D3D.DeviceContext); if (!ReflectionShader.Render(D3D.DeviceContext, TerrainModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, TerrainModel.ColorTexture.TextureResource, TerrainModel.NormalMapTexture.TextureResource, Light.DiffuseColour, Light.Direction, 2.0f, clipPlane)) { return(false); } // Reset the render target back to the original back buffer and not the render to texture anymore. D3D.SetBackBufferRenderTarget(); // Reset the viewport back to the original. D3D.ResetViewPort(); return(true); }
public void ShutDown() { Timer = null; D3D?.ShutDown(); D3D = null; }
private bool Render() { // Clear the buffer to begin the scene. D3D.BeginScene(0.1f, 0f, 0f, 1f); // Generate the view matrix based on the camera position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. var viewMatrix = Camera.ViewMatrix; var worldMatrix = D3D.WorldMatrix; var projectionMatrix = D3D.ProjectionMatrix; // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. Model.Render(D3D.DeviceContext); // Render the model using the color shader. if (!ColorShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix)) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public void Shutdown() { // Release the position object. Position = null; // Release the fps object. FPS = null; // Release the camera object. Camera = null; // Release the text object. Text?.Shutdown(); Text = null; // Release the font shader object. FontShader?.Shuddown(); FontShader = null; // Release the cpu object. CPU?.Shutdown(); CPU = null; // Release the color shader object. ColorShader?.ShutDown(); ColorShader = null; // Release the tree object. Terrain?.ShutDown(); Terrain = null; // Release the input object. Input?.Shutdown(); Input = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
public void Shutdown() { // Release the light object. Light = null; // Release the camera object. Camera = null; // Release the light shader object. LightShader?.ShutDown(); LightShader = null; // Release the deferred shader object. DeferredShader?.ShutDown(); DeferredShader = null; // Release the deferred buffers object. DeferredBuffers?.Shutdown(); DeferredBuffers = null; // Release the full screen ortho window object. FullScreenWindow?.Shutdown(); FullScreenWindow = null; // Release the tree object. Model?.Shutdown(); Model = null; // Release the input object. Input?.Shutdown(); Input = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
public void ShutDown() { // Release the light object. Light = null; // Release the camera object. Camera = null; // Release the model object. BitMap?.Shutdown(); BitMap = null; // Release the text object. Text?.Shutdown(); Text = null; // Release the light shader object. LightShader?.ShutDown(); LightShader = null; // Release the model object. Model?.Shutdown(); Model = null; // Release the input object. Input?.Shutdown(); Input = null; // Release the texture shader object. TextureShader?.ShutDown(); TextureShader = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
private bool RenderGraphics() { // Clear the scene. D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, projection, and ortho matrices from the camera and Direct3D objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix cameraViewMatrix = Camera.ViewMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; Matrix orthoD3DMatrix = D3D.OrthoMatrix; // Construct the frustum. Frustum.ConstructFrustum(DSystemConfiguration.ScreenDepth, projectionMatrix, cameraViewMatrix); // Set the terrain shader parameters only once now that it will use for rendering. if (!TerrainShader.SetShaderParameters(D3D.DeviceContext, worldMatrix, cameraViewMatrix, projectionMatrix, Light.AmbientColor, Light.DiffuseColour, Light.Direction, TerrainModel.Texture.TextureResource)) { return(false); } // Render the terrain using the quad tree and terrain shader. QuadTree.Render(D3D.DeviceContext, Frustum, TerrainShader); // Set the number of rendered terrain triangles since some were culled. if (!Text.SetRenderCount(QuadTree.DrawCount, D3D.DeviceContext)) { return(false); } if (!Text.SetSentenceByIndex(11, "TEST", D3D.DeviceContext)) { return(false); } // Turn off the Z buffer to begin all 2D rendering. D3D.TurnZBufferOff(); // Turn on the alpha blending before rendering the text. D3D.TurnOnAlphaBlending(); // Render the text user interface elements. if (!Text.Render(D3D.DeviceContext, FontShader, worldMatrix, orthoD3DMatrix)) { return(false); } // Turn off alpha blending after rendering the text. D3D.TurnOffAlphaBlending(); // Turn the Z buffer back on now that all 2D rendering has completed. D3D.TurnZBufferOn(); // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
public bool Render() { // Clear the buffers to begin the scene. D3D.BeginScene(0, 0, 0, 1f); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, and projection matrices from the camera and d3d objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix viewMatrix = Camera.ViewMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Put the floor model vertex and index buffers on the graphics pipeline to prepare them for drawing. FloorModel.Render(D3D.DeviceContext); // Render the floor model using the texture shader. if (!TextureShader.Render(D3D.DeviceContext, FloorModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, FloorModel.GetTexture())) { return(false); } // Get the position of the camera. Vector3 cameraPosition = Camera.GetPosition(); // Set the position of the billboard model. Vector3 modelPosition = new Vector3(); modelPosition.X = 0.0f; modelPosition.Y = 1.5f; modelPosition.Z = 0.0f; // Calculate the rotation that needs to be applied to the billboard model to face the current camera position using the arc tangent function. double angle = Math.Atan2(modelPosition.X - cameraPosition.X, modelPosition.Z - cameraPosition.Z) * (180.0f / Math.PI); // Convert rotation into radians. float rotation = (float)angle * 0.0174532925f; // Setup the rotation the billboard at the origin using the world matrix. Matrix.RotationY(rotation, out worldMatrix); // Setup the translation matrix from the billboard model. Matrix translationMatrix = Matrix.Translation(modelPosition.X, modelPosition.Y, modelPosition.Z); // Finally combine the rotation and translation matrices to create the final world matrix for the billboard model. Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix); // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. BillboardModel.Render(D3D.DeviceContext); // Render the model using the texture shader. if (!TextureShader.Render(D3D.DeviceContext, BillboardModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, BillboardModel.GetTexture())) { return(false); } // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
private bool RenderGraphics() { // Clear the scene. D3D.BeginScene(0, 0, 0, 1); // Generate the view matrix based on the camera's position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. var viewMatrix = Camera.ViewMatrix; var worldMatrix = D3D.WorldMatrix; var projectionMatrix = D3D.ProjectionMatrix; var orthoMatrix = D3D.OrthoMatrix; // Construct the frustrum Frustum.ConstructFrustum(SystemConfiguration.ScreenDepth, projectionMatrix, viewMatrix); // Set the terrain shader parameters that it will use for rendering. if (!HeightMapTerrainShader.SetShaderParameters(D3D.DeviceContext, worldMatrix, viewMatrix, projectionMatrix, Light.Direction, Light.AmbientColor, Light.DiffuseColor, Terrain.Texture.TextureResource)) { return(false); } // Render the terrain using the quad tree and terrain shader QuadTree.Render(D3D.DeviceContext, Frustum, HeightMapTerrainShader); // Set the number of rendered terrain triangles since some were culled. if (!Text.SetRenderCount(QuadTree.DrawCount, D3D.DeviceContext)) { return(false); } // Turn off the Z buffer to begin all 2D rendering. D3D.TurnZBufferOff(); // Turn on the alpha blending before rendering the text. D3D.TurnOnAlphaBlending(); // Render the text string. if (!Text.Render(D3D.DeviceContext, worldMatrix, orthoMatrix)) { return(false); } // Turn off the alpha blending before rendering the text. D3D.TurnOffAlphaBlending(); // Turn on the Z buffer to begin all 2D rendering. D3D.TurnZBufferOn(); // Present the rendered scene to the screen. D3D.EndScene(); return(true); }