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);
        }
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
        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);
        }
Beispiel #9
0
        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(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);
        }
Beispiel #12
0
        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);
        }
        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);
        }
Beispiel #15
0
        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);
        }
        private bool Render()
        {
            // Clear the buffers to begin 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, and projection matrices from the camera and d3d objects.
            Matrix translationMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Setup the rotation and translation of the first model.
            Matrix.RotationY(Rotation, out worldMatrix);
            Matrix.Translation(-3.5f, 0.0f, 0.0f, out translationMatrix);
            Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix);

            // Render the first model using the texture shader.
            CubeModel1.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderTextureShader(D3D.DeviceContext, CubeModel1.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel1.Texture.TextureResource))
            {
                return(false);
            }

            // Setup the rotation and translation of the second model by resetting the worldMatrix too.
            worldMatrix = D3D.WorldMatrix;
            Matrix.RotationY(Rotation, out worldMatrix);
            Matrix.Translation(0.0f, 0.0f, 0.0f, out translationMatrix);
            Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix);

            // Render the second model using the light shader.
            CubeModel2.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderLightShader(D3D.DeviceContext, CubeModel2.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel2.Texture.TextureResource, Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }

            // Setup the rotation and translation of the third model.
            worldMatrix = D3D.WorldMatrix;
            Matrix.RotationY(Rotation, out worldMatrix);
            Matrix.Translation(3.5f, 0.0f, 0.0f, out translationMatrix);
            Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix);

            // Render the third model using the bump map shader.
            CubeBumpMapModel3.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderBumpMapShader(D3D.DeviceContext, CubeBumpMapModel3.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeBumpMapModel3.ColorTexture.TextureResource, CubeBumpMapModel3.NormalMapTexture.TextureResource, Light.Direction, Light.DiffuseColour))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
        public bool Render()
        {
            float   distortionScale, distortionBias;
            Vector3 scrollSpeeds, scales;
            Vector2 distortion1, distortion2, distortion3;

            // Increment the frame time counter.
            FrameTime += 0.001f;
            if (FrameTime >= 1000.0f)
            {
                FrameTime = 0.0f;
            }

            // Set the three scrolling speeds for the three different noise textures.
            // The x value is the scroll speed for the first noise texture. The y value is the scroll speed for the second noise texture. And the z value is the scroll speed for the third noise texture.
            scrollSpeeds = new Vector3(1.3f, 2.1f, 2.3f);

            // Set the three scales which will be used to create the three different noise octave textures.
            scales = new Vector3(1.0f, 2.0f, 3.0f);

            // Set the three different x and y distortion factors for the three different noise textures.
            distortion1 = new Vector2(0.1f, 0.2f);
            distortion2 = new Vector2(0.1f, 0.3f);
            distortion3 = new Vector2(0.1f, 0.1f);

            // The the scale and bias of the texture coordinate sampling perturbation.
            distortionScale = 0.8f;
            distortionBias  = 0.5f;

            // 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;

            // Turn on alpha blending for the fire transparency.
            D3D.TurnOnAlphaBlending();

            // Put the square model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            Model.Render(D3D.DeviceContext);

            // Render the square model using the fire shader.
            FireShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.TextureCollection.Select(item => item.TextureResource).ToArray()[0], Model.TextureCollection.Select(item => item.TextureResource).ToArray()[1], Model.TextureCollection.Select(item => item.TextureResource).ToArray()[2], FrameTime, scrollSpeeds, scales, distortion1, distortion2, distortion3, distortionScale, distortionBias);

            // Turn off alpha blending.
            D3D.TurnOffAlphaBlending();

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
Beispiel #18
0
        public bool Render()
        {
            if (SystemConfiguration.DebugWindowOn)
            {
                // Render the entire scene to the texture first.
                if (!RenderToDebugTexture())
                {
                    return(false);
                }
            }

            // Render the entire scene as a reflection to the texture first.
            if (!RenderToReflectionTexture())
            {
                return(false);
            }

            // Clear the buffer to begin the scene.
            D3D.BeginScene(0, 0, 0, 1f);

            // Render the scene as normal to the back buffer.
            if (!RenderScene())
            {
                return(false);
            }

            if (SystemConfiguration.DebugWindowOn)
            {
                // 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 debug window vertex and index buffer on the graphics pipeline them for drawing.
                if (!DebugWindow.Render(D3D.DeviceContext, 50, 50))
                {
                    return(false);
                }

                // Render the debug window using the texture shader.
                if (!TextureShader.Render(D3D.DeviceContext, DebugWindow.IndexCount, worldMatrix, viewMatrix, orthoMatrix, RenderDebugTexture.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);
        }
Beispiel #19
0
        public bool Render()
        {
            // Clear the buffer to begin the scene.
            D3D.BeginScene(0f, 0f, 0f, 1f);

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
Beispiel #20
0
        private bool Render()
        {
            // Clear the buffer to begin the scene.
            D3D.BeginScene(0.5f, 0.5f, 0.5f, 1.0f);

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
Beispiel #21
0
        private void RenderGraphics(double frameTime)
        {
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);
            Camera.Render();
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix cameraViewMatrix = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            Terrain.Render(D3D.DeviceContext, frameTime);
            ColorShader.Render(D3D.DeviceContext, Terrain.IndexCount, worldMatrix, cameraViewMatrix, projectionMatrix);
            D3D.EndScene();
        }
        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;

            // Render the terrain buffers.
            TerrainModel.Render(D3D.DeviceContext);

            // Render the model using the color shader.
            if (!TerrainShader.Render(D3D.DeviceContext, TerrainModel.IndexCount, worldMatrix, cameraViewMatrix, projectionMatrix, Light.AmbientColor, Light.DiffuseColour, Light.Direction, TerrainModel.Texture.TextureResource))
            {
                return(false);
            }

            // Turn off the Z buffer to begin all 2D rendering.
            D3D.TurnZBufferOff();

            // Render the mini map.
            if (!MiniMap.Render(D3D.DeviceContext, worldMatrix, orthoD3DMatrix, TextureShader))
            {
                return(false);
            }

            // Turn on the alpha blending before rendering the text.
            D3D.TurnOnAlphaBlending();

            // Render the text user interface elements.
            if (!Text.Render(D3D.DeviceContext, 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);
        }
Beispiel #23
0
        public bool Render(float rotation)
        {
            Matrix worldMatrix, viewMatrix, projectionMatrix;
            float  refractionScale;

            // First set the refraction scale to modify how much perturbation occurs in the glass.
            // Set the refraction scale for the glass shader.
            refractionScale = 0.01f;

            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Get the world, view, and projection matrices from the camera and d3d objects.
            worldMatrix      = D3D.WorldMatrix;
            viewMatrix       = Camera.ViewMatrix;
            projectionMatrix = D3D.ProjectionMatrix;

            // Then render the 3D spinning cube scene as normal.
            // Multiply the world matrix by the rotation.
            Matrix.RotationY(rotation, out worldMatrix);

            // Put the cube model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            Model.Render(D3D.DeviceContext);

            // Render the cube model using the texture shader.
            if (!TextureShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.TextureCollection.Select(item => item.TextureResource).First()))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Now render the window model using the glass shader with the color texture, normal map, refraction render to texture, and refraction scale as input.
            // Translate to back where the window model will be rendered.
            Matrix.Translation(0.0f, 0.0f, -1.5f, out worldMatrix);

            // // Put the window model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WindowModel.Render(D3D.DeviceContext);

            // Render the window model using the glass shader.
            if (!GlassShader.Render(D3D.DeviceContext, WindowModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, WindowModel.TextureCollection.Select(item => item.TextureResource).First(), WindowModel.TextureCollection.Select(item => item.TextureResource).ToArray()[1], RenderTexture.ShaderResourceView, refractionScale))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
        private bool Render()
        {
            D3D.BeginScene(0.1f, 0f, 0f, 1f);

            Camera.Render();
            Model.Render(D3D.DeviceContext);
            if (!ColorShader.Render(D3D.DeviceContext, Model.IndexCount, D3D.WorldMatrix, Camera.ViewMatrix, D3D.ProjectionMatrix))
            {
                return(false);
            }

            D3D.EndScene();
            return(true);
        }
Beispiel #25
0
        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;

            // Render the terrain buffers.
            Terrain.Render(D3D.DeviceContext);

            // Render the model using the color shader.
            if (!HeightMapTerrainShader.Render(D3D.DeviceContext, Terrain.IndexCount,
                                               worldMatrix, viewMatrix, projectionMatrix,
                                               Light.Direction, Light.AmbientColor, Light.DiffuseColor,
                                               Terrain.Texture.TextureResource))
            {
                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);
        }
Beispiel #26
0
        public bool Render()
        {
            // Clear the buffer to begin the scene as Black.
            D3D.BeginScene(0, 0, 0, 1f);

            // 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 RenderScene()
        {
            // Clear the buffer to begin the scene as Black.
            D3D.BeginScene(0, 0, 0, 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 with the texture shader.
            if (!TextureShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.TextureCollection.Select(item => item.TextureResource).First()))
            {
                return(false);
            }

            // Get the world matrix again and translate down for the floor model to render underneath the cube.
            worldMatrix = D3D.WorldMatrix;
            Matrix.Translation(0, -1.5f, 0, out worldMatrix);

            // Get the camera reflection view matrix.
            var reflectionMatrix = Camera.ReflectionViewMatrix;

            // 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 reflection shader, reflection texture, and reflection view matrix.
            if (!ReflectionShader.Render(D3D.DeviceContext, FloorModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, FloorModel.TextureCollection.Select(item => item.TextureResource).First(), RenderTexture.ShaderResourceView, reflectionMatrix))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
        private bool Render()
        {
            // Clear the buffers to begin 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, and projection matrices from the camera and d3d objects.
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the view and projection matrices from the view point object.
            Matrix viewMatrix2       = ViewPoint.ViewMatrix;
            Matrix projectionMatrix2 = ViewPoint.ProjectionMatrix;

            // Setup the translation for the ground model.
            Matrix.Translation(0.0f, 1.0f, 0.0f, out worldMatrix);

            // Render the ground model using the projection shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ProjectionShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, GroundModel.Texture.TextureResource, Light.AmbientColor, Light.DiffuseColour, Light.Position, viewMatrix2, projectionMatrix2, ProjectionTexture.TextureResource))
            {
                return(false);
            }

            // Reset the world matrix and setup the translation for the cube model.
            worldMatrix = D3D.WorldMatrix;
            Matrix.Translation(0.0f, 2.0f, 0.0f, out worldMatrix);

            // Render the cube model using the projection shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!ProjectionShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel.Texture.TextureResource, Light.AmbientColor, Light.DiffuseColour, Light.Position, viewMatrix2, projectionMatrix2, ProjectionTexture.TextureResource))
            {
                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, 1.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;
            Matrix baseViewMatrix   = Camera.BaseViewMatrix;

            // Render the ground model.
            GroundModel.Render(D3D.DeviceContext);
            ShaderManager.RenderTextureShader(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, GroundModel.ColourTexture.TextureResource);

            // Turn on the alpha-to-coverage blending.
            D3D.EnableSecondBlendState();

            // Render the foliage.
            Foliage.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderFoliageShader(D3D.DeviceContext, Foliage.VertexCount, Foliage.InstanceCount, viewCameraMatrix, projectionMatrix, Foliage.Texture.TextureResource))
            {
                return(false);
            }

            // Turn off the alpha blending.
            D3D.TurnOffAlphaBlending();

            // Render the user interface.
            UserInterface.Render(D3D, ShaderManager, worldMatrix, baseViewMatrix, orthoMatrix);

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
Beispiel #30
0
        public bool Render()
        {
            // Set the color of the fog to grey.
            var fogColor = 0.5f;

            // Set the start and end of the fog.
            var fogStart = 4.0f;
            var fogEnd   = 4.5f;

            // Clear the buffer to begin the scene.
            D3D.BeginScene(fogColor, fogColor, fogColor, 1f);

            // Generate the view matrix based on the camera position.
            Camera.Render();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Update the rotation variable each frame.
            Rotate();

            // Multiply the world matrix by the rotation.
            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 with the fog shader.
            if (!FogShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.TextureCollection.Select(item => item.TextureResource).ToArray(), fogStart, fogEnd))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }