public class TerrainPatch extends Geometry
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
Modifier and Type | Field and Description |
---|---|
protected TerrainPatch |
bottomNeighbour |
protected LODGeomap |
geomap |
protected TerrainPatch |
leftNeighbour |
protected int |
lod |
protected int |
lodBottom |
protected float[] |
lodEntropy |
protected int |
lodLeft |
protected int |
lodRight |
protected int |
lodTop |
protected Vector2f |
offset |
protected float |
offsetAmount |
protected int |
previousLod |
protected short |
quadrant |
protected TerrainPatch |
rightNeighbour |
protected boolean |
searchedForNeighboursAlready |
protected int |
size |
protected Vector3f |
stepScale |
protected TerrainPatch |
topNeighbour |
protected int |
totalSize |
protected Vector3f |
worldScaleCached |
protected Vector3f |
worldTranslationCached |
cachedWorldMat, groupNode, ignoreTransform, lodLevel, material, mesh, SAVABLE_VERSION, startIndex
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localOverrides, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_CHILD_LIGHTLIST, RF_LIGHTLIST, RF_MATPARAM_OVERRIDE, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldOverrides, worldTransform
Constructor and Description |
---|
TerrainPatch() |
TerrainPatch(java.lang.String name) |
TerrainPatch(java.lang.String name,
int size) |
TerrainPatch(java.lang.String name,
int size,
Vector3f stepScale,
float[] heightMap,
Vector3f origin)
Constructor instantiates a new
TerrainPatch object. |
TerrainPatch(java.lang.String name,
int size,
Vector3f stepScale,
float[] heightMap,
Vector3f origin,
int totalSize,
Vector2f offset,
float offsetAmount)
Constructor instantiates a new
TerrainPatch object. |
Modifier and Type | Method and Description |
---|---|
protected void |
averageNormalsTangents(Vector3f topPoint,
Vector3f rootPoint,
Vector3f leftPoint,
Vector3f bottomPoint,
Vector3f rightPoint,
Vector3f normal,
Vector3f tangent,
Vector3f binormal) |
protected void |
cacheTerrainTransforms()
Caches the transforms (except rotation) so the LOD calculator,
which runs on a separate thread, can access them safely.
|
protected void |
clearCaches()
Removes any references when the terrain is being removed.
|
TerrainPatch |
clone()
This version of clone is a shallow clone, in other words, the
same mesh is referenced as the original geometry.
|
void |
cloneFields(Cloner cloner,
java.lang.Object original)
Called internally by com.jme3.util.clone.Cloner.
|
int |
collideWith(Collidable other,
CollisionResults results)
Check collision with another Collidable.
|
protected void |
ensurePositiveVolumeBBox() |
protected void |
fixNormalEdges(TerrainPatch right,
TerrainPatch bottom,
TerrainPatch top,
TerrainPatch left,
TerrainPatch bottomRight,
TerrainPatch bottomLeft,
TerrainPatch topRight,
TerrainPatch topLeft)
Matches the normals along the edge of the patch with the neighbours.
|
void |
generateLodEntropies()
This calculation is slow, so don't use it often.
|
Triangle[] |
getGridTriangles(float x,
float z)
Get the triangles at the specified grid point.
|
protected float |
getHeight(int x,
int z,
float xm,
float zm) |
float[] |
getHeightMap() |
float |
getHeightmapHeight(float x,
float z) |
int |
getLod() |
protected int |
getLodBottom() |
float[] |
getLodEntropies() |
protected int |
getLodLeft() |
protected int |
getLodRight() |
protected int |
getLodTop() |
int |
getMaxLod()
The maximum lod supported by this terrain patch.
|
protected Vector3f |
getMeshNormal(int x,
int z) |
Vector2f |
getOffset()
Returns the current offset amount.
|
float |
getOffsetAmount()
Returns the offset amount this terrain patch uses for textures.
|
int |
getPreviousLod() |
short |
getQuadrant() |
int |
getSize()
Returns the size of this terrain patch.
|
Vector3f |
getStepScale()
Returns the step scale that stretches the height map.
|
Vector2f |
getTex(float x,
float z,
Vector2f store) |
int |
getTotalSize()
Returns the total size of the terrain.
|
Triangle |
getTriangle(float x,
float z)
Get the triangle of this geometry at the specified local coordinate.
|
Vector3f |
getWorldScaleCached() |
Vector3f |
getWorldTranslationCached() |
void |
lockMesh()
Locks the mesh (sets it static) to improve performance.
|
void |
read(JmeImporter im) |
protected void |
reIndexGeometry(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated,
boolean useVariableLod) |
protected void |
setHeight(java.util.List<TerrainQuad.LocationHeight> locationHeights,
boolean overrideHeight) |
void |
setLod(int lod) |
protected void |
setLodBottom(int lodBottom) |
protected void |
setLodLeft(int lodLeft) |
protected void |
setLodRight(int lodRight) |
protected void |
setLodTop(int lodTop) |
void |
setOffset(Vector2f offset)
Sets the value for the current offset amount to use when building texture
coordinates.
|
void |
setOffsetAmount(float offsetAmount)
Sets the offset of this terrain texture map.
|
void |
setPreviousLod(int previousLod) |
void |
setQuadrant(short quadrant) |
void |
setSize(int size)
Sets the size of this terrain patch.
|
void |
setStepScale(Vector3f stepScale)
Sets the step scale of this terrain patch's height map.
|
void |
setTotalSize(int totalSize)
Sets the total size of the terrain .
|
void |
unlockMesh()
Unlocks the mesh (sets it dynamic) to make it editable.
|
protected void |
updateNormals()
Recalculates all normal vectors in this terrain patch.
|
protected Vector3f |
worldCoordinateToLocal(Vector3f loc) |
void |
write(JmeExporter ex) |
associateWithGroupNode, breadthFirstTraversal, checkCulling, clone, computeWorldMatrix, deepClone, depthFirstTraversal, getFallbackMorphTarget, getLodLevel, getMaterial, getMesh, getModelBound, getMorphState, getMorphState, getNbSimultaneousGPUMorph, getTriangleCount, getVertexCount, getWorldMatrix, isBatched, isDirtyMorph, isGrouped, isIgnoreTransform, oldDeepClone, removeFromParent, setDirtyMorph, setFallbackMorphTarget, setIgnoreTransform, setLodLevel, setMaterial, setMesh, setModelBound, setMorphState, setMorphState, setNbSimultaneousGPUMorph, setParent, unassociateFromGroupNode, updateModelBound, updateWorldBound, updateWorldLightList, updateWorldTransforms
addControl, addLight, addMatParamOverride, breadthFirstTraversal, center, clearMatParamOverrides, depthFirstTraversal, forceRefresh, getBatchHint, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalBatchHint, getLocalCullHint, getLocalLightList, getLocalMatParamOverrides, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldMatParamOverrides, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, jmeClone, localToWorld, lookAt, matches, move, move, oldClone, removeControl, removeControl, removeLight, removeMatParamOverride, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLightListRefresh, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setMatParamOverrideRefresh, setName, setQueueBucket, setRequiresUpdates, setShadowMode, setTransformRefresh, setUserData, toString, updateGeometricState, updateLogicalState, updateMatParamOverrides, worldToLocal
protected LODGeomap geomap
protected int lod
protected int previousLod
protected int lodLeft
protected int lodTop
protected int lodRight
protected int lodBottom
protected int size
protected int totalSize
protected short quadrant
protected Vector3f stepScale
protected Vector2f offset
protected float offsetAmount
protected TerrainPatch leftNeighbour
protected TerrainPatch topNeighbour
protected TerrainPatch rightNeighbour
protected TerrainPatch bottomNeighbour
protected boolean searchedForNeighboursAlready
protected Vector3f worldTranslationCached
protected Vector3f worldScaleCached
protected float[] lodEntropy
public TerrainPatch()
public TerrainPatch(java.lang.String name)
public TerrainPatch(java.lang.String name, int size)
public TerrainPatch(java.lang.String name, int size, Vector3f stepScale, float[] heightMap, Vector3f origin)
TerrainPatch
object. The
parameters and heightmap data are then processed to generate a
TriMesh
object for rendering.name
- the name of the terrain patch.size
- the size of the heightmap.stepScale
- the scale for the axes.heightMap
- the height data.origin
- the origin offset of the patch.public TerrainPatch(java.lang.String name, int size, Vector3f stepScale, float[] heightMap, Vector3f origin, int totalSize, Vector2f offset, float offsetAmount)
TerrainPatch
object. The
parameters and heightmap data are then processed to generate a
TriMesh
object for rendering.name
- the name of the terrain patch.size
- the size of the patch.stepScale
- the scale for the axes.heightMap
- the height data.origin
- the origin offset of the patch.totalSize
- the total size of the terrain. (Higher if the patch is part of
a TerrainQuad
tree.)offset
- the offset for texture coordinates.offsetAmount
- the total offset amount. Used for texture coordinates.public void generateLodEntropies()
public float[] getLodEntropies()
public float[] getHeightMap()
public int getMaxLod()
protected void reIndexGeometry(java.util.HashMap<java.lang.String,UpdatedTerrainPatch> updated, boolean useVariableLod)
public float getHeightmapHeight(float x, float z)
public Triangle getTriangle(float x, float z)
x
- local to the terrain patchz
- local to the terrain patchpublic Triangle[] getGridTriangles(float x, float z)
x
- local to the terrain patchz
- local to the terrain patchprotected void setHeight(java.util.List<TerrainQuad.LocationHeight> locationHeights, boolean overrideHeight)
protected void updateNormals()
protected void fixNormalEdges(TerrainPatch right, TerrainPatch bottom, TerrainPatch top, TerrainPatch left, TerrainPatch bottomRight, TerrainPatch bottomLeft, TerrainPatch topRight, TerrainPatch topLeft)
protected void averageNormalsTangents(Vector3f topPoint, Vector3f rootPoint, Vector3f leftPoint, Vector3f bottomPoint, Vector3f rightPoint, Vector3f normal, Vector3f tangent, Vector3f binormal)
protected Vector3f getMeshNormal(int x, int z)
protected float getHeight(int x, int z, float xm, float zm)
public void lockMesh()
public void unlockMesh()
public float getOffsetAmount()
public Vector3f getStepScale()
public int getTotalSize()
public int getSize()
public Vector2f getOffset()
public void setOffset(Vector2f offset)
offset
- The new texture offset.public void setSize(int size)
size
- The new size.public void setTotalSize(int totalSize)
totalSize
- The new total size.public void setStepScale(Vector3f stepScale)
stepScale
- The new step scale.public void setOffsetAmount(float offsetAmount)
offsetAmount
- The new texture offset.public short getQuadrant()
public void setQuadrant(short quadrant)
quadrant
- The quadrant to set.public int getLod()
public void setLod(int lod)
public int getPreviousLod()
public void setPreviousLod(int previousLod)
protected int getLodLeft()
protected void setLodLeft(int lodLeft)
protected int getLodTop()
protected void setLodTop(int lodTop)
protected int getLodRight()
protected void setLodRight(int lodRight)
protected int getLodBottom()
protected void setLodBottom(int lodBottom)
public int collideWith(Collidable other, CollisionResults results) throws UnsupportedCollisionException
Collidable
collideWith
in interface Collidable
collideWith
in class Geometry
other
- The object to check collision againstresults
- Will contain the list of CollisionResult
s.UnsupportedCollisionException
public void write(JmeExporter ex) throws java.io.IOException
public void read(JmeImporter im) throws java.io.IOException
public TerrainPatch clone()
Geometry
clone
in interface CloneableSmartAsset
clone
in class Geometry
Mesh.cloneForAnim()
public void cloneFields(Cloner cloner, java.lang.Object original)
cloneFields
in interface JmeCloneable
cloneFields
in class Geometry
cloner
- The cloner that is performing the cloning operation. The
cloneFields method can call back into the cloner to make
clones of its subordinate fields.original
- The original object from which this object was cloned.
This is provided for the very rare case that this object needs
to refer to its original for some reason. In general, all of
the relevant values should have been transferred during the
shallow clone, and this object need only clone what it wants.protected void ensurePositiveVolumeBBox()
protected void cacheTerrainTransforms()
public Vector3f getWorldScaleCached()
public Vector3f getWorldTranslationCached()
protected void clearCaches()