示例#1
0
        public bool update(TgcTerrainEditor editor)
        {
            var changes = false;

            if (Enabled)
            {
                if (editor.Input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT))
                {
                    reproduceSound();
                    var invert = editor.Input.keyDown(Key.LeftAlt);

                    var oldInvert = Invert;
                    Invert ^= invert;
                    if (!Editing)
                    {
                        beginEdition(editor.Terrain);
                    }
                    if (editTerrain(editor.ElapsedTime))
                    {
                        changes = true;
                        terrain.updateVertices();
                    }
                    Invert = oldInvert;
                }
                else if (Editing)
                {
                    endEdition();
                }
            }
            if (changes)
            {
                editor.updateVegetationY();
            }
            return(changes);
        }
示例#2
0
        public bool update(TgcTerrainEditor editor)
        {
            bool changes = false;

            if (Enabled)
            {
                if (GuiController.Instance.D3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT))
                {
                    reproduceSound();
                    bool invert = GuiController.Instance.D3dInput.keyDown(Microsoft.DirectX.DirectInput.Key.LeftAlt);

                    bool oldInvert = Invert;
                    Invert ^= invert;
                    if (!Editing)
                    {
                        beginEdition(editor.Terrain);
                    }
                    if (editTerrain())
                    {
                        changes = true;
                        terrain.updateVertices();
                    }
                    Invert = oldInvert;
                }
                else if (Editing)
                {
                    endEdition();
                }
            }
            if (changes)
            {
                editor.updateVegetationY();
            }
            return(changes);
        }
示例#3
0
        public TerrainEditorModifier AddTerrainEditorModifier(TgcTerrainEditor tool)
        {
            var modifier = new TerrainEditorModifier(tool);

            AddModifier(modifier);
            return(modifier);
        }
示例#4
0
        public bool mouseMove(TgcTerrainEditor editor)
        {
            TGCVector3 pos;

            Enabled  = editor.mousePositionInTerrain(out pos);
            Position = pos;
            return(false);
        }
示例#5
0
 public Shovel(TgcTerrainEditor editor) : base(editor)
 {
     Color1       = Color.Aqua;
     Color2       = Color.Red;
     text.Color   = Color1;
     bBrush.Color = Color1;
     bBrush.updateValues();
 }
示例#6
0
 public Steamroller(TgcTerrainEditor editor) : base(editor)
 {
     Color1       = Color.LightGoldenrodYellow;
     Color2       = Color.Purple;
     text.Color   = Color1;
     bBrush.Color = Color1;
     bBrush.updateValues();
 }
示例#7
0
 public void render(TgcTerrainEditor editor)
 {
     editor.doRender();
     if (Enabled)
     {
         renderFloatingVegetation();
     }
 }
示例#8
0
 protected virtual void addVegetation(TgcTerrainEditor editor)
 {
     editor.addVegetation(Mesh);
     if (SoundEnabled)
     {
         playSound();
     }
     Mesh = null;
 }
示例#9
0
 public override bool mouseMove(TgcTerrainEditor editor)
 {
     if (Mesh == null) 
         Mesh = InstancesManager.Instance.newMeshInstanceOf(vegetationName);
     Vector3 pos = Position;
     base.mouseMove(editor);
     if (pos == Position) Enabled = false;
     return false;
 }
示例#10
0
 public bool mouseLeave(TgcTerrainEditor editor)
 {
     Enabled = false;
     if (Editing)
     {
         endEdition();
     }
     return(false);
 }
示例#11
0
 public void render(TgcTerrainEditor editor)
 {
     if (Enabled)
     {
         configureTerrainEffect(editor.Terrain);
         bBrush.Render();
     }
     renderText();
     editor.doRender();
 }
示例#12
0
        protected override void addVegetation(TgcTerrainEditor editor)
        {
            Vector3 scale = Mesh.Scale;
            Vector3 rotation = Mesh.Rotation;
            base.addVegetation(editor);

            Mesh = InstancesManager.Instance.newMeshInstanceOf(vegetationName);
            Mesh.Scale = scale;
            Mesh.Rotation = rotation;
            Mesh.Position = Position;
        }
