예제 #1
0
        protected void RenderScene()
        {
            // update view variables
            xAxisRotation.Angle = XAxisSlider.Value;
            yAxisRotation.Angle = -YAxisSlider.Value;
            zAxisRotation.Angle = ZAxisSlider.Value;
            modelZoom.ScaleX    = ZoomSlider.Value / 2;
            modelZoom.ScaleY    = ZoomSlider.Value / 2;
            modelZoom.ScaleZ    = ZoomSlider.Value / 2;

            // update view
            meshManager.SetViewAndProjection(
                camera.ToViewLH().ToMatrix4x4F(),
                camera.ToPerspectiveLH(renderHost.ActualWidth / renderHost.ActualHeight).ToMatrix4x4F());

            // clear render target
            device.ClearRenderTargetView(renderTargetView, backgroundColor);

            // Clear the depth buffer to 1.0 (max depth)
            device.ClearDepthStencilView(depthStencilView, ClearOptions.Depth, 1.0f, (byte)0);

            // render mesh
            mesh.LightIntensity = 2.5f;
            mesh.Render(modelTransformGroup.Value);

            // present back buffer
            swapChain.Present(1, PresentOptions.None);
        }
예제 #2
0
        private void InitMatrices()
        {
            // Initialize the view matrix
            Vector3F Eye = new Vector3F(0.0f, 1.0f, -5.0f);
            Vector3F At  = new Vector3F(0.0f, 0.0f, 0.0f);
            Vector3F Up  = new Vector3F(0.0f, 1.0f, 0.0f);

            Matrix4x4F viewMatrix;
            Matrix4x4F projectionMatrix;

            viewMatrix = DXUtil.Camera.MatrixLookAtLH(Eye, At, Up);

            // Initialize the projection matrix
            projectionMatrix = DXUtil.Camera.MatrixPerspectiveFovLH((float)Math.PI * 0.25f, ((float)host.ActualWidth / (float)host.ActualHeight), 0.5f, 1000.0f);

            meshManager.SetViewAndProjection(viewMatrix, projectionMatrix);
        }
예제 #3
0
        private void InitMatrices()
        {
            // Initialize the view matrix
            Vector3F Eye = new Vector3F(0.0f, 3.0f, -15.0f);
            Vector3F At  = new Vector3F(0.0f, 0.0f, 0.0f);
            Vector3F Up  = new Vector3F(0.0f, 1.0f, 0.0f);

            Matrix4x4F viewMatrix;
            Matrix4x4F projectionMatrix;

            viewMatrix = dxUtil.Camera.MatrixLookAtLH(Eye, At, Up);

            // Initialize the projection matrix
            projectionMatrix = dxUtil.Camera.MatrixPerspectiveFovLH(
                (float)Math.PI * 0.25f,
                (float)directControl.ClientSize.Width / (float)directControl.ClientSize.Height,
                0.5f, 1000.0f);

            meshManager.SetViewAndProjection(viewMatrix, projectionMatrix);
        }