示例#1
0
        public TransformationController(IMainShell windows)
        {
            this.windows = windows;

            translation = new TranslationGlyp(new Rectangle(0, 0, 128, 128))
            {
                Visible      = false,
                Alpha        = 0.7f,
                EnablePlanes = true,
                Width        = 5
            }.Initialize() as TranslationGlyp;

            rotation = new RotationGlyp(new Rectangle(0, 0, 128, 128))
            {
                MarkersAlpha = 0.8f,
                SphereColor  = new Color4(Color3.FromArgb(System.Drawing.Color.Yellow.ToArgb()), 0.5f),
                Thickness    = 1,
                Visible      = false
            };
            rotation.Initialize();

            scale = new ScaleGlyp()
            {
                Visible = false
            };

            Engine.Scene.Decals.Add(translation);
            Engine.Scene.Decals.Add(rotation);
            Engine.Scene.Decals.Add(scale);

            Engine.UpdateFrame += UpdateGlyps;
        }
        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));
        }