示例#13
0
        public TerrainBrush(TgcTerrainEditor editor)
        {
            SoundEnabled = true;
            text         = new TgcText2D();
            text.Align   = TgcText2D.TextAlign.RIGHT;
            text.changeFont(new Font("Arial", 12, FontStyle.Bold));

            bBrush = TGCBox.fromSize(new TGCVector3(10, 100, 10));
            sound  = new TgcStaticSound();
            sound.loadSound(editor.MediaDir + "Sound\\tierra.wav", editor.DirectSound.DsDevice);
        }
示例#14
0
        protected override void addVegetation(TgcTerrainEditor editor)
        {
            var scale    = Mesh.Scale;
            var rotation = Mesh.Rotation;

            base.addVegetation(editor);

            Mesh          = InstancesManager.Instance.newMeshInstanceOf(vegetationName);
            Mesh.Scale    = scale;
            Mesh.Rotation = rotation;
            Mesh.Position = Position;
        }
示例#15
0
        public VegetationPicker(TgcTerrainEditor editor)
        {
            label       = new TgcText2D();
            label.Color = Color.Yellow;
            label.Align = TgcText2D.TextAlign.LEFT;
            font        = new Font("Arial", 12, FontStyle.Bold);
            label.changeFont(font);

            Rotation     = RotationAxis.Y;
            SoundEnabled = true;
            sound        = new TgcStaticSound();
            sound.loadSound(editor.MediaDir + "Sound\\pisada arena dcha.wav", -2000, editor.DirectSound.DsDevice);
        }
示例#16
0
        public override bool mouseMove(TgcTerrainEditor editor)
        {
            if (Mesh == null)
            {
                Mesh = InstancesManager.Instance.newMeshInstanceOf(vegetationName);
            }
            var pos = Position;

            base.mouseMove(editor);
            if (pos == Position)
            {
                Enabled = false;
            }
            return(false);
        }
示例#17
0
        private void setLabelPosition(TgcTerrainEditor editor)
        {
            label.Text = string.Format("\"{0}\"( {1} ; {2} ; {3} )", Mesh.Name, Mesh.Position.X, Mesh.Position.Y,
                                       Mesh.Position.Z);
            SizeF nameSize;

            using (var g = ToolsModel.Instance.Panel3d.CreateGraphics())
            {
                nameSize = g.MeasureString(label.Text, font);
            }

            label.Size     = nameSize.ToSize();
            label.Position = new Point((int)(editor.Input.Xpos - nameSize.Width / 2),
                                       (int)(editor.Input.Ypos + nameSize.Height + 5));
        }
示例#18
0
        public virtual bool mouseMove(TgcTerrainEditor editor)
        {
            Vector3 pos;
            Enabled = true;
            if (Mesh != null)
            {
                if (editor.mousePositionInTerrain(out pos))
                {
                    Position = pos;
                    Mesh.Position = pos;

                    setLabelPosition();
                }
            }
           
            return false;
        }
示例#19
0
        public virtual bool update(TgcTerrainEditor editor)
        {
            bool changes = false;

            if (Enabled)
            {
                if (Mesh != null)
                {
                    updateMeshScaleAndRotation();
                }

                if (GuiController.Instance.D3dInput.buttonPressed(TgcD3dInput.MouseButtons.BUTTON_LEFT))
                {
                    if (Mesh != null)
                    {
                        addVegetation(editor);
                        changes = true;
                    }
                    else
                    {
                        Mesh = pickVegetation(editor);
                        if (Mesh != null)
                        {
                            changes = true;
                            setLabelPosition();
                        }
                    }
                }

                if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Delete))
                {
                    removeFloatingVegetation();
                }

                if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Z))
                {
                    if (editor.HasVegetation)
                    {
                        removeFloatingVegetation();
                        Mesh = editor.vegetationPop();
                    }
                }
            }

            return(changes);
        }
示例#20
0
        public TerrainEditorControl(TgcTerrainEditor terrainEditor)
        {
            // TODO: Complete member initialization
            this.terrainEditor = terrainEditor;

            InitializeComponent();
            //Tab General
            createHeightmapBrowser();

            pictureBoxModifyHeightmap.ImageLocation = heightmapBrowser.SelectedImage;

            textureBrowser = new TgcTextureBrowser();
            textureBrowser.ShowFolders = true;
            textureBrowser.setSelectedImage(GuiController.Instance.ExamplesMediaDir + "Heighmaps\\" + "TerrainTexture1-256x256.jpg");
            pictureBoxModifyTexture.ImageLocation = textureBrowser.SelectedImage;
            terrainEditor.Terrain.loadHeightmap(heightmapBrowser.SelectedImage, (float)nudScaleXZ.Value, (float)nudScaleY.Value, new Microsoft.DirectX.Vector3(0, 0, 0));
            terrainEditor.Terrain.loadTexture(textureBrowser.SelectedImage);
            
            shovel = new Shovel();
            vegetationBrush = new VegetationBrush();
            steamroller = new Steamroller();
            vegetationPicker = new VegetationPicker();

            //Tooltips
            toolTip1.SetToolTip(rbShovel, "Pala.\nAumenta la altura del terreno.\nShovel sound by adough1@freesound");
            toolTip1.SetToolTip(rbSteamroller, "Aplanadora.\nNivela el terreno\nSteamroller stock image by presterjohn1@deviantArt");
            toolTip1.SetToolTip(tbRadius, "Regula el tamaño del pincel");
            toolTip1.SetToolTip(tbIntensity, "Regula la intesidad del efecto del pincel");
            toolTip1.SetToolTip(tbHardness, "Regula el tamaño del radio interno.\nA medida que los vertices se alejan del radio interno, la intensidad disminuye.");
            toolTip1.SetToolTip(cbRounded, "Cuando se deselecciona, el pincel es cuadrado");
            toolTip1.SetToolTip(cbInvert, "Invierte el efecto del pincel.\n(La pala hunde, la aplanadora aumenta los desniveles)");
            toolTip1.SetToolTip(bChangeFolder, "La carpeta seleccionada debe contener carpetas con\nel mismo nombre que el -TgcScene.xml que llevan dentro.");
            
            //Camera
            terrainEditor.Camera.MovementSpeed = tbCameraMovementSpeed.Value;
            terrainEditor.Camera.JumpSpeed = tbCameraJumpSpeed.Value;
        

            //Info
            setInfo();
            folderBrowserDialog1.SelectedPath = InstancesManager.Location;

            //Vegetation
            fillVegetationList(InstancesManager.Location);
        }
示例#21
0
        private TgcMesh pickVegetation(TgcTerrainEditor editor)
        {
            TgcPickingRay ray = new TgcPickingRay();

            ray.updateRay();
            float   minT       = -1;
            TgcMesh closerMesh = null;

            foreach (TgcMesh v in editor.Vegetation)
            {
                Vector3 q;
                if (TgcCollisionUtils.intersectRayAABB(ray.Ray, v.BoundingBox, out q))
                {
                    float t = 0;
                    if (q != ray.Ray.Origin)
                    {
                        if (ray.Ray.Direction.X != 0)
                        {
                            t = (q.X - ray.Ray.Origin.X) / ray.Ray.Direction.X;
                        }
                        else if (ray.Ray.Direction.Y != 0)
                        {
                            t = (q.Y - ray.Ray.Origin.Y) / ray.Ray.Direction.Y;
                        }
                        else if (ray.Ray.Direction.Z != 0)
                        {
                            t = (q.Z - ray.Ray.Origin.Z) / ray.Ray.Direction.Z;
                        }
                    }

                    if (minT == -1 || t < minT)
                    {
                        minT       = t;
                        closerMesh = v;
                    }
                }
            }

            if (closerMesh != null)
            {
                editor.removeVegetation(closerMesh);
            }

            return(closerMesh);
        }
示例#22
0
        public TerrainEditorControl(TgcTerrainEditor terrainEditor)
        {
            // TODO: Complete member initialization
            this.terrainEditor = terrainEditor;

            InitializeComponent();
            //Tab General
            createHeightmapBrowser();

            pictureBoxModifyHeightmap.ImageLocation = heightmapBrowser.SelectedImage;

            textureBrowser             = new TgcTextureBrowser();
            textureBrowser.ShowFolders = true;
            textureBrowser.setSelectedImage(GuiController.Instance.ExamplesMediaDir + "Heighmaps\\" + "TerrainTexture1-256x256.jpg");
            pictureBoxModifyTexture.ImageLocation = textureBrowser.SelectedImage;
            terrainEditor.Terrain.loadHeightmap(heightmapBrowser.SelectedImage, (float)nudScaleXZ.Value, (float)nudScaleY.Value, new Microsoft.DirectX.Vector3(0, 0, 0));
            terrainEditor.Terrain.loadTexture(textureBrowser.SelectedImage);

            shovel           = new Shovel();
            vegetationBrush  = new VegetationBrush();
            steamroller      = new Steamroller();
            vegetationPicker = new VegetationPicker();

            //Tooltips
            toolTip1.SetToolTip(rbShovel, "Pala.\nAumenta la altura del terreno.\nShovel sound by adough1@freesound");
            toolTip1.SetToolTip(rbSteamroller, "Aplanadora.\nNivela el terreno\nSteamroller stock image by presterjohn1@deviantArt");
            toolTip1.SetToolTip(tbRadius, "Regula el tamaño del pincel");
            toolTip1.SetToolTip(tbIntensity, "Regula la intesidad del efecto del pincel");
            toolTip1.SetToolTip(tbHardness, "Regula el tamaño del radio interno.\nA medida que los vertices se alejan del radio interno, la intensidad disminuye.");
            toolTip1.SetToolTip(cbRounded, "Cuando se deselecciona, el pincel es cuadrado");
            toolTip1.SetToolTip(cbInvert, "Invierte el efecto del pincel.\n(La pala hunde, la aplanadora aumenta los desniveles)");
            toolTip1.SetToolTip(bChangeFolder, "La carpeta seleccionada debe contener carpetas con\nel mismo nombre que el -TgcScene.xml que llevan dentro.");

            //Camera
            terrainEditor.Camera.MovementSpeed = tbCameraMovementSpeed.Value;
            terrainEditor.Camera.JumpSpeed     = tbCameraJumpSpeed.Value;


            //Info
            setInfo();
            folderBrowserDialog1.SelectedPath = InstancesManager.Location;

            //Vegetation
            fillVegetationList(InstancesManager.Location);
        }
示例#23
0
        public virtual bool mouseMove(TgcTerrainEditor editor)
        {
            Vector3 pos;

            Enabled = true;
            if (Mesh != null)
            {
                if (editor.mousePositionInTerrain(out pos))
                {
                    Position      = pos;
                    Mesh.Position = pos;

                    setLabelPosition();
                }
            }

            return(false);
        }
示例#24
0
 private void updateMeshScaleAndRotation(TgcTerrainEditor editor)
 {
     if (editor.Input.keyDown(Key.J))
     {
         rotate(FastMath.ToRad(60 * editor.ElapsedTime));
     }
     else if (editor.Input.keyDown(Key.L))
     {
         rotate(FastMath.ToRad(-60 * editor.ElapsedTime));
     }
     else if (editor.Input.keyDown(Key.I))
     {
         Mesh.Scale += ScaleAxis * 1.5f * editor.ElapsedTime;
     }
     else if (editor.Input.keyDown(Key.K))
     {
         Mesh.Scale -= ScaleAxis * 1.5f * editor.ElapsedTime;
     }
 }
示例#25
0
 public bool mouseMove(TgcTerrainEditor editor)
 {
     Vector3 pos;
     Enabled = editor.mousePositionInTerrain(out pos);
     this.Position = pos;
     return false;
 }
示例#26
0
        protected virtual void addVegetation(TgcTerrainEditor editor)
        {

            editor.addVegetation(Mesh);
            if (SoundEnabled) playSound();
            Mesh = null;
          
        }
