Slightly improved the terrain paint tool. Changed the terrain flatten tool to match documentation

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10738 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
bre..om 2013-07-25 16:26:06 +00:00
parent bf4447bc46
commit a33c7394e3
3 changed files with 24 additions and 6 deletions

View File

@ -32,10 +32,12 @@
package com.jme3.gde.terraineditor.tools; package com.jme3.gde.terraineditor.tools;
import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractStatefulGLToolAction; import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractStatefulGLToolAction;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.terrain.Terrain; import com.jme3.terrain.Terrain;
import org.openide.loaders.DataObject;
/** /**
* Helps find the terrain in the scene * Helps find the terrain in the scene
@ -69,4 +71,17 @@ public abstract class AbstractTerrainToolAction extends AbstractStatefulGLToolAc
return null; return null;
} }
@Override
protected void setModified(final AbstractSceneExplorerNode rootNode, final DataObject dataObject) {
if (dataObject.isModified())
return;
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
dataObject.setModified(true);
//rootNode.refresh(true); // we don't need to refresh the whole tree when we edit the terrain
}
});
}
} }

View File

@ -66,7 +66,9 @@ public class LevelTerrainTool extends TerrainTool {
if (radius == 0 || weight == 0) if (radius == 0 || weight == 0)
return; return;
if (desiredHeight == null) if (desiredHeight == null)
desiredHeight = point.clone(); desiredHeight = markerSecondary.getWorldTranslation().clone();
else
desiredHeight.y = markerSecondary.getWorldTranslation().y;
if (toolParams.absolute) if (toolParams.absolute)
desiredHeight.y = toolParams.height; desiredHeight.y = toolParams.height;
LevelTerrainToolAction action = new LevelTerrainToolAction(point, radius, weight, desiredHeight, toolParams.precision, getMesh()); LevelTerrainToolAction action = new LevelTerrainToolAction(point, radius, weight, desiredHeight, toolParams.precision, getMesh());

View File

@ -166,7 +166,7 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
int maxy = (int) Math.min(height,(uv.y*height + radius*height)); int maxy = (int) Math.min(height,(uv.y*height + radius*height));
float radiusSquared = radius*radius; float radiusSquared = radius*radius;
float radiusFalloff = radius*fadeFalloff; float radiusFalloff = radiusSquared*fadeFalloff;
// go through each pixel, in the radius of the tool, in the image // go through each pixel, in the radius of the tool, in the image
for (int y = miny; y < maxy; y++){ for (int y = miny; y < maxy; y++){
for (int x = minx; x < maxx; x++){ for (int x = minx; x < maxx; x++){
@ -178,14 +178,15 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
manipulatePixel(image, x, y, color, false); // gets the color at that location (false means don't write to the buffer) manipulatePixel(image, x, y, color, false); // gets the color at that location (false means don't write to the buffer)
// calculate the fade falloff intensity // calculate the fade falloff intensity
float intensity = 0.1f; float intensity = (1.0f-(dist/radiusSquared))*fadeFalloff;
if (dist > radiusFalloff) { /*if (dist > radiusFalloff) {
float dr = radius - radiusFalloff; // falloff to radius length float dr = radius - radiusFalloff; // falloff to radius length
float d2 = dist - radiusFalloff; // dist minus falloff float d2 = dist - radiusFalloff; // dist minus falloff
d2 = d2/dr; // dist percentage of falloff length d2 = d2/dr; // dist percentage of falloff length
intensity = 1-d2; // fade out more the farther away it is intensity = 1-d2; // fade out more the farther away it is
} }*/
//if (dragged) //if (dragged)
// intensity = intensity*0.1f; // magical divide it by 10 to reduce its intensity when mouse is dragged // intensity = intensity*0.1f; // magical divide it by 10 to reduce its intensity when mouse is dragged