// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { // 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 the camera for 2D user interface rendering. Camera.SetPosition(0, 0, -5); Camera.Render(); // Create the model class. BumpMapModel = new DBumpMapModel(); // Initialize the model object. if (!BumpMapModel.Initialize(D3D.Device, "Cube.txt", new[] { "stone02.bmp", "bump02.bmp", "spec02.bmp" })) { MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK); return(false); } // Create the bump map shader object. SpecMapShader = new DSpecMapShader(); // Initialize the bump map shader object. if (!SpecMapShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the light shader", "Error", MessageBoxButtons.OK); return(false); } // Create the light object. Light = new DLight(); // Initialize the light object. Light.SetDiffuseColor(1, 1, 1, 1f); Light.SetDirection(0, 0, 1); Light.SetSpecularColor(0, 1, 1, 1); Light.SetSpecularPower(16); 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); } // Create the shader manager object. ShaderManager = new DShaderManager(); // Initialize the shader manager object. if (!ShaderManager.Initialize(D3D.Device, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the initial position and rotation of the camera. Camera.SetPosition(0.0f, 0.0f, -10.0f); #endregion #region Data variables. // Create the light object. Light = new DLight(); // Initialize the light object. Light.SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f); Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); Light.Direction = new Vector3(0.0f, 0.0f, 1.0f); Light.SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f); Light.SetSpecularPower(64.0f); #endregion #region Initialize Models // Create the ground model object. CubeModel1 = new DModel(); // Initialize the cube model object. if (!CubeModel1.Initialize(D3D.Device, "cube.txt", "marble.bmp")) { return(false); } // Create the second model object. CubeModel2 = new DModel(); // Initialize the cube model object. if (!CubeModel2.Initialize(D3D.Device, "cube.txt", "metal.bmp")) { return(false); } // Create the third bump model object for models with normal maps and related vectors. CubeBumpMapModel3 = new DBumpMapModel(); // Initialize the bump model object. if (!CubeBumpMapModel3.Initialize(D3D.Device, "cube.txt", "stone01.bmp", "normal.bmp")) { return(false); } #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }