Example #1
0
        private bool LoadTexture(SharpDX.Direct3D11.Device device, string textureFileName, string glowMapFileName)
        {
            textureFileName = DSystemConfiguration.DataFilePath + textureFileName;
            glowMapFileName = DSystemConfiguration.DataFilePath + glowMapFileName;

            // Create the texture object.
            Texture = new DTexture();

            // Initialize the texture object.
            if (!Texture.Initialize(device, textureFileName))
            {
                return(false);
            }

            // Create the glow map texture object.
            GlowMapTexture = new DTexture();

            // Initialize the glow map texture object.
            if (!GlowMapTexture.Initialize(device, glowMapFileName))
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        private bool LoadTextures(SharpDX.Direct3D11.Device device, string trunkFilename, string leafFilename)
        {
            trunkFilename = DSystemConfiguration.DataFilePath + @"Trees\" + trunkFilename;
            leafFilename  = DSystemConfiguration.DataFilePath + @"Trees\" + leafFilename;

            // Create the trunk texture object.
            TrunkTexture = new DTexture();

            // Initialize the texture object.
            if (!TrunkTexture.Initialize(device, trunkFilename))
            {
                return(false);
            }

            // Create the leaf texture object.
            LeafTexture = new DTexture();

            // Initialize the leaf texture object.
            if (!LeafTexture.Initialize(device, leafFilename))
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        private bool LoadTexture(SharpDX.Direct3D11.Device device, string textureFileName)
        {
            textureFileName = DSystemConfiguration.DataFilePath + textureFileName;

            // Create the texture object.
            Texture = new DTexture();

            // Initialize the texture object.
            Texture.Initialize(device, textureFileName);

            return(true);
        }
Example #4
0
        private bool LoadTexture(Device device, string textureFileName)
        {
            textureFileName = DSystemConfiguration.FontFilePath + textureFileName;

            // Create new texture object.
            Texture = new DTexture();

            // Initialize the texture object.
            if (!Texture.Initialize(device, textureFileName))
            {
                return(false);
            }

            return(true);
        }
        private bool LoadTextures(SharpDX.Direct3D11.Device device, string colorTextureFileName, string normalMapTextureFileName)
        {
            colorTextureFileName     = DSystemConfiguration.DataFilePath + colorTextureFileName;
            normalMapTextureFileName = DSystemConfiguration.DataFilePath + normalMapTextureFileName;

            // Create the color texture object.
            ColorTexture = new DTexture();

            // Initialize the color texture object.
            if (!ColorTexture.Initialize(device, colorTextureFileName))
            {
                return(false);
            }

            // Create the normal map texture object.
            NormalMapTexture = new DTexture();

            // Initialize the normal map texture object.
            if (!NormalMapTexture.Initialize(device, normalMapTextureFileName))
            {
                return(false);
            }
            return(true);
        }
        // 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 and rotation of the camera.
                Camera.SetPosition(0.0f, 7.0f, -10.0f);
                Camera.SetRotation(35.0f, 0.0f, 0.0f);
                #endregion

                #region Initialize Models
                // Create the ground model object.
                GroundModel = new DModel();

                // Initialize the ground model object.
                if (!GroundModel.Initialize(D3D.Device, "floor.txt", "stone.bmp"))
                {
                    return(false);
                }

                // Create the ground model object.
                CubeModel = new DModel();

                // Initialize the cube model object.
                if (!CubeModel.Initialize(D3D.Device, "cube.txt", "seafloor.bmp"))
                {
                    return(false);
                }
                #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.Position = new Vector3(2.0f, 5.0f, -2.0f);
                #endregion

                #region Initialize Shaders
                // Create the projection shader object.
                ProjectionShader = new DProjectionShader();

                // Initialize the projection shader object.
                if (!ProjectionShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the projection texture object.
                ProjectionTexture = new DTexture();

                // Initialize the projection texture object.
                if (!ProjectionTexture.Initialize(D3D.Device, DSystemConfiguration.DataFilePath + "grate.bmp"))
                {
                    return(false);
                }

                // Create the view point object.
                ViewPoint = new DViewPoint();

                // Initialize the view point object.
                ViewPoint.SetPosition(2.0f, 5.0f, -2.0f);
                ViewPoint.SetLookAt(0.0f, 0.0f, 0.0f);
                ViewPoint.SetProjectionParameters((float)(Math.PI / 2.0f), 1.0f, 0.1f, 100.0f);
                ViewPoint.GenerateViewMatrix();
                ViewPoint.GenerateProjectionMatrix();
                #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 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);
            }
        }