// Methods public bool Initialize(Device device, IntPtr windowsHandle) { // Create the texture shader object. TextureShader = new DTextureShader(); // Initialize the texture shader object. if (!TextureShader.Initialize(device, windowsHandle)) { return(false); } // Create the light shader object. LightShader = new DLightShader(); // Initialize the light shader object. if (!LightShader.Initialize(device, windowsHandle)) { return(false); } // Create the bump map shader object. BumpMapShader = new DBumpMapShader(); // Initialize the bump map shader object. if (!BumpMapShader.Initialize(device, windowsHandle)) { return(false); } return(true); }
public void Shutdown() { // Release the camera object. Camera = null; // Release the texture shader object. TextureShader?.ShutDown(); TextureShader = null; // Release the Floor model object. FloorModel?.Shutdown(); FloorModel = null; // Release the Billboard model object. BillboardModel?.Shutdown(); BillboardModel = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { // Set the size to sample down to. screenWidth = configuration.Width; screenHeight = configuration.Height; try { // Create the input object. Input = new DInput(); // Initialize the input object. if (!Input.Initialize(configuration, windowHandle)) { return(false); } #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the initial position of the camera. Camera.SetPosition(0.0f, 0.0f, -10.0f); Camera.Render(); #endregion // Create the model object. Model = new DModel(); // Initialize the model object. if (!Model.Initialize(D3D.Device, "sphere.txt", "blue.bmp")) { return(false); } // Create the texture shader object. TextureShader = new DTextureShader(); // Initialize the texture shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the light shader object. LightShader = new DLightShader(); // Initialize the light shader object. if (!LightShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the light object. Light = new DLight(); // Initialize the light object. Light.Direction = new Vector3(0.0f, 0.0f, 1.0f); // Create the text object. Text = new DTextClass(); // Initialize the text object. if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, Camera.ViewMatrix)) { return(false); } // Create the bitmap object as the mouse pointer. BitMap = new DBitmap(); // Initialize the bitmap object. if (!BitMap.Initialize(D3D.Device, configuration.Width, configuration.Height, "mouse.bmp", 32, 32)) { return(false); } // Initialize that the user has not clicked on the screen to try an intersection test yet. beginMouseChexk = false; return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the initial position of the camera. Camera.SetPosition(0.0f, 0.0f, -7.0f); #endregion #region Initialize Shaders // Create the texture shader object. TextureShader = new DTextureShader(); // Create the texture shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { return(false); } #endregion #region Initialize Models // Create the Flat Plane model class. FloorModel = new DModel(); // Create the floor model object. if (!FloorModel.Initialize(D3D.Device, "floor.txt", new[] { "grid01.bmp" })) { MessageBox.Show("Could not initialize the ground model object", "Error", MessageBoxButtons.OK); return(false); } // Create the billboard model object. BillboardModel = new DModel(); // Initialize the billboard model object. if (!BillboardModel.Initialize(D3D.Device, "square.txt", new[] { "seafloor.bmp" })) { return(false); } #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the position of the camera; Camera.SetPosition(0, 0, -5.0f); #endregion #region Initialize Models // Create the model class. Model = new DModel(); // Initialize the model object. if (!Model.Initialize(D3D.Device, "square.txt", new[] { "dirt01.bmp" })) { MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK); return(false); } // Create the model class. Model2 = new DModel(); // Initialize the model object. if (!Model2.Initialize(D3D.Device, "square.txt", new[] { "stone01.bmp" })) { MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Textures // Create the shader object. TextureShader = new DTextureShader(); // Initialize the shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the shader", "Error", MessageBoxButtons.OK); return(false); } // Create the shader object. TransparentShader = new DTransparentShader(); // Initialize the shader object. if (!TransparentShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the shader", "Error", MessageBoxButtons.OK); return(false); } #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { // Create the input object. The input object will be used to handle reading the keyboard and mouse input from the user. Input = new DInput(); // Initialize the input object. if (!Input.Initialize(configuration, windowHandle)) { return(false); } // #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } // Create the camera object Camera = new DCamera(); // Initialize a base view matrix with the camera for 2D user interface rendering. Camera.SetPosition(0.0f, 0.0f, -1.0f); Camera.Render(); Matrix baseViewMatrix = Camera.ViewMatrix; // Set the initial position of the camera. (Since the ViewMatrix is already created from a base position.) Camera.SetPosition(40.0f, 2.0f, -7.0f); // Create the model object. TerrainModel = new DTerrain(); // Initialize the terrain object. if (!TerrainModel.Initialize(D3D.Device, "heightmap01.bmp", "dirt03.bmp", "colorm01.bmp")) { return(false); } // Create the position object. Position = new DPosition(); // Set the initial position of the viewer to the same as the initial camera position. Position.SetPosition(Camera.GetPosition().X, Camera.GetPosition().Y, Camera.GetPosition().Z); // Create the fps object. FPS = new DFPS(); // Initialize the fps object. FPS.Initialize(); // Create the cpu object. CPU = new DCPU(); // Initialize the cpu object. CPU.Initialize(); // Create the text object. Text = new DText(); // Initialize the text object. if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix)) { return(false); } // Set the video card information in the text object. if (!Text.SetVideoCard(D3D.VideoCardDescription, D3D.VideoCardMemory, D3D.DeviceContext)) { return(false); } // Create the color shader object. TerrainShader = new DTerrainShader(); // Initialize the color shader object. if (!TerrainShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the light object. Light = new DLight(); // Initialize the light object. Light.SetAmbientColor(0.05f, 0.05f, 0.05f, 1.0f); Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); Light.Direction = new Vector3(-0.5f, -1.0f, 0.0f); // Create the texture shader object. TextureShader = new DTextureShader(); // Initialize the texture shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Get the size of the terrain as the minimap will require this information. int textureWidth = TerrainModel.TextureWidth; int textureHeight = TerrainModel.TextureHeight; // Create the mini map object. MiniMap = new DMiniMapClass(); // Initialize the mini map object. if (!MiniMap.Initialize(D3D.Device, windowHandle, configuration.Width, configuration.Height, baseViewMatrix, (float)(textureWidth - 1), (float)(textureHeight - 1))) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { // Set the size to sample down to. int downSampleWidth = configuration.Width / 2; int downSampleHeight = configuration.Height / 2; try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the initial position of the camera. Camera.SetPosition(0.0f, 0.0f, -10.0f); #endregion #region Initialize Models // Create the Flat Plane model class. Model = new DModel(); // Create the floor model object. if (!Model.Initialize(D3D.Device, "cube.txt", "seafloor.bmp")) { MessageBox.Show("Could not initialize the ground model object", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Shaders // Create the texture shader object. TextureShader = new DTextureShader(); // Create the texture shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the horizontal blur shader object. HorizontalBlurShader = new DHorizontalBlurShader(); // Initialize the horizontal blur shader object. if (!HorizontalBlurShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the vertical blur shader object. VerticalBlurShader = new DVerticalBlurShader(); // Initialize the vertical blur shader object. if (!VerticalBlurShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. if (!RenderTexture.Initialize(D3D.Device, configuration)) { return(false); } // Create the down sample render to texture object. DownSampleTexure = new DRenderTexture(); // Temporarily alter Texture widths for small Down Sampled RenderTextures. int fullSizeWidth = configuration.Width; int fullScreenHeight = configuration.Height; configuration.Width /= 2; configuration.Height /= 2; // Initialize the down sample render to texture object. if (!DownSampleTexure.Initialize(D3D.Device, configuration)) { return(false); } // Create the horizontal blur render to texture object. HorizontalBlurTexture = new DRenderTexture(); // Initialize the horizontal blur render to texture object. if (!HorizontalBlurTexture.Initialize(D3D.Device, configuration)) { return(false); } // Create the vertical blur render to texture object. VerticalBlurTexture = new DRenderTexture(); // Initialize the vertical blur render to texture object. if (!VerticalBlurTexture.Initialize(D3D.Device, configuration)) { return(false); } // Put back the setting for other RenderTexture objects to its fell screen resultion settings. configuration.Width = fullSizeWidth; configuration.Height = fullScreenHeight; // Create the up sample render to texture object. UpSampleTexure = new DRenderTexture(); // Initialize the up sample render to texture object. if (!UpSampleTexure.Initialize(D3D.Device, configuration)) { return(false); } // Create the small ortho window object. SmallWindow = new DOrthoWindow(); // Initialize the small ortho window object at half the width and height of a full screen. if (!SmallWindow.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2)) { return(false); } // Create the full screen ortho window object. FullScreenWindow = new DOrthoWindow(); // Initialize the full screen ortho window object. if (!FullScreenWindow.Initialize(D3D.Device, configuration.Width, configuration.Height)) { return(false); } #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the position of the camera. Camera.SetPosition(0.0f, 0.0f, -5.0f); #endregion #region Initialize Models // Create the Flat Plane model class. Model = new DModel(); // Initialize the ground model object. if (!Model.Initialize(D3D.Device, "cube.txt", new[] { "seafloor.bmp", "bump03.bmp" })) { MessageBox.Show("Could not initialize the ground model object", "Error", MessageBoxButtons.OK); return(false); } // Create the wall model class. WindowModel = new DModel(); // Initialize the wall model object. if (!WindowModel.Initialize(D3D.Device, "square.txt", new[] { "glass01.bmp", "bump03.bmp" })) { MessageBox.Show("Could not initialize the wall model object", "Error", MessageBoxButtons.OK); return(false); } // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. RenderTexture.Initialize(D3D.Device, configuration); #endregion #region Initialize Shaders // Create the texture shader object. TextureShader = new DTextureShader(); // Initialize the texture shader object. TextureShader.Initialize(D3D.Device, windowHandle); // Create the glass shader object. GlassShader = new DGlassShader(); // Initialize the glass shader object. GlassShader.Initialize(D3D.Device, windowHandle); #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the position of the camera; Camera.SetPosition(0, 0, -10); #endregion #region Initialize Models // Create the model class. Model = new DModel(); // Initialize the model object. if (!Model.Initialize(D3D.Device, "Cube.txt", new[] { "seafloor.bmp" })) { MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK); return(false); } // Create the bitmap object. Bitmap = new DBitmap(); // Initialize the model object. if (!Bitmap.Initialize(D3D.Device, configuration.Width, configuration.Height, configuration.Width, configuration.Height)) { MessageBox.Show("Could not initialize the bitmap object", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Shader // Create the shader object. TextureShader = new DTextureShader(); // Initialize the shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the shader", "Error", MessageBoxButtons.OK); return(false); } // Create the shader object. FadeShader = new DFadeShader(); // Initialize the shader object. if (!FadeShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the fade shader", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Data // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. if (!RenderTexture.Initialize(D3D.Device, configuration)) { return(false); } #endregion #region Initialize Variables // Set the fade in time to 3000 milliseconds FadeInTime = 5000; // Initialize the accumulated time to zero milliseconds. AccumulatedTime = 0; // Initialize the fade percentage to zero at first so the scene is black. FadePercentage = 0; // Set the fading in effect to not done. FadeDone = false; #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
public bool Render(DeviceContext deviceContext, Matrix worldMatrix, Matrix orthoMatrix, DTextureShader textureShader) { // Put the border bitmap vertex and index buffers on the graphics pipeline to prepare them for drawing. if (!Border.Render(deviceContext, (m_MapLocationX - 2), (m_MapLocationY - 2))) { return(false); } // Render the border bitmap using the texture shader. if (!textureShader.Render(deviceContext, Border.IndexCount, worldMatrix, ViewMatrix, orthoMatrix, Border.Texture.TextureResource)) { return(false); } // Put the mini-map bitmap vertex and index buffers on the graphics pipeline to prepare them for drawing. if (!MiniMapBitmap.Render(deviceContext, m_MapLocationX, m_MapLocationY)) { return(false); } // Render the mini-map bitmap using the texture shader. if (!textureShader.Render(deviceContext, MiniMapBitmap.IndexCount, worldMatrix, ViewMatrix, orthoMatrix, MiniMapBitmap.Texture.TextureResource)) { return(false); } // Put the point bitmap vertex and index buffers on the graphics pipeline to prepare them for drawing. if (!Point.Render(deviceContext, m_PointLocationX, m_PointLocationY)) { return(false); } // Render the point bitmap using the texture shader. if (!textureShader.Render(deviceContext, Point.IndexCount, worldMatrix, ViewMatrix, orthoMatrix, Point.Texture.TextureResource)) { return(false); } return(true); }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { // Create the input object. The input object will be used to handle reading the keyboard and mouse input from the user. Input = new DInput(); // Initialize the input object. if (!Input.Initialize(configuration, windowHandle)) { return(false); } // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } // Create the camera object Camera = new DCamera(); // Initialize a base view matrix with the camera for 2D user interface rendering. Camera.SetPosition(0.0f, 0.0f, -10.0f); Camera.RenderBaseViewMatrix(); Matrix baseViewMatrix = Camera.BaseViewMatrix; // Set the initial position of the camera. Camera.SetPosition(100.0f, 2.0f, 5.0f); // Create the model object. TerrainModel = new DTerrain(); // Initialize the terrain object. if (!TerrainModel.Initialize(D3D.Device, "heightmap01.bmp", "dirt02.bmp", "colorm01.bmp", "detail001.bmp")) { return(false); } // Create the position object. Position = new DPosition(); // Set the initial position of the viewer to the same as the initial camera position. Position.SetPosition(Camera.GetPosition().X, Camera.GetPosition().Y, Camera.GetPosition().Z); // Create the fps object. FPS = new DFPS(); // Initialize the fps object. FPS.Initialize(); // Create the cpu object. CPU = new DCPU(); // Initialize the cpu object. CPU.Initialize(); // Create the text object. Text = new DText(); // Initialize the text object. if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix)) { return(false); } // Set the video card information in the text object. if (!Text.SetVideoCard(D3D.VideoCardDescription, D3D.VideoCardMemory, D3D.DeviceContext)) { return(false); } // Create the terrain shader object. TerrainShader = new DTerrainShader(); // Initialize the terrain shader object. if (!TerrainShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the light object. Light = new DLight(); // Initialize the light object. Light.SetAmbientColor(0.05f, 0.05f, 0.05f, 1.0f); Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); Light.Direction = new Vector3(-0.5f, -1.0f, 0.0f); // Create the debug window bitmap object. DebugWindow = new DDebugWindow(); // Initialize the debug window bitmap object. if (!DebugWindow.Initialize(D3D.Device, configuration.Width, configuration.Height, 256, 256)) { return(false); } // Create the texture shader object. TextureShader = new DTextureShader(); // Initialize the texture shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. if (!RenderTexture.Initialize(D3D.Device, configuration)) { return(false); } // Create the depth shader object. DepthShader = new DDepthShader(); // Initialize the depth shader object. if (!DepthShader.Initialize(D3D.Device, windowHandle)) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the position of the camera; Camera.SetPosition(0, 0, -10); #endregion #region Initialize Models // Create the model class. Model = new DModel(); // Initialize the model object. if (!Model.Initialize(D3D.Device, "Cube.txt", new[] { "seafloor.bmp" })) { MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK); return(false); } // Create the model class. FloorModel = new DModel(); // Initialize the model object. if (!FloorModel.Initialize(D3D.Device, "floor.txt", new[] { "blue01.bmp" })) { MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Shaders // Create the shader object. TextureShader = new DTextureShader(); // Initialize the shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the shader", "Error", MessageBoxButtons.OK); return(false); } // Create the Reflection shader object. ReflectionShader = new DReflectionShader(); // Initialize the shader object. if (!ReflectionShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the shader", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Data // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. if (!RenderTexture.Initialize(D3D.Device, configuration)) { return(false); } #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }