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); }
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 AddTerrainEditorModifier(TgcTerrainEditor tool) { var modifier = new TerrainEditorModifier(tool); AddModifier(modifier); return(modifier); }
public bool mouseMove(TgcTerrainEditor editor) { TGCVector3 pos; Enabled = editor.mousePositionInTerrain(out pos); Position = pos; return(false); }
public Shovel(TgcTerrainEditor editor) : base(editor) { Color1 = Color.Aqua; Color2 = Color.Red; text.Color = Color1; bBrush.Color = Color1; bBrush.updateValues(); }
public Steamroller(TgcTerrainEditor editor) : base(editor) { Color1 = Color.LightGoldenrodYellow; Color2 = Color.Purple; text.Color = Color1; bBrush.Color = Color1; bBrush.updateValues(); }
public void render(TgcTerrainEditor editor) { editor.doRender(); if (Enabled) { renderFloatingVegetation(); } }
protected virtual void addVegetation(TgcTerrainEditor editor) { editor.addVegetation(Mesh); if (SoundEnabled) { playSound(); } Mesh = null; }
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; }
public bool mouseLeave(TgcTerrainEditor editor) { Enabled = false; if (Editing) { endEdition(); } return(false); }
public void render(TgcTerrainEditor editor) { if (Enabled) { configureTerrainEffect(editor.Terrain); bBrush.Render(); } renderText(); editor.doRender(); }
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; }
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); }
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; }
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); }
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); }
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)); }
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; }
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); }
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); }
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); }
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); }
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; } }
public bool mouseMove(TgcTerrainEditor editor) { Vector3 pos; Enabled = editor.mousePositionInTerrain(out pos); this.Position = pos; return false; }
protected virtual void addVegetation(TgcTerrainEditor editor) { editor.addVegetation(Mesh); if (SoundEnabled) playSound(); Mesh = null; }
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; }
public void render(TgcTerrainEditor editor) { editor.doRender(); if (Enabled) renderFloatingVegetation(); }
public void render(TgcTerrainEditor editor) { if (Enabled) { configureTerrainEffect(editor.Terrain); bBrush.render(); } renderText(); editor.doRender(); }
public VegetationBrush(TgcTerrainEditor editor) : base(editor) { }
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); }
public bool mouseLeave(TgcTerrainEditor editor) { this.Enabled = false; return false; }
public bool mouseLeave(TgcTerrainEditor editor) { this.Enabled = false; return(false); }
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; }
public bool mouseLeave(TgcTerrainEditor editor) { Enabled = false; if (Editing) endEdition(); return false; }