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
3.0
bre..om 12 years ago
parent bf4447bc46
commit a33c7394e3
  1. 15
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/AbstractTerrainToolAction.java
  2. 4
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/LevelTerrainTool.java
  3. 9
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/PaintTerrainToolAction.java

@ -32,10 +32,12 @@
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.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.terrain.Terrain;
import org.openide.loaders.DataObject;
/**
* Helps find the terrain in the scene
@ -69,4 +71,17 @@ public abstract class AbstractTerrainToolAction extends AbstractStatefulGLToolAc
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
}
});
}
}

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

@ -166,7 +166,7 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
int maxy = (int) Math.min(height,(uv.y*height + radius*height));
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
for (int y = miny; y < maxy; y++){
for (int x = minx; x < maxx; x++){
@ -178,13 +178,14 @@ 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)
// calculate the fade falloff intensity
float intensity = 0.1f;
if (dist > radiusFalloff) {
float intensity = (1.0f-(dist/radiusSquared))*fadeFalloff;
/*if (dist > radiusFalloff) {
float dr = radius - radiusFalloff; // falloff to radius length
float d2 = dist - radiusFalloff; // dist minus falloff
d2 = d2/dr; // dist percentage of falloff length
intensity = 1-d2; // fade out more the farther away it is
}
}*/
//if (dragged)
// intensity = intensity*0.1f; // magical divide it by 10 to reduce its intensity when mouse is dragged

Loading…
Cancel
Save