|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.scene.Spatial
com.jme3.scene.Node
com.jme3.terrain.geomipmap.TerrainQuad
public class TerrainQuad
A terrain quad is a node in the quad tree of the terrain system. The root terrain quad will be the only one that receives the update() call every frame and it will determine if there has been any LOD change.
The leaves of the terrain quad tree are Terrain Patches. These have the real geometry mesh.
Heightmap coordinates start from the bottom left of the world and work towards the top right.
+x ^ | ......N = length of heightmap | : : | : : | 0.....: +---------> +z (world coordinates)
Nested Class Summary | |
---|---|
protected class |
TerrainQuad.LocationHeight
|
Nested classes/interfaces inherited from class com.jme3.scene.Spatial |
---|
Spatial.BatchHint, Spatial.CullHint |
Field Summary | |
---|---|
protected NeighbourFinder |
neighbourFinder
|
protected Vector2f |
offset
|
protected float |
offsetAmount
|
protected int |
patchSize
|
protected int |
quadrant
|
protected int |
size
|
protected Vector3f |
stepScale
|
protected int |
totalSize
|
Fields inherited from class com.jme3.scene.Node |
---|
children |
Fields inherited from class com.jme3.scene.Spatial |
---|
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_LIGHTLIST, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldTransform |
Constructor Summary | |
---|---|
|
TerrainQuad()
|
|
TerrainQuad(java.lang.String name,
int patchSize,
int totalSize,
float[] heightMap)
|
|
TerrainQuad(java.lang.String name,
int patchSize,
int quadSize,
int totalSize,
float[] heightMap)
|
|
TerrainQuad(java.lang.String name,
int patchSize,
int totalSize,
int quadSize,
Vector3f scale,
float[] heightMap)
|
|
TerrainQuad(java.lang.String name,
int patchSize,
int size,
Vector3f scale,
float[] heightMap)
|
protected |
TerrainQuad(java.lang.String name,
int patchSize,
int quadSize,
Vector3f scale,
float[] heightMap,
int totalSize,
Vector2f offset,
float offsetAmount)
|
Method Summary | |
---|---|
void |
adjustHeight(java.util.List<Vector2f> xz,
java.util.List<java.lang.Float> height)
Raise/lower the height at many points. |
void |
adjustHeight(Vector2f xz,
float delta)
Raise/lower the height in one call (instead of getHeight then setHeight). |
void |
attachBoundChildren(Node parent)
A handy method that will attach all bounding boxes of this terrain to the node you supply. |
protected void |
cacheTerrainTransforms()
Caches the transforms (except rotation) so the LOD calculator, which runs on a separate thread, can access them safely. |
protected boolean |
calculateLod(java.util.List<Vector3f> location,
java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updates,
LodCalculator lodCalculator)
|
TerrainQuad |
clone()
Creates a clone of the asset. |
TerrainQuad |
clone(boolean cloneMaterials)
|
int |
collideWith(Collidable other,
CollisionResults results)
Check collision with another Collidable. |
float[] |
createHeightSubBlock(float[] heightMap,
int x,
int y,
int side)
|
protected void |
createQuad(int blockSize,
float[] heightMap)
Quadrants, world coordinates, and heightmap coordinates (Y-up): -z -u | -v 1|3 -x ----+---- x 2|4 u | v z createQuad generates four new quads from this quad. |
protected void |
createQuadPatch(float[] heightMap)
createQuadPatch creates four child patches from this quad. |
protected TerrainPatch |
findDownPatch(TerrainPatch tp)
|
protected TerrainQuad |
findDownQuad()
|
protected TerrainPatch |
findLeftPatch(TerrainPatch tp)
|
protected TerrainQuad |
findLeftQuad()
|
protected void |
findNeighboursLod(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated)
|
void |
findPick(Ray toTest,
java.util.List<TerrainPickData> results)
Gather the terrain patches that intersect the given ray (toTest). |
protected TerrainPatch |
findRightPatch(TerrainPatch tp)
|
protected TerrainQuad |
findRightQuad()
|
protected TerrainPatch |
findTopPatch(TerrainPatch tp)
|
protected TerrainQuad |
findTopQuad()
|
protected void |
fixEdges(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated)
Find any neighbours that should have their edges seamed because another neighbour changed its LOD to a greater value (less detailed) |
protected void |
fixNormalEdges(BoundingBox affectedArea)
fix the normals on the edge of the terrain patches. |
protected void |
fixNormals(BoundingBox affectedArea)
Find what terrain patches need normal recalculations and update their normals; |
void |
generateDebugTangents(Material mat)
|
void |
generateEntropy(ProgressMonitor progressMonitor)
Generate the entropy values for the terrain for the "perspective" LOD calculator. |
void |
getAllTerrainPatches(java.util.List<TerrainPatch> holder)
Retrieve all Terrain Patches from all children and store them in the 'holder' list |
void |
getAllTerrainPatchesWithTranslation(java.util.Map<TerrainPatch,Vector3f> holder,
Vector3f translation)
|
protected float |
getHeight(int x,
int z,
float xm,
float zm)
|
float |
getHeight(Vector2f xz)
Get the interpolated height of the terrain at the specified point. |
float[] |
getHeightMap()
Get the heightmap of the entire terrain. |
protected float |
getHeightmapHeight(int x,
int z)
This will just get the heightmap value at the supplied point, not an interpolated (actual) height value. |
float |
getHeightmapHeight(Vector2f xz)
Get the heightmap height at the specified X-Z coordinate. |
Material |
getMaterial()
Returns the material that this terrain uses. |
Material |
getMaterial(Vector3f worldLocation)
Returns the material that this terrain uses. |
int |
getMaxLod()
This is calculated by the specific LOD algorithm. |
protected Vector3f |
getMeshNormal(int x,
int z)
|
protected Vector3f |
getNormal(float x,
float z,
Vector2f xz)
|
Vector3f |
getNormal(Vector2f xz)
Get the normal vector for the surface of the terrain at the specified X-Z coordinate. |
int |
getNumMajorSubdivisions()
|
protected TerrainPatch |
getPatch(int quad)
|
int |
getPatchSize()
|
protected TerrainQuad |
getQuad(int quad)
|
int |
getQuadrant()
|
int |
getTerrainSize()
Used for painting to get the number of vertices along the edge of the terrain. |
int |
getTotalSize()
|
protected boolean |
isPointOnTerrain(int x,
int z)
|
protected boolean |
isRootQuad()
|
protected boolean |
needToRecalculateNormals()
|
void |
read(JmeImporter e)
|
void |
recalculateAllNormals()
Forces the recalculation of all normals on the terrain. |
protected void |
reIndexPages(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated,
boolean usesVariableLod)
|
void |
resetCachedNeighbours()
Reset the cached references of neighbours. |
protected void |
setHeight(java.util.List<TerrainQuad.LocationHeight> locations,
boolean overrideHeight)
|
void |
setHeight(java.util.List<Vector2f> xz,
java.util.List<java.lang.Float> height)
Set the height at many points. |
protected void |
setHeight(java.util.List<Vector2f> xz,
java.util.List<java.lang.Float> height,
boolean overrideHeight)
|
void |
setHeight(Vector2f xz,
float height)
Set the height at the specified X-Z coordinate. |
void |
setLocked(boolean locked)
lock or unlock the meshes of this terrain. |
protected void |
setNeedToRecalculateNormals()
This will cause all normals for this terrain quad to be recalculated |
void |
setNeighbourFinder(NeighbourFinder neighbourFinder)
|
protected void |
setNormalRecalcNeeded(Vector2f changedPoint)
Signal if the normal vectors for the terrain need to be recalculated. |
void |
setQuadrant(short quadrant)
|
protected void |
split(int blockSize,
float[] heightMap)
split divides the heightmap data for four children. |
protected void |
updateNormals()
update the normals if there were any height changes recently. |
void |
write(JmeExporter e)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Vector2f offset
protected int totalSize
protected int size
protected int patchSize
protected Vector3f stepScale
protected float offsetAmount
protected int quadrant
protected NeighbourFinder neighbourFinder
Constructor Detail |
---|
public TerrainQuad()
public TerrainQuad(java.lang.String name, int patchSize, int totalSize, float[] heightMap)
name
- the name of the scene element. This is required for
identification and comparison purposes.patchSize
- size of the individual patchestotalSize
- the size of this entire terrain tree (on one side)heightMap
- The height map to generate the terrain from (a flat
height map will be generated if this is null)public TerrainQuad(java.lang.String name, int patchSize, int quadSize, int totalSize, float[] heightMap)
name
- the name of the scene element. This is required for
identification and comparison purposes.patchSize
- size of the individual patchesquadSize
- totalSize
- the size of this entire terrain tree (on one side)heightMap
- The height map to generate the terrain from (a flat
height map will be generated if this is null)public TerrainQuad(java.lang.String name, int patchSize, int size, Vector3f scale, float[] heightMap)
name
- the name of the scene element. This is required for
identification and comparison purposes.patchSize
- size of the individual patchessize
- size of this quad, can be between totalSize and patchSizescale
- heightMap
- The height map to generate the terrain from (a flat
height map will be generated if this is null)public TerrainQuad(java.lang.String name, int patchSize, int totalSize, int quadSize, Vector3f scale, float[] heightMap)
name
- the name of the scene element. This is required for
identification and comparison purposes.patchSize
- size of the individual patchestotalSize
- the size of this entire terrain tree (on one side)quadSize
- scale
- heightMap
- The height map to generate the terrain from (a flat
height map will be generated if this is null)protected TerrainQuad(java.lang.String name, int patchSize, int quadSize, Vector3f scale, float[] heightMap, int totalSize, Vector2f offset, float offsetAmount)
Method Detail |
---|
public void setNeighbourFinder(NeighbourFinder neighbourFinder)
public void recalculateAllNormals()
protected void updateNormals()
protected void cacheTerrainTransforms()
public void generateEntropy(ProgressMonitor progressMonitor)
generateEntropy
in interface Terrain
progressMonitor
- optionalprotected boolean isRootQuad()
public Material getMaterial()
Terrain
getMaterial
in interface Terrain
public Material getMaterial(Vector3f worldLocation)
Terrain
getMaterial
in interface Terrain
worldLocation
- the location, in world coordinates, of where
we are interested in the underlying texture.public int getNumMajorSubdivisions()
getNumMajorSubdivisions
in interface Terrain
protected boolean calculateLod(java.util.List<Vector3f> location, java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updates, LodCalculator lodCalculator)
protected void findNeighboursLod(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated)
public void resetCachedNeighbours()
protected void fixEdges(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated)
protected void reIndexPages(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated, boolean usesVariableLod)
protected void split(int blockSize, float[] heightMap)
split
divides the heightmap data for four children. The
children are either quads or patches. This is dependent on the size of the
children. If the child's size is less than or equal to the set block
size, then patches are created, otherwise, quads are created.
blockSize
- the blocks size to test against.heightMap
- the height data.protected void createQuad(int blockSize, float[] heightMap)
createQuad
generates four new quads from this quad.
The heightmap's top left (0,0) coordinate is at the bottom, -x,-z
coordinate of the terrain, so it grows in the positive x.z direction.
public void generateDebugTangents(Material mat)
protected void createQuadPatch(float[] heightMap)
createQuadPatch
creates four child patches from this quad.
public float[] createHeightSubBlock(float[] heightMap, int x, int y, int side)
public void attachBoundChildren(Node parent)
parent
- that will get the bounding box shapes of the terrain attached toprotected void setNormalRecalcNeeded(Vector2f changedPoint)
needToRecalculateNormals
- if null, will cause needToRecalculateNormals() to return falseprotected boolean needToRecalculateNormals()
protected void setNeedToRecalculateNormals()
public float getHeightmapHeight(Vector2f xz)
Terrain
getHeightmapHeight
in interface Terrain
xz
- world coordinate
protected float getHeightmapHeight(int x, int z)
protected Vector3f getMeshNormal(int x, int z)
public float getHeight(Vector2f xz)
getHeight
in interface Terrain
xz
- the location to get the height for
protected float getHeight(int x, int z, float xm, float zm)
public Vector3f getNormal(Vector2f xz)
Terrain
getNormal
in interface Terrain
xz
- the X-Z world coordinate
protected Vector3f getNormal(float x, float z, Vector2f xz)
public void setHeight(Vector2f xz, float height)
Terrain
setHeight
in interface Terrain
xz
- coordinate to set the heightheight
- that will be set at the coordinatepublic void adjustHeight(Vector2f xz, float delta)
Terrain
adjustHeight
in interface Terrain
xz
- world coordinate to adjust the terrain heightdelta
- +- value to adjust the height bypublic void setHeight(java.util.List<Vector2f> xz, java.util.List<java.lang.Float> height)
Terrain
setHeight
in interface Terrain
xz
- a list of coordinates where the hight will be setheight
- the heights that match the xz coordinatespublic void adjustHeight(java.util.List<Vector2f> xz, java.util.List<java.lang.Float> height)
Terrain
adjustHeight
in interface Terrain
xz
- a list of coordinates where the hight will be adjustedheight
- +- value to adjust the height by, that matches the xz coordinatesprotected void setHeight(java.util.List<Vector2f> xz, java.util.List<java.lang.Float> height, boolean overrideHeight)
protected void setHeight(java.util.List<TerrainQuad.LocationHeight> locations, boolean overrideHeight)
protected boolean isPointOnTerrain(int x, int z)
public int getTerrainSize()
Terrain
getTerrainSize
in interface Terrain
public void setLocked(boolean locked)
setLocked
in interface Terrain
locked
- or unlockedpublic int getQuadrant()
public void setQuadrant(short quadrant)
protected TerrainPatch getPatch(int quad)
protected TerrainQuad getQuad(int quad)
protected TerrainPatch findRightPatch(TerrainPatch tp)
protected TerrainPatch findDownPatch(TerrainPatch tp)
protected TerrainPatch findTopPatch(TerrainPatch tp)
protected TerrainPatch findLeftPatch(TerrainPatch tp)
protected TerrainQuad findRightQuad()
protected TerrainQuad findDownQuad()
protected TerrainQuad findTopQuad()
protected TerrainQuad findLeftQuad()
protected void fixNormals(BoundingBox affectedArea)
protected void fixNormalEdges(BoundingBox affectedArea)
public int collideWith(Collidable other, CollisionResults results)
Collidable
collideWith
in interface Collidable
collideWith
in class Node
other
- The object to check collision againstresults
- Will contain the list of CollisionResult
s.
public void findPick(Ray toTest, java.util.List<TerrainPickData> results)
toTest
- results
- public void getAllTerrainPatches(java.util.List<TerrainPatch> holder)
holder
- must not be null, will be populated when returnspublic void getAllTerrainPatchesWithTranslation(java.util.Map<TerrainPatch,Vector3f> holder, Vector3f translation)
public void read(JmeImporter e) throws java.io.IOException
read
in interface Savable
read
in class Node
java.io.IOException
public void write(JmeExporter e) throws java.io.IOException
write
in interface Savable
write
in class Node
java.io.IOException
public TerrainQuad clone()
CloneableSmartAsset
Object.clone()
for more info on how this method
should be implemented.
clone
in interface CloneableSmartAsset
clone
in class Spatial
Mesh.cloneForAnim()
public TerrainQuad clone(boolean cloneMaterials)
clone
in class Node
Mesh.cloneForAnim()
public int getMaxLod()
Terrain
getMaxLod
in interface Terrain
public int getPatchSize()
public int getTotalSize()
public float[] getHeightMap()
Terrain
getHeightMap
in interface Terrain
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |