Map Editor

Hello,



In the search for some tools to help me build my game, I found out that it would be a good idea to have a map editor for it. That would allow me faster level design throught the game produciton. Given that my game is tile-based (rts like), I was searching for some tile editors.


  • The first one I found (Tiled http://www.mapeditor.org/ ) gave me a lot of ideas. But for this to work, I would need to somehow transform those tiles into a HeightMap, and apply the textures accordingly to the tiles that were used. And if I want to create an object (let’s say a tree) in a place, I’d put a tile that represents a tree(in the layer above, so the grass texture below won’t get lost), and when this generation happens, I could parse this “tree tile” as a tree, and add a model in that place. Is that correct, or is there another way to do that?


  • The problem with the first map editor was that I can’t put ramps, to change the Y level. A Warcraft3 map editor is pretty much what I need. But those things aren’t easily found out there to be used for free. I found out this (http://www.youtube.com/watch?v=8n3drHYoERA) wich also looks really cool.



    Edit: Maybe I could also use the TerrainEditor and try building a Grid from the loaded map. Do you guys have any opinions on those solutions?

Also, I could create a tile based editor, and then, on level loading, I convert those tiles into a HeightMap. I’m really giving shots at blind here. James created a hexagon based tile editor built-in his game, but I really think this is going to give me a lot to work with. Any ideas?

JME Terrain is specjalized in LOD/Multitexturing/etc… also tiles should give ability of “levels”(like in “Maker’s Tale”).

i think its quite a hard work.



but you say you need Warcraft3 map editor. it don’t use levels, so using it for limited tile maps is possible.



Even it’s better to use JME Terrain in this situation.



lets take Terrain HeightMap. it’s just a points, so for a tile you can take for example 4 points, so if one of tiles is lower, then it will automaticly smooth it.



harder to make texturing for it. i seen it’s quite advanced.(here i have no idea)

Unfortunately the question is too general for me to really be much help. So much stuff is dependant on the nature of your game, nature of the levels, etc. Do you want to use the game engine or an external editor? How much detail do you want to be editting? etc etc.

Well, both options are fine to me @zarch. Both are convinient, and I can try to modify both for my needings (like adding trees). For now, I just want to work with terrain, but being able to work with the Y position. Don’t need to be much detailed because I could do some hard stuff on the game, like trying to match textures so the editor doesn’t need to provide this info (less work for the editor). Levels are normally square, with some stuffs on the way, like trees and debris (collideable), most of it should be flat with some ramps connecting different Y positions.

Check out what I do here just with the SceneComposer/TerrainEditor: http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/powermonkey/#post-159693

If you are using straight tiles, then you will have to build your game like a voxel world. But if you are using jme terrain, it might be easier to add in a ‘slope’ tool to the existing editor, and add in some height snapping. Of course I can help guide you with this feature as I have wanted to add it for a while now.

I use the duplicate function in the scene composer, combined with the grid snap, to tile together spatials such as roads. It’s quite fast and flexible.

@Sploreg said:
If you are using straight tiles, then you will have to build your game like a voxel world. But if you are using jme terrain, it might be easier to add in a 'slope' tool to the existing editor, and add in some height snapping. Of course I can help guide you with this feature as I have wanted to add it for a while now.
I use the duplicate function in the scene composer, combined with the grid snap, to tile together spatials such as roads. It's quite fast and flexible.


If by Slope you mean levels (like a stair), then I think I'd stick with this solution, as this is the faster, easier and more attractive (do something that someone will use besides me). And afterwards, I could add a behavior so the objects I place snaps to the the Grid, so I can have the tiles I wanted in the first place.

Edit: This is why I like strong communities, normally someone thought of something you forgot about.

No I mean have fixed heights, but sloped in between. So the tool will snap between integer points, but still generate smooth terrain; not steps.

@Sploreg said:
No I mean have fixed heights, but sloped in between. So the tool will snap between integer points, but still generate smooth terrain; not steps.


This is the perfect soltuion. I think I'll need to start editing the Terrain Editor, I'll look into some docs on how to do it, or if you have any shortcuts, just say it ^^

I have no idea how I'm going to compile all this stuff. I think I could just compile the TerrainEditor module, and overwrite the current on my jME so I could see the changes I'm making. Huuuum, that's a start.

I’ve thought about this slope tool a little bit already. Here is a bit of a summary of how it can work.



First click, set a start point. Second click, establish the end point.

After second click, the slope is generated.

Hold Ctrl to snap to 15 degree angles on the Y-axis.

The slope will need a width, and a “steepness” for the side slopes. Similar to the side of the road in this picture: http://i.imgur.com/bKSLB.jpg

So you can have steep sides on the slope, or gradual ones.



The slope will have to be able to cut through terrain and rise above it.



There is a tool that is sort of similar to this: LevelTerrainTool.java and LevelTerrainToolAction.java in the terrain editor module of the SDK. It is a good place to start looking.

You can launch the sdk from a netbeans environment. Then whenever you change something in the terrain editor module you just have to right-click it and select ‘Reload in target platform’ and it will re-load in your already open/running sdk (that you launched from netbeans).

@Sploreg said:
You can launch the sdk from a netbeans environment. Then whenever you change something in the terrain editor module you just have to right-click it and select 'Reload in target platform' and it will re-load in your already open/running sdk (that you launched from netbeans).


Thank you for this information. I was looking for this. Got it working already with testing modifications. I just hope this doesn't take more then 2 weeks to finish it.

Well well well, already got something. Terrain need smooth. I did this way cause I failed to understand the way tou said. Anyways, it’s still buggy though, as this shouldn’t be applied after/before the markers. It lacks smoothing, and when the radius is too big, the same level is applied incorrectly to the neighbours. Could you tell me what you think @Sploreg ?



Patch source dir is located at: trunksdkjme3-terrain-editorsrc



Edit: To use it, right click somewhere (top of the hill), then right click somewhere else (bottom of the hill), and then start clicking (dragging) with the left cursor down between the red and the blue marker (buggy for now if you go beyond them).



[patch]Index: com/jme3/gde/terraineditor/TerrainEditorTopComponent.form

===================================================================

— com/jme3/gde/terraineditor/TerrainEditorTopComponent.form (revisão 9571)

+++ com/jme3/gde/terraineditor/TerrainEditorTopComponent.form (cĂłpia de trabalho)

@@ -1,4 +1,4 @@

-<?xml version=“1.1” encoding=“UTF-8” ?>

+<?xml version=“1.0” encoding=“UTF-8” ?>



<Form version=“1.6” maxVersion=“1.7” type=“org.netbeans.modules.form.forminfo.JPanelFormInfo”>

<NonVisualComponents>

@@ -53,7 +53,7 @@

<EmptySpace max="-2" attributes=“0”/>

<Component id=“hintPanel” max=“32767” attributes=“0”/>

</Group>

  •      &lt;Component id=&quot;jToolBar1&quot; alignment=&quot;0&quot; pref=&quot;898&quot; max=&quot;32767&quot; attributes=&quot;0&quot;/&gt;<br />
    
  •      &lt;Component id=&quot;jToolBar1&quot; alignment=&quot;0&quot; pref=&quot;1015&quot; max=&quot;32767&quot; attributes=&quot;0&quot;/&gt;<br />
    

</Group>

</DimensionLayout>

<DimensionLayout dim="1">

@@ -65,7 +65,7 @@

<Component id="hintPanel" max="32767" attributes="1"/>

<Component id="paintingPanel" alignment="0" max="32767" attributes="1"/>

<Component id="toolSettingsPanel" alignment="0" pref="128" max="32767" attributes="1"/>

  •              &lt;Component id=&quot;jPanel2&quot; pref=&quot;128&quot; max=&quot;32767&quot; attributes=&quot;1&quot;/&gt;<br />
    
  •              &lt;Component id=&quot;jPanel2&quot; max=&quot;32767&quot; attributes=&quot;1&quot;/&gt;<br />
    

</Group>

</Group>

</Group>

@@ -213,6 +213,28 @@

<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="levelTerrainButtonActionPerformed"/>

</Events>

</Component>

  •    &lt;Component class=&quot;javax.swing.JToggleButton&quot; name=&quot;shirkitButton&quot;&gt;<br />
    
  •      &lt;Properties&gt;<br />
    
  •        &lt;Property name=&quot;buttonGroup&quot; type=&quot;javax.swing.ButtonGroup&quot; editor=&quot;org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor&quot;&gt;<br />
    
  •          &lt;ComponentRef name=&quot;terrainModButtonGroup&quot;/&gt;<br />
    
  •        &lt;/Property&gt;<br />
    
  •        &lt;Property name=&quot;icon&quot; type=&quot;javax.swing.Icon&quot; editor=&quot;org.netbeans.modules.form.editors2.IconEditor&quot;&gt;<br />
    
  •          &lt;Image iconType=&quot;3&quot; name=&quot;/com/jme3/gde/terraineditor/TerraMonkey.png&quot;/&gt;<br />
    
  •        &lt;/Property&gt;<br />
    
  •        &lt;Property name=&quot;text&quot; type=&quot;java.lang.String&quot; editor=&quot;org.netbeans.modules.i18n.form.FormI18nStringEditor&quot;&gt;<br />
    
  •          &lt;ResourceString bundle=&quot;com/jme3/gde/terraineditor/Bundle.properties&quot; key=&quot;TerrainEditorTopComponent.shirkitButton.text&quot; replaceFormat=&quot;org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)&quot;/&gt;<br />
    
  •        &lt;/Property&gt;<br />
    
  •        &lt;Property name=&quot;toolTipText&quot; type=&quot;java.lang.String&quot; editor=&quot;org.netbeans.modules.i18n.form.FormI18nStringEditor&quot;&gt;<br />
    
  •          &lt;ResourceString bundle=&quot;com/jme3/gde/terraineditor/Bundle.properties&quot; key=&quot;TerrainEditorTopComponent.shirkitButton.toolTipText&quot; replaceFormat=&quot;org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)&quot;/&gt;<br />
    
  •        &lt;/Property&gt;<br />
    
  •        &lt;Property name=&quot;focusable&quot; type=&quot;boolean&quot; value=&quot;false&quot;/&gt;<br />
    
  •        &lt;Property name=&quot;horizontalTextPosition&quot; type=&quot;int&quot; value=&quot;0&quot;/&gt;<br />
    
  •        &lt;Property name=&quot;verticalTextPosition&quot; type=&quot;int&quot; value=&quot;3&quot;/&gt;<br />
    
  •      &lt;/Properties&gt;<br />
    
  •      &lt;Events&gt;<br />
    
  •        &lt;EventHandler event=&quot;actionPerformed&quot; listener=&quot;java.awt.event.ActionListener&quot; parameters=&quot;java.awt.event.ActionEvent&quot; handler=&quot;shirkitButtonActionPerformed&quot;/&gt;<br />
    
  •      &lt;/Events&gt;<br />
    
  •    &lt;/Component&gt;<br />
    

<Component class="javax.swing.JToolBar$Separator" name="jSeparator2">

</Component>

<Component class="javax.swing.JButton" name="addTextureButton">

@@ -352,7 +374,7 @@

<Layout>

<DimensionLayout dim="0">

<Group type="103" groupAlignment="0" attributes="0">

  •              &lt;EmptySpace min=&quot;0&quot; pref=&quot;57&quot; max=&quot;32767&quot; attributes=&quot;0&quot;/&gt;<br />
    
  •              &lt;EmptySpace min=&quot;0&quot; pref=&quot;131&quot; max=&quot;32767&quot; attributes=&quot;0&quot;/&gt;<br />
    

</Group>

</DimensionLayout>

<DimensionLayout dim="1">

@@ -671,7 +693,7 @@

<Layout>

<DimensionLayout dim="0">

<Group type="103" groupAlignment="0" attributes="0">

  •          &lt;Component id=&quot;jScrollPane1&quot; alignment=&quot;0&quot; pref=&quot;244&quot; max=&quot;32767&quot; attributes=&quot;0&quot;/&gt;<br />
    
  •          &lt;Component id=&quot;jScrollPane1&quot; alignment=&quot;0&quot; pref=&quot;361&quot; max=&quot;32767&quot; attributes=&quot;0&quot;/&gt;<br />
    

</Group>

</DimensionLayout>

<DimensionLayout dim="1">

Index: com/jme3/gde/terraineditor/tools/ShirkitTool.java

===================================================================

— com/jme3/gde/terraineditor/tools/ShirkitTool.java (revisão 0)

+++ com/jme3/gde/terraineditor/tools/ShirkitTool.java (cĂłpia de trabalho)

@@ -0,0 +1,76 @@

+/*

    • To change this template, choose Tools | Templates
    • and open the template in the editor.
  • */

    +package com.jme3.gde.terraineditor.tools;

    +

    +import com.jme3.asset.AssetManager;

    +import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;

    +import com.jme3.material.Material;

    +import com.jme3.math.ColorRGBA;

    +import com.jme3.math.Vector3f;

    +import com.jme3.scene.Geometry;

    +import com.jme3.scene.Mesh;

    +import com.jme3.scene.Node;

    +import com.jme3.scene.shape.Sphere;

    +import org.openide.loaders.DataObject;

    +

    +/**
  • *
    • @author Shirkit
  • */

    +public class ShirkitTool extends TerrainTool {

    +
  • private Vector3f point1, point2;
  • private Geometry markerThird;
  • private int doit;

    +
  • @Override
  • public void activate(AssetManager manager, Node parent) {
  •    super.activate(manager, parent);<br />
    
  •    addMarkerSecondary(parent);<br />
    
  •    addMarkerThird(parent);<br />
    
  • }

    +
  • public void addMarkerThird(Node parent) {
  •    if (markerThird == null) {<br />
    
  •        markerThird = new Geometry(&quot;edit marker secondary&quot;);<br />
    
  •        Mesh m2 = new Sphere(8, 8, 0.5f);<br />
    
  •        markerThird.setMesh(m2);<br />
    
  •        Material mat2 = new Material(manager, &quot;Common/MatDefs/Misc/Unshaded.j3md&quot;);<br />
    
  •        mat2.getAdditionalRenderState().setWireframe(false);<br />
    
  •        markerThird.setMaterial(mat2);<br />
    
  •        markerThird.setLocalTranslation(0, 0, 0);<br />
    
  •        mat2.setColor(&quot;Color&quot;, ColorRGBA.Blue);<br />
    
  •    }<br />
    
  •    parent.attachChild(markerThird);<br />
    
  • }

    +
  • @Override
  • public void actionPrimary(Vector3f point, int textureIndex, AbstractSceneExplorerNode rootNode, DataObject dataObject) {
  •    if (point1 != null &amp;&amp; point2 != null) {<br />
    
  •        ShirkitToolAction action = new ShirkitToolAction(point, point1, point2, radius, weight);<br />
    
  •        action.actionPerformed(rootNode, dataObject);<br />
    
  •    }<br />
    
  • }

    +
  • @Override
  • public void actionSecondary(Vector3f point, int textureIndex, AbstractSceneExplorerNode rootNode, DataObject dataObject) {
  •    if (doit == 0) {<br />
    
  •        point2 = point;<br />
    
  •        markerSecondary.setLocalTranslation(point);<br />
    
  •    } else if (doit == 2) {<br />
    
  •        point1 = point;<br />
    
  •        markerThird.setLocalTranslation(point);<br />
    
  •    }<br />
    
  •    doit++;<br />
    
  •    if (doit == 5) {<br />
    
  •        doit = -1;<br />
    

+

  •        point2 = null;<br />
    
  •        point1 = null;<br />
    
  •        markerSecondary.setLocalTranslation(Vector3f.ZERO);<br />
    
  •        markerThird.setLocalTranslation(Vector3f.ZERO);<br />
    
  •    }<br />
    
  • }

    +}

    Index: com/jme3/gde/terraineditor/tools/ShirkitToolAction.java

    ===================================================================

    — com/jme3/gde/terraineditor/tools/ShirkitToolAction.java (revisão 0)

    +++ com/jme3/gde/terraineditor/tools/ShirkitToolAction.java (cĂłpia de trabalho)

    @@ -0,0 +1,118 @@

    +/*
    • To change this template, choose Tools | Templates
    • and open the template in the editor.
  • */

    +package com.jme3.gde.terraineditor.tools;

    +

    +import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;

    +import com.jme3.math.Vector2f;

    +import com.jme3.math.Vector3f;

    +import com.jme3.scene.Node;

    +import com.jme3.terrain.Terrain;

    +import java.util.ArrayList;

    +import java.util.List;

    +

    +/**
  • *
    • @author Shirkit
  • */

    +public class ShirkitToolAction extends AbstractTerrainToolAction {

    +
  • private final Vector3f current;
  • private Vector3f point1;
  • private Vector3f point2;
  • private final float radius;
  • private final float weight;

    +
  • public ShirkitToolAction(Vector3f current, Vector3f point1, Vector3f point2, float radius, float weight) {
  •    this.current = current;<br />
    
  •    this.point1 = point1;<br />
    
  •    this.point2 = point2;<br />
    
  •    this.radius = radius;<br />
    
  •    this.weight = weight;<br />
    
  •    name = &quot;Shirkit terrain&quot;;<br />
    
  • }

    +
  • @Override
  • protected Object doApplyTool(AbstractSceneExplorerNode rootNode) {
  •    Terrain terrain = getTerrain(rootNode.getLookup().lookup(Node.class));<br />
    
  •    if (terrain == null) {<br />
    
  •        return null;<br />
    
  •    }<br />
    

+

  •    doit(terrain);<br />
    

+

  •    return terrain;<br />
    
  • }

    +
  • private void doit(Terrain terrain) {
  •    if (point1.y &gt; point2.y) {<br />
    
  •        Vector3f temp = point1;<br />
    
  •        point1 = point2;<br />
    
  •        point2 = temp;<br />
    
  •    }<br />
    

+

  •    float desiredHeight = point1.y + (point2.y - point1.y) * (point1.distance(current)/point1.distance(point2));<br />
    

+

  •    int radiusStepsX = (int) (radius / ((Node) terrain).getLocalScale().x);<br />
    
  •    int radiusStepsZ = (int) (radius / ((Node) terrain).getLocalScale().z);<br />
    

+

  •    float xStepAmount = ((Node) terrain).getLocalScale().x;<br />
    
  •    float zStepAmount = ((Node) terrain).getLocalScale().z;<br />
    

+

  •    List&lt;Vector2f&gt; locs = new ArrayList&lt;Vector2f&gt;();<br />
    
  •    List&lt;Float&gt; heights = new ArrayList&lt;Float&gt;();<br />
    

+

  •    for (int z = -radiusStepsZ; z &lt; radiusStepsZ; z++) {<br />
    
  •        for (int x = -radiusStepsZ; x &lt; radiusStepsX; x++) {<br />
    

+

  •            float locX = current.x + (x * xStepAmount);<br />
    
  •            float locZ = current.z + (z * zStepAmount);<br />
    

+

  •            // see if it is in the radius of the tool<br />
    
  •            if (ToolUtils.isInRadius(locX - current.x, locZ - current.z, radius)) {<br />
    

+

  •                Vector2f terrainLoc = new Vector2f(locX, locZ);<br />
    
  •                // adjust height based on radius of the tool<br />
    
  •                float terrainHeightAtLoc = terrain.getHeightmapHeight(terrainLoc) * ((Node) terrain).getWorldScale().y;<br />
    
  •                float radiusWeight = ToolUtils.calculateRadiusPercent(radius, locX - current.x, locZ - current.z);<br />
    

+

  •                float epsilon = 0.1f * weight; // rounding error for snapping<br />
    

+

  •                float adj = 0;<br />
    
  •                if (terrainHeightAtLoc &lt; desiredHeight) {<br />
    
  •                    adj = 1;<br />
    
  •                } else if (terrainHeightAtLoc &gt; desiredHeight) {<br />
    
  •                    adj = -1;<br />
    
  •                }<br />
    

+

  •                adj *= radiusWeight * weight;<br />
    

+

  •                // test if adjusting too far and then cap it<br />
    
  •                if (adj &gt; 0 &amp;&amp; ToolUtils.floatGreaterThan((terrainHeightAtLoc + adj), desiredHeight, epsilon)) {<br />
    
  •                    adj = desiredHeight - terrainHeightAtLoc;<br />
    
  •                } else if (adj &lt; 0 &amp;&amp; ToolUtils.floatLessThan((terrainHeightAtLoc + adj), desiredHeight, epsilon)) {<br />
    
  •                    adj = terrainHeightAtLoc - desiredHeight;<br />
    
  •                }<br />
    

+

  •                if (!ToolUtils.floatEquals(adj, 0, 0.001f)) {<br />
    
  •                    locs.add(terrainLoc);<br />
    
  •                    heights.add(adj);<br />
    
  •                }<br />
    

+

  •            }<br />
    
  •        }<br />
    
  •    }<br />
    
  •    //undoLocs = locs;<br />
    
  •    //undoHeights = heights;<br />
    

+

  •    // do the actual height adjustment<br />
    
  •    terrain.adjustHeight(locs, heights);<br />
    

+

  •    ((Node) terrain).updateModelBound(); // or else we won't collide with it where we just edited<br />
    
  • }

    +
  • @Override
  • protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject) {
  • }

    +}

    Index: com/jme3/gde/terraineditor/TerrainEditorTopComponent.java

    ===================================================================

    — com/jme3/gde/terraineditor/TerrainEditorTopComponent.java (revisão 9571)

    +++ com/jme3/gde/terraineditor/TerrainEditorTopComponent.java (cĂłpia de trabalho)

    @@ -47,15 +47,7 @@

    import com.jme3.gde.core.util.DataObjectSaveNode;

    import com.jme3.gde.core.util.ToggleButtonGroup;

    import com.jme3.gde.terraineditor.sky.SkyboxWizardAction;

    -import com.jme3.gde.terraineditor.tools.EraseTerrainTool;

    -import com.jme3.gde.terraineditor.tools.LevelTerrainTool;

    -import com.jme3.gde.terraineditor.tools.LowerTerrainTool;

    -import com.jme3.gde.terraineditor.tools.PaintTerrainTool;

    -import com.jme3.gde.terraineditor.tools.RaiseTerrainTool;

    -import com.jme3.gde.terraineditor.tools.RoughExtraToolParams;

    -import com.jme3.gde.terraineditor.tools.RoughTerrainTool;

    -import com.jme3.gde.terraineditor.tools.SmoothTerrainTool;

    -import com.jme3.gde.terraineditor.tools.TerrainTool;

    +import com.jme3.gde.terraineditor.tools.*;

    import com.jme3.math.Vector3f;

    import com.jme3.scene.Node;

    import com.jme3.scene.Spatial;

    @@ -236,6 +228,7 @@

    smoothTerrainButton = new javax.swing.JToggleButton();

    roughTerrainButton = new javax.swing.JToggleButton();

    levelTerrainButton = new javax.swing.JToggleButton();
  •    shirkitButton = new javax.swing.JToggleButton();<br />
    

jSeparator2 = new javax.swing.JToolBar.Separator();

addTextureButton = new javax.swing.JButton();

removeTextureButton = new javax.swing.JButton();

@@ -354,6 +347,20 @@

}

});

jToolBar1.add(levelTerrainButton);

+

  •    terrainModButtonGroup.add(shirkitButton);<br />
    
  •    shirkitButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(&quot;/com/jme3/gde/terraineditor/TerraMonkey.png&quot;))); // NOI18N<br />
    
  •    org.openide.awt.Mnemonics.setLocalizedText(shirkitButton, org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, &quot;TerrainEditorTopComponent.shirkitButton.text&quot;)); // NOI18N<br />
    
  •    shirkitButton.setToolTipText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, &quot;TerrainEditorTopComponent.shirkitButton.toolTipText&quot;)); // NOI18N<br />
    
  •    shirkitButton.setFocusable(false);<br />
    
  •    shirkitButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);<br />
    
  •    shirkitButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);<br />
    
  •    shirkitButton.addActionListener(new java.awt.event.ActionListener() {<br />
    
  •        public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
    
  •            shirkitButtonActionPerformed(evt);<br />
    
  •        }<br />
    
  •    });<br />
    
  •    jToolBar1.add(shirkitButton);<br />
    

jToolBar1.add(jSeparator2);



addTextureButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/terraineditor/icon_terrain-add-texture.png"))); // NOI18N

@@ -448,7 +455,7 @@

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

  •        .addGap(0, 57, Short.MAX_VALUE)<br />
    
  •        .addGap(0, 120, Short.MAX_VALUE)<br />
    

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

@@ -637,7 +644,7 @@

hintPanel.setLayout(hintPanelLayout);

hintPanelLayout.setHorizontalGroup(

hintPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

  •        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)<br />
    
  •        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)<br />
    

);

hintPanelLayout.setVerticalGroup(

hintPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

@@ -656,7 +663,7 @@

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(hintPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

  •        .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 898, Short.MAX_VALUE)<br />
    
  •        .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 1015, Short.MAX_VALUE)<br />
    

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

@@ -667,7 +674,7 @@

.addComponent(hintPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(paintingPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(toolSettingsPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)

  •                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)))<br />
    
  •                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))<br />
    

);

}// </editor-fold>//GEN-END:initComponents



@@ -860,6 +867,17 @@

// TODO add your handling code here:

}//GEN-LAST:event_scaleFieldActionPerformed


  • private void shirkitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shirkitButtonActionPerformed
  •    if (shirkitButton.isSelected()) {<br />
    
  •        ShirkitTool tool = new ShirkitTool();<br />
    
  •        toolController.setTerrainEditButtonState(tool);<br />
    
  •        setHintText(tool);<br />
    
  •    } else {<br />
    
  •        toolController.setTerrainEditButtonState(null);<br />
    
  •        setHintText((TerrainTool) null);<br />
    
  •    }<br />
    
  • }//GEN-LAST:event_shirkitButtonActionPerformed

    +

    // Variables declaration - do not modify//GEN-BEGIN:variables

    private javax.swing.JButton addTextureButton;

    private javax.swing.JButton createTerrainButton;

    @@ -896,6 +914,7 @@

    private javax.swing.JTextField scaleField;

    private javax.swing.JLabel scaleLabel;

    private javax.swing.JTextField shininessField;
  • private javax.swing.JToggleButton shirkitButton;

    private javax.swing.JToggleButton smoothTerrainButton;

    private javax.swing.ButtonGroup terrainModButtonGroup;

    private javax.swing.JFileChooser textureFileChooser;

    Index: com/jme3/gde/terraineditor/Bundle.properties

    ===================================================================

    — com/jme3/gde/terraineditor/Bundle.properties (revisão 9571)

    +++ com/jme3/gde/terraineditor/Bundle.properties (cĂłpia de trabalho)

    @@ -119,3 +119,5 @@

    CreateTerrainVisualPanel2.jLabel6.text=Smooth

    CreateTerrainVisualPanel2.jLabel7.text=Height Scale:

    CreateTerrainVisualPanel2.heightScale.text=1

    +TerrainEditorTopComponent.shirkitButton.toolTipText=Shirkit terrain

    +TerrainEditorTopComponent.shirkitButton.text=

    [/patch]

What might be interesting is just a way to click one (or more) vertex on the terrain and then up/down arrow to move them up and down…saving the changes back into the original heightmap as well as modifying the grid.



Then you can sculpt terrain in the 3d view with full flexibility.

@zarch said:
What might be interesting is just a way to click one (or more) vertex on the terrain and then up/down arrow to move them up and down...saving the changes back into the original heightmap as well as modifying the grid.

Then you can sculpt terrain in the 3d view with full flexibility.


You mean selecting each vertex at a time? It can be done easily, the problem is how to get a key modifier. @Sploreg is it ok to pass the KeyInputEvent to the TerrainTool? I wanted, for example, to know when another modifier key (Alt, Ctrl or RightShift) is down, but this info isn't avaliable to it.

@shirkit cool, I got it working. I like the painting ability. My idea was to generate the ramp immediately, but this will give the user more control.



I hooked in key events to the terrain tools, you just have to override:

[java]public void keyPressed(KeyInputEvent kie) {}[/java]

in ShirkitTool.java

You will need the latest from svn for this.

@Sploreg said:
@shirkit cool, I got it working. I like the painting ability. My idea was to generate the ramp immediately, but this will give the user more control.

I hooked in key events to the terrain tools, you just have to override:
[java]public void keyPressed(KeyInputEvent kie) {}[/java]
in ShirkitTool.java
You will need the latest from svn for this.


Ok, thank you. I'll continue the developing. Now I doubt this will take much time.

Btw, you know any way to prevent the spheres to enter Wireframe mode? I thought by replacing the AdditionalRendererState attribute in the Geometry class for the markers I create, to prevent setWireframe doing anything, but I really don't know if this is a good idea (it really doesn't seems to be good).

I just had them as wireframe so when the radius is very large you can see what is going on underneath.

You should be able to disable it for your tool however, just override:

[java]

public void addMarkerPrimary(Node parent)

[/java]

in ShirkitTool.

No @Sploreg I mean when the user press that small cube, next to that light bulb (in the top of the Scene Composer), everything is present as blue wireframed. I want to change that behavior, so I can try to implement the behavior asked by @zarch that would allow a user to manually select vertex, one by one or in an area (just like desktop selection), and adjust them. I can only think someone using this tool while that forced wireframe is activated (I may be wrong).



Btw, I’m almost finished, I’m implementing the undo tool right now, and then it’s finished.