// 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 shader manager object. ShaderManager = new DShaderManager(); // Initialize the shader manager object. if (!ShaderManager.Initilize(D3D, windowHandle)) { return(false); } // Create the position object. Position = new DPosition(); // Set the initial position and rotation of the viewer. Position.SetPosition(0.0f, 1.5f, -4.0f); Position.SetRotation(15.0f, 0.0f, 0.0f); // 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.Render(); Camera.RenderBaseViewMatrix(); // Create the fps object. FPS = new DFPS(); //// Initialize the fps object. FPS.Initialize(); // Create the user interface object. UserInterface = new DUserInterface(); // Initialize the user interface object. if (!UserInterface.Initialize(D3D, configuration)) { return(false); } // Create the ground model object. GroundModel = new DModel(); // Initialize the ground model object. if (!GroundModel.Initialize(D3D.Device, "plane01.txt", "rock015.bmp")) { return(false); } // Create the foliage object. Foliage = new DFoliage(); // Initialize the foliage object. if (!Foliage.Initialize(D3D.Device, "grass01.bmp", 500)) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods public bool Initialize(DDX11 D3Ddevice, DSystemConfiguration configuration) { // Create the first font object. Font1 = new DFont(); // Initialize the first font object. if (!Font1.Initialize(D3Ddevice.Device, "font01.txt", "font01.bmp", 32.0f, 3)) { return(false); } // Create the text object for the fps string. FpsString = new DText(); // Initialize the fps text string. if (!FpsString.Initialize(D3Ddevice.Device, Font1, configuration, 16, "FPS: 0", 10, 50, 0.0f, 1.0f, 0.0f, false, D3Ddevice.DeviceContext)) { return(false); } // Initial the previous frame fps. PreviousFPS = -1; // Create the text objects for the position strings. PositionStrings = new DText[6]; for (int i = 0; i < PositionStrings.Length; i++) { PositionStrings[i] = new DText(); } // Initialize the position text strings. if (!PositionStrings[0].Initialize(D3Ddevice.Device, Font1, configuration, 16, "X: 0", 10, 90, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!PositionStrings[1].Initialize(D3Ddevice.Device, Font1, configuration, 16, "Y: 0", 10, 110, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!PositionStrings[2].Initialize(D3Ddevice.Device, Font1, configuration, 16, "Z: 0", 10, 130, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!PositionStrings[3].Initialize(D3Ddevice.Device, Font1, configuration, 16, "rX: 0", 10, 170, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!PositionStrings[4].Initialize(D3Ddevice.Device, Font1, configuration, 16, "rY: 0", 10, 190, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!PositionStrings[5].Initialize(D3Ddevice.Device, Font1, configuration, 16, "rZ: 0", 10, 210, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } // Initialize the previous frame position. PreviousPositions = new int[6]; VideoStrings = new DText[2]; for (int i = 0; i < VideoStrings.Length; i++) { VideoStrings[i] = new DText(); } // Initialize the position text strings. if (!VideoStrings[0].Initialize(D3Ddevice.Device, Font1, configuration, 256, D3Ddevice.VideoCardDescription, 10, 10, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!VideoStrings[1].Initialize(D3Ddevice.Device, Font1, configuration, 64, D3Ddevice.VideoCardMemory.ToString(), 10, 30, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } // Create the text objects for the render count strings. RenderCountStrings = new DText[3]; for (int i = 0; i < RenderCountStrings.Length; i++) { RenderCountStrings[i] = new DText(); } // Initialize the render count strings. if (!RenderCountStrings[0].Initialize(D3Ddevice.Device, Font1, configuration, 32, "Polys Drawn: 0", 10, 250, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!RenderCountStrings[1].Initialize(D3Ddevice.Device, Font1, configuration, 32, "Cells Drawn: 0", 10, 270, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } if (!RenderCountStrings[2].Initialize(D3Ddevice.Device, Font1, configuration, 32, "Cells Culled: 0", 10, 290, 1.0f, 1.0f, 1.0f, false, D3Ddevice.DeviceContext)) { return(false); } // Create the mini-map object. MiniMap = new DMiniMap(); // Initialize the mini-map object. if (!MiniMap.Initialize(D3Ddevice.Device, D3Ddevice.DeviceContext, configuration, 1025, 1025)) { return(false); } return(true); }
public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { // 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 shader manager object. ShaderManager = new DShaderManager(); // Initialize the shader manager object. if (!ShaderManager.Initilize(D3D, windowHandle)) { return(false); } // Create the texture manager object. TextureManager = new DTextureManager(); // Initialize the texture manager object. if (!TextureManager.Initialize(10)) { return(false); } // Load textures into the texture manager. if (!TextureManager.LoadTexture(D3D.Device, D3D.DeviceContext, "dirt01d.bmp", 0)) { return(false); } if (!TextureManager.LoadTexture(D3D.Device, D3D.DeviceContext, "dirt01n.bmp", 1)) { return(false); } // Create and initialize Timer. Timer = new DTimer(); if (!Timer.Initialize()) { return(false); } // Create the fps object. FPS = new DFPS(); FPS.Initialize(); // Create and Initialize the Zone object. Zone = new DZone(); if (!Zone.Initialze(D3D, windowHandle, configuration)) { 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); } // #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) { 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 { // 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 position object. Position = new DPosition(); // Set the initial position and rotation of the viewer. Position.SetPosition(15.0f, 13.0f, 20.0f); Position.SetRotation(25.0f, 180.0f, 0.0f); // Create the camera object Camera = new DCamera(); // Create the light object. Light = new DLight(); // Initialize the light object. Light.Direction = new Vector3(0.5f, -0.75f, 0.0f); // Create the model object. TerrainModel = new DTerrainHeightMap(); // Initialize the terrain object. if (!TerrainModel.Initialize(D3D.Device, "hm01.bmp", 10.0f)) { 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 first color texture object. ColourTexture1 = new DTexture(); // Load the first color texture object. if (!ColourTexture1.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "dirt001.bmp")) { return(false); } // Create the second color texture object. ColourTexture2 = new DTexture(); // Load the second color texture object. if (!ColourTexture2.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "dirt004.bmp")) { return(false); } // Create the third color texture object. ColourTexture3 = new DTexture(); // Load the third color texture object. if (!ColourTexture3.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "dirt002.bmp")) { return(false); } // Create the fourth color texture object. ColourTexture4 = new DTexture(); // Load the forth color texture object. if (!ColourTexture4.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "stone001.bmp")) { return(false); } // Create the first alpha texture object. AlphaTexture1 = new DTexture(); // Load the first alpha texture object. if (!AlphaTexture1.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "alphaRoad001.bmp")) { return(false); } // Create the first normal texture object. NormalTexture1 = new DTexture(); // Load the first alpha/Normal texture object. if (!NormalTexture1.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "normal001.bmp")) { return(false); } // Create the second normal texture object. NormalTexture2 = new DTexture(); // Load the second alpha/Normal texture object. if (!NormalTexture2.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "normal002.bmp")) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }