Beispiel #1
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Components.Joint joint   = entity.GetOrCreate <Components.Joint>("Joint");
            Spinner          spinner = entity.GetOrCreate <Spinner>("Spinner");

            spinner.Add(new Binding <Direction>(spinner.Direction, joint.Direction));

            JointFactory.Bind(entity, main, spinner.CreateJoint, true, creating);
            DynamicVoxel voxel = entity.Get <DynamicVoxel>();

            voxel.KineticFriction.Value = voxel.StaticFriction.Value = 0;

            entity.Add("On", spinner.On);
            entity.Add("Off", spinner.Off);
            entity.Add("Forward", spinner.Forward);
            entity.Add("Backward", spinner.Backward);
            entity.Add("HitMax", spinner.HitMax);
            entity.Add("HitMin", spinner.HitMin);

            entity.Add("Direction", joint.Direction);
            entity.Add("Minimum", spinner.Minimum);
            entity.Add("Maximum", spinner.Maximum);
            entity.Add("Locked", spinner.Locked);
            entity.Add("Speed", spinner.Speed);
            entity.Add("Goal", spinner.Goal);
            entity.Add("Servo", spinner.Servo);
            entity.Add("CannotSuspendByDistance", entity.Get <DynamicVoxel>().CannotSuspendByDistance);
        }
Beispiel #2
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Components.Joint joint   = entity.GetOrCreate <Components.Joint>("Joint");
            Spinner          spinner = entity.GetOrCreate <Spinner>("Spinner");

            spinner.Add(new Binding <Direction>(spinner.Direction, joint.Direction));

            JointFactory.Bind(entity, main, spinner.CreateJoint, true, creating);
            DynamicVoxel voxel = entity.Get <DynamicVoxel>();

            voxel.KineticFriction.Value = voxel.StaticFriction.Value = 0;

            if (main.EditorEnabled)
            {
                spinner.Add(new Binding <Quaternion, Matrix>(spinner.OriginalRotation, x => Quaternion.CreateFromRotationMatrix(x), voxel.Transform));
            }

            entity.Add("Forward", spinner.Forward);
            entity.Add("Backward", spinner.Backward);
            entity.Add("HitMax", spinner.HitMax);
            entity.Add("HitMin", spinner.HitMin);
            entity.Add("MovementLoop", spinner.MovementLoop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });
            entity.Add("MovementStop", spinner.MovementStop, new PropertyEntry.EditorData {
                Options = WwisePicker.Get(main)
            });

            entity.Add("Direction", joint.Direction);
            entity.Add("Minimum", spinner.Minimum);
            entity.Add("Maximum", spinner.Maximum);
            entity.Add("Locked", spinner.Locked);
            entity.Add("Speed", spinner.Speed);
            entity.Add("Goal", spinner.Goal);
            entity.Add("Servo", spinner.Servo);
            entity.Add("CannotSuspendByDistance", entity.Get <DynamicVoxel>().CannotSuspendByDistance);
        }
        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 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);
        }
        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));
        }