private void SetupTerrainComponents(Viewport vp, Rectangle settingsPanelArea)
        {
            int sliderHeight = (int)(0.05f * vp.Height);

            ControlMat mat = new ControlMat(settingsPanelArea, 7, 1, 10);

            Slider scaleX = new Slider("Length Scale", mat.Spaces[0], 0.1f, 10.0f);
            scaleX.SetValue(bs.ScaleX);
            scaleX.Use += delegate(float v) { bs.ScaleX = v; };
            controls.Add(scaleX);

            Slider scaleY = new Slider("Height Scale", mat.Spaces[1], 0.1f, 10.0f);
            scaleY.SetValue(bs.ScaleY);
            scaleY.Use += delegate(float v) { bs.ScaleY = v; };
            controls.Add(scaleY);

            Slider scaleZ = new Slider("Width Scale", mat.Spaces[2], 0.1f, 10.0f);
            scaleZ.SetValue(bs.ScaleZ);
            scaleZ.Use += delegate(float v) { bs.ScaleZ = v; };
            controls.Add(scaleZ);

            Slider vegetationDensity = new Slider("Vegetation", mat.Spaces[3], 0.0f, 1.0f);
            vegetationDensity.SetValue(bs.VegDensity);
            vegetationDensity.Use += delegate(float v) { bs.VegDensity = v; };
            controls.Add(vegetationDensity);

            Slider treeDensity = new Slider("Trees", mat.Spaces[4], 0.0f, 1.0f);
            treeDensity.SetValue(bs.TreeDensity);
            treeDensity.Use += delegate(float v) { bs.TreeDensity = v; };
            controls.Add(treeDensity);

            Slider smoothing = new Slider("Smoothing", mat.Spaces[5], 0, 50);
            smoothing.SetValue(bs.Smoothing);
            smoothing.Use += delegate(float v) { bs.Smoothing = (int)v; };
            controls.Add(smoothing);

            Spinner<Climate> cSpin = new Spinner<Climate>("Climate", mat.Spaces[6]);
            cSpin.Use += delegate() { bs.Climate = cSpin.GetSelected().ToString(); };
            foreach (Climate climate in Enum.GetValues(typeof(Climate)))
                cSpin.Add(climate);
            cSpin.Select((Climate)Enum.Parse(typeof(Climate), bs.Climate));
            controls.Add(cSpin);

            int y = (int)(vp.Height * 0.05f);
            controls.Add(new Label("Setup", new Rectangle(0, y / 2, vp.Width, y * 2), Label.Fit.AlignCenter));
        }
        private void SetupAC(Viewport vp)
        {
            Rectangle area = new Rectangle(0, 0, vp.Width / 3, vp.Height / 3);
            ControlMat mat = new ControlMat(area, 10, 1, 2, ControlMat.FillOrder.RowsFirst);
            Label selectionLabel = new Label("Selected Target", mat.Spaces[0], Label.Fit.AlignLeft);
            Label nameLabel = new Label("Name: ", mat.Spaces[1], Label.Fit.AlignLeft);
            Label positionLabel = new Label("Position: ", mat.Spaces[2], Label.Fit.AlignLeft);
            Label infoLabel = new Label("Info: ", mat.Spaces[3], Label.Fit.AlignLeft);

            SelectionInfoChanged += delegate(object src, EventArgs e)
            {
                nameLabel.Text = src == null ? "Name:" : "Name: " + selected.Name;
                positionLabel.Text = src == null ? "Position:" : "Position: " + selected.Position;
                infoLabel.Text = src == null ? "Info:" : "Info: " + selected.Info;
            };

            Slider separationSlider = new Slider("Separation", mat.Spaces[4], 0.0f, 1.0f);
            Slider cohesionSlider = new Slider("Cohesion", mat.Spaces[5], 0.0f, 1.0f);
            Slider wanderSlider = new Slider("Wander", mat.Spaces[6], 0.0f, 1.0f);
            Slider alignmentSlider = new Slider("Alignment", mat.Spaces[7], 0.0f, 1.0f);
            //alignmentSlider.Use += delegate(float v) { world.Wildlife.ApplySteerParameters(

            ac.Add(selectionLabel);
            ac.Add(nameLabel);
            ac.Add(positionLabel);
            ac.Add(infoLabel);
            ac.Disable(manager.UI);
        }
        private void SetupCC(Viewport vp)
        {
            Camera c = manager.UI.Camera;
            Rectangle ccArea = new Rectangle(0, 0, (int)(vp.Width * 0.5f), vp.Height / 3);
            ControlMat ccSpace = new ControlMat(ccArea, 7, 1, 2, ControlMat.FillOrder.RowsFirst);

            cc.Add(new Label("Camera Options", ccSpace.Spaces[0], Label.Fit.AlignCenter));

            Spinner<Camera.Mode> mode = new Spinner<Camera.Mode>("Mode", ccSpace.Spaces[1]);
            foreach (Camera.Mode cMode in Enum.GetValues(typeof(Camera.Mode)))
                mode.Add(cMode);
            mode.Use += delegate() { manager.UI.Camera.SetMode(mode.GetSelected()); };
            c.Changed += delegate(object src, EventArgs e) { mode.Select(c.CurrentMode); };
            cc.Add(mode);

            Slider transSpeed = new Slider("TSpeed", ccSpace.Spaces[2], 0.1f, 5.0f);
            transSpeed.SetValue(manager.UI.Camera.TranslateSpeed);
            transSpeed.Use += delegate(float v) { manager.UI.Camera.TranslateSpeed = v; };
            c.Changed += delegate(object src, EventArgs e) { transSpeed.SetValue(c.TranslateSpeed); };
            cc.Add(transSpeed);

            Slider rotSpeed = new Slider("RSpeed", ccSpace.Spaces[3], 0.02f, 0.1f);
            rotSpeed.SetValue(manager.UI.Camera.RotateSpeed);
            rotSpeed.Use += delegate(float v) { manager.UI.Camera.RotateSpeed = v; };
            c.Changed += delegate(object src, EventArgs e) { rotSpeed.SetValue(c.RotateSpeed); };
            cc.Add(rotSpeed);

            Label posInfo = new Label("Position: " + manager.UI.Camera.Position, ccSpace.Spaces[4], Label.Fit.AlignCenter);
            cc.Add(posInfo);

            Label rotInfo = new Label("Rotation: " + manager.UI.Camera.Rotation, ccSpace.Spaces[5], Label.Fit.AlignLeft);
            cc.Add(rotInfo);

            c.Changed += delegate(object src, EventArgs e)
            {
                posInfo.SetText("Position: " + c.Position, Label.Fit.AlignLeft);
                rotInfo.SetText("Rotation: " + c.Rotation, Label.Fit.AlignLeft);
            };

            cc.Disable(manager.UI);
        }
        private void SetupWC(Viewport vp)
        {
            wc.Clear();
            Sim.Environment.World world = manager.UI.Sim.World;
            wc.Disable(manager.UI);
            Rectangle wcArea = new Rectangle(0, 0, vp.Width / 2, vp.Height / 3);
            ControlMat wcSpace = new ControlMat(wcArea, 7, 1, 2, ControlMat.FillOrder.RowsFirst);
            int i = 0;

            wc.Add(new Label("Weather Options", wcSpace.Spaces[i++], Label.Fit.AlignCenter));

            ToggleButton rain = new ToggleButton("Active", wcSpace.Spaces[i++]);
            rain.Use += delegate() { world.Weather.Active = !world.Weather.Active; };
            wc.Add(rain);

            Slider turbSlider = new Slider("Turbulence", wcSpace.Spaces[i++], 0, 30);
            turbSlider.SetValue(Sim.Settings.Graphics.Default.WindTurbulence);
            turbSlider.Use += delegate(float v) { Sim.Settings.Graphics.Default.WindTurbulence = v; };
            wc.Add(turbSlider);

            Slider windX = new Slider("Wind X", wcSpace.Spaces[i++], -75.0f, 75.0f);
            windX.SetValue(Sim.Settings.Graphics.Default.WindX);
            windX.Use += delegate(float v) { Sim.Settings.Graphics.Default.WindX = v; };
            wc.Add(windX);

            Slider windZ = new Slider("Wind Z", wcSpace.Spaces[i++], -75.0f, 75.0f);
            windZ.SetValue(Sim.Settings.Graphics.Default.WindZ);
            windZ.Use += delegate(float v) { Sim.Settings.Graphics.Default.WindZ = v; };
            wc.Add(windZ);

            Slider overcast = new Slider("Overcast", wcSpace.Spaces[i++], 1, 5);
            overcast.SetValue(Sim.Settings.Graphics.Default.Overcast);
            overcast.Use += delegate(float v) { Sim.Settings.Graphics.Default.Overcast = v; Shaders.Common.Parameters["overcast"].SetValue(v); };
            wc.Add(overcast);
        }
        private void SetupGC(Viewport vp)
        {
            gc.Clear();

            
            Sim.Environment.World world = manager.UI.Sim.World;
            Rectangle gcArea = new Rectangle(0, 0, vp.Width / 3, (int)(vp.Height / 1.5f));
            ControlMat gcSpace = new ControlMat(gcArea, 16, 1, 2, ControlMat.FillOrder.RowsFirst);
            int i = 0;

            gc.Add(new Label("Drawing Options", gcSpace.Spaces[i++], Label.Fit.AlignCenter));

            Spinner<FillMode> gcFillSpinner = new Spinner<FillMode>("Fill Mode", gcSpace.Spaces[i++]);
            gcFillSpinner.Add(FillMode.Solid);
            gcFillSpinner.Add(FillMode.WireFrame);
            gcFillSpinner.Add(FillMode.Point);
            gcFillSpinner.Use += delegate() { world.FillMode = gcFillSpinner.GetSelected(); };
            gc.Add(gcFillSpinner);
            gc.Disable(manager.UI);

            Sim.Settings.Graphics gs = Sim.Settings.Graphics.Default;

            gc.Add(new Button("Sky", gcSpace.Spaces[i++], delegate() { world.Sky.Visible = !world.Sky.Visible; }));
            gc.Add(new Button("Terrain", gcSpace.Spaces[i++], delegate() { world.Terrain.Visible = !world.Terrain.Visible; }));
            gc.Add(new Button("Water", gcSpace.Spaces[i++], delegate() { world.Water.Visible = !world.Water.Visible; }));
            gc.Add(new Button("Axes", gcSpace.Spaces[i++], delegate() { world.DrawAxes = !world.DrawAxes; }));
            gc.Add(new Button("Vegetation", gcSpace.Spaces[i++], delegate() { world.Vegetation.Visible = !world.Vegetation.Visible; }));
            gc.Add(new Button("AI Nodes", gcSpace.Spaces[i++], delegate() { world.Terrain.DrawNodes = !world.Terrain.DrawNodes; }));
            gc.Add(new Button("Terrain Normals", gcSpace.Spaces[i++], delegate() { world.Terrain.DrawNormals = !world.Terrain.DrawNormals; }));
            gc.Add(new Button("Detail Texturing", gcSpace.Spaces[i++], delegate() { 
                gs.TerrainDetail = !gs.TerrainDetail; 
                world.Terrain.Effect.Parameters["bDetailEnabled"].SetValue(gs.TerrainDetail); }));
            gc.Add(new Button("Bump Mapping", gcSpace.Spaces[i++], delegate() { 
                gs.BumpEnabled = !gs.BumpEnabled;
                world.Terrain.Effect.Parameters["bBumpEnabled"].SetValue(gs.BumpEnabled);}));
            gc.Add(new Button("Shadow Mapping", gcSpace.Spaces[i++], delegate() {
                gs.ShadowsEnabled = !gs.ShadowsEnabled;
                Shaders.Common.Parameters["bShadowsEnabled"].SetValue(gs.ShadowsEnabled);}));
            gc.Add(new Button("Bloom", gcSpace.Spaces[i++], delegate()
            {
                gs.BloomEnabled = !gs.BloomEnabled;
            }));

            Slider biSlider = new Slider("Bloom Intes.", gcSpace.Spaces[i++],0,10);
            biSlider.SetValue(1.25f);
            biSlider.Use += delegate(float v) { manager.UI.Sim.PostProcessManager.Bloom.SetIntensity(v);};
            gc.Add(biSlider);

            Slider btSlider = new Slider("Bloom Thres.", gcSpace.Spaces[i++], 0, 1);
            btSlider.SetValue(0.6f);
            btSlider.Use += delegate(float v) { manager.UI.Sim.PostProcessManager.Bloom.SetThreshold(v); };
            gc.Add(btSlider);

            Slider bbSlider = new Slider("Bloom Blur", gcSpace.Spaces[i++], 0, 20);
            bbSlider.SetValue(8);
            bbSlider.Use += delegate(float v) { manager.UI.Sim.PostProcessManager.Bloom.SetBlur(v); };
            gc.Add(bbSlider);
        }