// 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 and rotation of the camera; Camera.SetPosition(0.0f, 2.0f, -12.0f); // 0.0f, 4.0f, -12.0f #endregion #region Initialize Models // Create the Flat Plane model class. Model = new DModel(); //// Initialize the ground model object. if (!Model.Initialize(D3D.Device, "plane01.txt", new[] { "stone01.bmp" })) { MessageBox.Show("Could not initialize the ground model object", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Shaders // Create the light shader object. LightShader = new DLightShader(); // Initialize the light shader object. if (!LightShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the light shader object.", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Data // Create the first light object. Light1 = new DLight(); // Initialize the first light as a red Light. Light1.SetDiffuseColor(1.0f, 0.0f, 0.0f, 1.0f); Light1.SetPosition(-3.0f, 1.0f, 3.0f); // Create the second light object. Light2 = new DLight(); // Initialize the second light as a green Light. Light2.SetDiffuseColor(0.0f, 1.0f, 0.0f, 1.0f); Light2.SetPosition(3.0f, 1.0f, 3.0f); // Create the third light object. Light3 = new DLight(); // Initialize the third light to a blue Light. Light3.SetDiffuseColor(0.0f, 0.0f, 1.0f, 1.0f); Light3.SetPosition(-3.0f, 1.0f, -3.0f); // Create the fourth light object. Light4 = new DLight(); // Initialize the fourth light as a white Light. Light4.SetDiffuseColor(1.0f, 1.0f, 0.0f, 1.0f); Light4.SetPosition(3.0f, 1.0f, -3.0f); // Prep rendering variables here once instead of every frame. lightDiffuseColors = new Vector4[LightShader.NumLights]; lightPositions = new Vector4[LightShader.NumLights]; // Create the diffuse color array from the four light colors. lightDiffuseColors[0] = Light1.DiffuseColour; lightDiffuseColors[1] = Light2.DiffuseColour; lightDiffuseColors[2] = Light3.DiffuseColour; lightDiffuseColors[3] = Light4.DiffuseColour; // Create the light position array from the four light positions. lightPositions[0] = Light1.Position; lightPositions[1] = Light2.Position; lightPositions[2] = Light3.Position; lightPositions[3] = Light4.Position; #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }