|
|
|
@ -32,12 +32,8 @@ |
|
|
|
|
package jme3test.terrain; |
|
|
|
|
|
|
|
|
|
import com.jme3.app.SimpleApplication; |
|
|
|
|
import com.jme3.bounding.BoundingBox; |
|
|
|
|
import com.jme3.collision.CollisionResult; |
|
|
|
|
import com.jme3.collision.CollisionResults; |
|
|
|
|
import com.jme3.export.Savable; |
|
|
|
|
import com.jme3.export.binary.BinaryExporter; |
|
|
|
|
import com.jme3.export.binary.BinaryImporter; |
|
|
|
|
import com.jme3.font.BitmapText; |
|
|
|
|
import com.jme3.input.KeyInput; |
|
|
|
|
import com.jme3.input.MouseInput; |
|
|
|
@ -52,9 +48,8 @@ import com.jme3.math.ColorRGBA; |
|
|
|
|
import com.jme3.math.Ray; |
|
|
|
|
import com.jme3.math.Vector2f; |
|
|
|
|
import com.jme3.math.Vector3f; |
|
|
|
|
import com.jme3.renderer.queue.RenderQueue.Bucket; |
|
|
|
|
import com.jme3.scene.Geometry; |
|
|
|
|
import com.jme3.scene.Node; |
|
|
|
|
import com.jme3.scene.debug.Arrow; |
|
|
|
|
import com.jme3.scene.shape.Sphere; |
|
|
|
|
import com.jme3.terrain.geomipmap.TerrainGrid; |
|
|
|
|
import com.jme3.terrain.geomipmap.TerrainLodControl; |
|
|
|
@ -64,16 +59,8 @@ import com.jme3.terrain.heightmap.FractalHeightMapGrid; |
|
|
|
|
import com.jme3.terrain.heightmap.ImageBasedHeightMap; |
|
|
|
|
import com.jme3.texture.Texture; |
|
|
|
|
import com.jme3.texture.Texture.WrapMode; |
|
|
|
|
import java.io.BufferedInputStream; |
|
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.logging.Level; |
|
|
|
|
import java.util.logging.Logger; |
|
|
|
|
import jme3tools.converters.ImageToAwt; |
|
|
|
|
import org.novyon.noise.ShaderUtils; |
|
|
|
|
import org.novyon.noise.basis.FilteredBasis; |
|
|
|
@ -106,6 +93,7 @@ public class TerrainTestModifyHeight extends SimpleApplication { |
|
|
|
|
private boolean lowerTerrain = false; |
|
|
|
|
|
|
|
|
|
private Geometry marker; |
|
|
|
|
private Geometry markerNormal; |
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
TerrainTestModifyHeight app = new TerrainTestModifyHeight(); |
|
|
|
@ -132,6 +120,10 @@ public class TerrainTestModifyHeight extends SimpleApplication { |
|
|
|
|
float h = terrain.getHeight(new Vector2f(intersection.x, intersection.z)); |
|
|
|
|
Vector3f tl = terrain.getWorldTranslation(); |
|
|
|
|
marker.setLocalTranslation(tl.add(new Vector3f(intersection.x, h, intersection.z)) ); |
|
|
|
|
markerNormal.setLocalTranslation(tl.add(new Vector3f(intersection.x, h, intersection.z)) ); |
|
|
|
|
|
|
|
|
|
Vector3f normal = terrain.getNormal(new Vector2f(intersection.x, intersection.z)); |
|
|
|
|
((Arrow)markerNormal.getMesh()).setArrowExtent(normal); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -148,8 +140,8 @@ public class TerrainTestModifyHeight extends SimpleApplication { |
|
|
|
|
matWire.getAdditionalRenderState().setWireframe(true); |
|
|
|
|
matWire.setColor("Color", ColorRGBA.Green); |
|
|
|
|
|
|
|
|
|
//createTerrain();
|
|
|
|
|
createTerrainGrid(); |
|
|
|
|
createTerrain(); |
|
|
|
|
//createTerrainGrid();
|
|
|
|
|
|
|
|
|
|
DirectionalLight light = new DirectionalLight(); |
|
|
|
|
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); |
|
|
|
@ -422,6 +414,7 @@ public class TerrainTestModifyHeight extends SimpleApplication { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void createMarker() { |
|
|
|
|
// collision marker
|
|
|
|
|
Sphere sphere = new Sphere(8, 8, 0.5f); |
|
|
|
|
marker = new Geometry("Marker"); |
|
|
|
|
marker.setMesh(sphere); |
|
|
|
@ -433,5 +426,12 @@ public class TerrainTestModifyHeight extends SimpleApplication { |
|
|
|
|
marker.setMaterial(mat); |
|
|
|
|
rootNode.attachChild(marker); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// surface normal marker
|
|
|
|
|
Arrow arrow = new Arrow(new Vector3f(0,1,0)); |
|
|
|
|
markerNormal = new Geometry("MarkerNormal"); |
|
|
|
|
markerNormal.setMesh(arrow); |
|
|
|
|
markerNormal.setMaterial(mat); |
|
|
|
|
rootNode.attachChild(markerNormal); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|