示例#27
0
        private TgcMesh pickVegetation(TgcTerrainEditor editor)
        {
            TgcPickingRay ray = new TgcPickingRay();
            ray.updateRay();
            float minT = -1;
            TgcMesh closerMesh = null;
            foreach (TgcMesh v in editor.Vegetation)
            {

                Vector3 q;
                if (TgcCollisionUtils.intersectRayAABB(ray.Ray, v.BoundingBox, out q))
                {
                    float t = 0;
                    if (q != ray.Ray.Origin)
                    {
                        if (ray.Ray.Direction.X != 0) t = (q.X - ray.Ray.Origin.X) / ray.Ray.Direction.X;
                        else if (ray.Ray.Direction.Y != 0) t = (q.Y - ray.Ray.Origin.Y) / ray.Ray.Direction.Y;
                        else if (ray.Ray.Direction.Z != 0) t = (q.Z - ray.Ray.Origin.Z) / ray.Ray.Direction.Z;
                    }

                    if (minT == -1 || t < minT)
                    {
                        minT = t;
                        closerMesh = v;
                    }

                }

            }

            if (closerMesh != null) editor.removeVegetation(closerMesh);

            return closerMesh;
        }
示例#28
0
 public void render(TgcTerrainEditor editor)
 {
     editor.doRender();
     if (Enabled) renderFloatingVegetation();
 }
示例#29
0
 public void render(TgcTerrainEditor editor)
 {
     if (Enabled)
     {
         configureTerrainEffect(editor.Terrain);
         bBrush.render();
     }
     renderText();
     editor.doRender();
 }
示例#30
0
 public VegetationBrush(TgcTerrainEditor editor) : base(editor)
 {
 }
示例#31
0
        public bool update(TgcTerrainEditor editor)
        {
            bool changes = false;
            if (Enabled)
            {
                if (GuiController.Instance.D3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT))
                {
                    reproduceSound();
                    bool invert = GuiController.Instance.D3dInput.keyDown(Microsoft.DirectX.DirectInput.Key.LeftAlt);

                    bool oldInvert = Invert;
                    Invert ^= invert;
                    if (!Editing)
                    {
                        beginEdition(editor.Terrain);
                    }
                    if (editTerrain())
                    {
                        changes = true;
                        terrain.updateVertices();

                    }
                    Invert = oldInvert;
                }
                else if (Editing) endEdition();

            }
            if (changes) editor.updateVegetationY();
            return changes;
        }
 public TerrainEditorModifier(string varName, TgcTerrainEditor creator)
     : base(varName)
 {
     control = new TerrainEditorControl(creator);
     contentPanel.Controls.Add(control);
 }
示例#33
0
 public TerrainEditorModifier(string varName, TgcTerrainEditor creator)
     : base(varName)
 {
     control = new TerrainEditorControl(creator);
     contentPanel.Controls.Add(control);
 }
示例#34
0
 public bool mouseLeave(TgcTerrainEditor editor)
 {
     this.Enabled = false;
     return false;
 }
示例#35
0
 public bool mouseLeave(TgcTerrainEditor editor)
 {
     this.Enabled = false;
     return(false);
 }
示例#36
0
        public virtual bool update(TgcTerrainEditor editor)
        {
            bool changes = false;
            if (Enabled)
            {

                if (Mesh != null) updateMeshScaleAndRotation();

                if (GuiController.Instance.D3dInput.buttonPressed(TgcD3dInput.MouseButtons.BUTTON_LEFT))
                {
                    if (Mesh != null)
                    {
                        addVegetation(editor);
                        changes = true;
                    }
                    else
                    {
                        Mesh = pickVegetation(editor);
                        if (Mesh != null)
                        {
                            changes = true;
                            setLabelPosition();

                        }
                    }
                }

                if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Delete))
                {
                    removeFloatingVegetation();
                }

                if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Z))
                {
                    if (editor.HasVegetation)
                    {
                        removeFloatingVegetation();
                        Mesh = editor.vegetationPop();
                    }
                }
            }

            return changes;
        }
示例#37
0
 public bool mouseLeave(TgcTerrainEditor editor)
 {
     Enabled = false;
     if (Editing) endEdition();
     return false;
 }