public bool Initialze(DDX11 D3D, IntPtr windowHandle, DSystemConfiguration configuration) { // Create the user interface object. UserInterface = new DUserInterface(); // Initialize the user interface object. if (!UserInterface.Initialize(D3D, configuration)) { 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.Render(); Camera.RenderBaseViewMatrix(); // Create the position object. Position = new DPosition(); // Set the initial position and rotation of the viewer.28.0f, 5.0f, -10.0f Position.SetPosition(512.0f, 30.0f, 1034.0f); Position.SetRotation(0.0f, 180.0f, 0.0f); // Create the light object. Light = new DLight(); // Initialize the light object. Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); Light.Direction = new Vector3(-0.5f, -1.0f, -0.5f); // Create and initialize the frustum object. Frustum = new DFrustum(); Frustum.Initialize(DSystemConfiguration.ScreenDepth); // Create the sky dome object. SkyDomeModel = new DSkyDome(); // Initialize the sky dome object. if (!SkyDomeModel.Initialize(D3D.Device, "skydome.txt")) { return(false); } // Initialize the terrain object. Terrain = new DTerrain(); // Initialize the ground model object. if (!Terrain.Initialize(D3D.Device, "setupS2TutTerr08.txt")) { return(false); } // Set the UI to display by default. DisplayUI = true; // Set wire frame rendering initially to enabled. WireFrame = false; // Set the rendering of cell lines initially to enabled. CellLines = true; return(true); }
public bool Initialze(DDX11 D3D, IntPtr windowHandle, DSystemConfiguration configuration) { // Create the user interface object. UserInterface = new DUserInterface(); // Initialize the user interface object. if (!UserInterface.Initialize(D3D, configuration)) { 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.Render(); Camera.RenderBaseViewMatrix(); // Create the position object. Position = new DPosition(); // Set the initial position and rotation of the viewer.28.0f, 5.0f, -10.0f Position.SetPosition(128.0f, 10.0f, -10.0f); Position.SetRotation(0.0f, 0.0f, 0.0f); // Initialize the terrain object. Terrain = new DTerrain(); // Initialize the ground model object. if (!Terrain.Initialize(D3D.Device, "setup.txt")) { return(false); } // Set the UI to display by default. DisplayUI = true; // Set wire frame rendering initially to enabled. WireFrame = true; 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, -10.0f); Camera.RenderBaseViewMatrix(); Matrix baseViewMatrix = Camera.BaseViewMatrix; // Set the initial position of the camera. (Since the ViewMatrix is already created from a base position.) 250.0f Camera.SetPosition(100.0f, 2.0f, 250.0f); Camera.SetRotation(0, 180.0f, 0); // Create the model object. TerrainModel = new DTerrainHeightMap(); // Initialize the terrain object. if (!TerrainModel.Initialize(D3D.Device, "heightmap01.bmp", "dirt02.bmp", "bump.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); Position.SetRotation(Camera.GetRotation().X, Camera.GetRotation().Y, Camera.GetRotation().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. TerrainBumpMapShader = new DBumpMapShader(); // Initialize the color shader object. if (!TerrainBumpMapShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the light object. Light = new DLight(); // Initialize the light object. Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); Light.Direction = new Vector3(0.75f, -0.5f, 0.0f); 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(280.379f, 24.5225f, 367.018f); Position.SetRotation(19.6834f, 222.013f, 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.RenderBaseViewMatrix(); Matrix baseViewMatrix = Camera.BaseViewMatrix; // Create the light object. Light = new DLight(); // Initialize the light object. Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); Light.Direction = new Vector3(0.5f, -0.75f, 0.25f); // Create the model object. TerrainModel = new DTerrainHeightMap(); // Initialize the terrain object. if (!TerrainModel.Initialize(D3D.Device, "hm.bmp", "cm.bmp", 20.0f, "dirt04.bmp", "normal01.bmp")) { 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 sky dome object. SkyDome = new DSkyDome(); // Initialize the sky dome object. if (!SkyDome.Initialize(D3D.Device)) { return(false); } // Create the sky dome shader object. SkyDomeShader = new DSkyDomeShader(); // Initialize the sky dome shader object. if (!SkyDomeShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the sky plane object. SkyPlane = new DSkyPlane(); // Initialize the sky plane object. if (!SkyPlane.Initialze(D3D.Device, "cloud001.bmp", "perturb001.bmp")) { return(false); } // Create the sky plane shader object. SkyPlaneShader = new DSkyPlaneShader(); // Initialize the sky plane shader object. if (!SkyPlaneShader.Initialize(D3D.Device, windowHandle)) { return(false); } // 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 refraction render to texture object. RefractionTexture = new DRenderTexture(); // Initialize the refraction render to texture object. if (!RefractionTexture.Initialize(D3D.Device, configuration)) { return(false); } // Create the reflection render to texture object. ReflectionTexture = new DRenderTexture(); // Initialize the reflection render to texture object. if (!ReflectionTexture.Initialize(D3D.Device, configuration)) { return(false); } // Create the reflection shader object. ReflectionShader = new DReflectionShader(); // Initialize the reflection shader object. if (!ReflectionShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the water object. WaterModel = new DWater(); // Initialize the water object. if (!WaterModel.Initilize(D3D.Device, "waternormal.bmp", 3.75f, 110.0f)) { return(false); } // Create the water shader object. WaterShader = new DWaterShader(); // Initialize the water shader object. if (!WaterShader.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. 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(); // Set the initial position of the camera and build the matrices needed for rendering. Camera.SetPosition(0.0f, 0.0f, -10.0f); Camera.Render(); Camera.RenderBaseViewMatrix(); // This might be mis-implemented. CHECK THIS !!! // Create the light object. Light = new DLight(); // Initialize the light object. Light.Direction = new Vector3(0.0f, 0.0f, 1.0f); // Create the model object. Model = new DModel(); // Initialize the ground model object. if (!Model.Initialize(D3D.Device, "cube.txt", "seafloor.bmp")) { 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); } // Create the deferred buffers object. DeferredBuffers = new DDeferredBuffers(); // Initialize the deferred buffers object. if (!DeferredBuffers.Initialize(D3D.Device, configuration.Width, configuration.Height)) { return(false); } // Create the deferred shader object. DeferredShader = new DDeferredShader(); // Initialize the deferred shader object. if (!DeferredShader.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); } 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, -10.0f); Camera.RenderBaseViewMatrix(); #endregion #region Initialize Models // Create the cube model object. CubeModel = new DModel(); // Initialize the cube model object. if (!CubeModel.Initialize(D3D.Device, "cube.txt", "wall01.bmp")) { return(false); } // Set the position for the cube model. CubeModel.SetPosition(-2.0f, 2.0f, 0.0f); // Create the sphere model object. SphereModel = new DModel(); // Initialize the sphere model object. if (!SphereModel.Initialize(D3D.Device, "sphere.txt", "ice01.bmp")) { return(false); } // Set the position for the sphere model. SphereModel.SetPosition(2.0f, 2.0f, 0.0f); // Create the ground model object. GroundModel = new DModel(); // Initialize the ground model object. if (!GroundModel.Initialize(D3D.Device, "plane01.txt", "metal001.bmp")) { return(false); } // Set the position for the ground model. GroundModel.SetPosition(0.0f, 1.0f, 0.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.SetLookAt(0.0f, 0.0f, 0.0f); Light.GenerateProjectionMatrix(); // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. if (!RenderTexture.Initialize(D3D.Device, 1024, 1024, DSystemConfiguration.ScreenDepth, DSystemConfiguration.ScreenNear)) { return(false); } // Create the depth shader object. DepthShader = new DDepthShader(); // Initialize the depth shader object. if (!DepthShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the black and white render to texture object. BlackWhiteRenderTexture = new DRenderTexture(); // Initialize the black and white render to texture object. if (!BlackWhiteRenderTexture.Initialize(D3D.Device, 1024, 1024, DSystemConfiguration.ScreenDepth, DSystemConfiguration.ScreenNear)) { return(false); } #endregion #region Initialize Shaders // Create the shadow shader object. ShadowShader = new DShadowShader(); // Initialize the shadow shader object. if (!ShadowShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Set the size to sample down to. int downSampleWidth = 1024 / 2; int downSampleHeight = 1024 / 2; // Create the down sample render to texture object. DownSampleTexure = new DRenderTexture(); // Initialize the down sample render to texture object. if (!DownSampleTexure.Initialize(D3D.Device, downSampleWidth, downSampleHeight, DSystemConfiguration.ScreenDepth, DSystemConfiguration.ScreenNear)) { return(false); } // Create the small ortho window object. SmallWindow = new DOrthoWindow(); // Initialize the small ortho window object. if (!SmallWindow.Initialize(D3D.Device, downSampleWidth, downSampleHeight)) { 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 horizontal blur render to texture object. HorizontalBlurTexture = new DRenderTexture(); // Initialize the horizontal blur render to texture object. if (!HorizontalBlurTexture.Initialize(D3D.Device, downSampleWidth, downSampleHeight, DSystemConfiguration.ScreenDepth, 0.1f)) { 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 render to texture object. VerticalBlurTexture = new DRenderTexture(); // Initialize the vertical blur render to texture object. if (!VerticalBlurTexture.Initialize(D3D.Device, downSampleWidth, downSampleHeight, DSystemConfiguration.ScreenDepth, 0.1f)) { 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 up sample render to texture object. UpSampleTexure = new DRenderTexture(); // Initialize the up sample render to texture object. if (!UpSampleTexure.Initialize(D3D.Device, 1024, 1024, DSystemConfiguration.ScreenDepth, 0.1f)) { return(false); } // Create the full screen ortho window object. FullScreenWindow = new DOrthoWindow(); // Initialize the full screen ortho window object. if (!FullScreenWindow.Initialize(D3D.Device, 1024, 1024)) { return(false); } // Create the soft shadow shader object. SoftShadowShader = new DSoftShadowShader(); // Initialize the soft shadow shader object. if (!SoftShadowShader.Initialize(D3D.Device, windowHandle)) { 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 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(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); } }