コード例 #1
0
        private void CreateTerrain()
        {
            //Load the height map
            Texture2D heigthMap = Engine.Graphics.CreateTexture2DFromFile("terrain.png");

            //Create the HeightField using the heigth map ,divide the HeightField into and 8x8 grid of sections
            //this will improve culling
            HeightField heigthField = new HeightField(heigthMap, 32, 32);

            heigthField.Materials[0].Diffuse = Color3.FromArgb(System.Drawing.Color.DarkGreen.ToArgb());

            //Uncomment this to texture the terrain
            heigthField.Materials[0].DiffuseMaps = new Texture2D[]
            {
                Engine.Graphics.CreateTexture2DFromFile("grass.jpg")
            };

            //smoot the height field using a 5x5 gaussian kernel with 4 pass
            heigthField.Smoot(5, 4);

            //Create the HeightField node translat it to the center of the scene, then scaling it to 1000 units in X and Z
            Engine.Scene.Create("HeightFieldNode", heigthField,
                                Igneel.Matrix.Translate(-0.5f, 0, -0.5f) *
                                Igneel.Matrix.Scale(1000, 100, 1000));
        }