|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jme.scene.Spatial
com.jme.scene.Node
com.jme.terrain.TerrainPage
TerrainPage is used to build a quad tree of terrain blocks.
The TerrainPage will have four children, either four pages or
four blocks. The size of the page must be (2^N + 1), to allow for even
splitting of the blocks. Organization of the page into a quad tree allows for
very fast culling of the terrain. In some instances, using Clod will also
improve rendering speeds. The total size of the heightmap is provided, as
well as the desired end size for a block. Appropriate values for the end
block size is completely dependant on the application. In some cases, a large
size will give performance gains, in others, a small size is the best option.
It is recommended that different combinations are tried.
| Field Summary |
| Fields inherited from class com.jme.scene.Node |
children |
| Fields inherited from class com.jme.scene.Spatial |
currentStates, defaultStateList, forceCull, forceView, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, name, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder |
| Constructor Summary | |
|
TerrainPage()
Empty Constructor to be used internally only. |
|
TerrainPage(java.lang.String name)
Creates a TerrainPage to be filled later. |
|
TerrainPage(java.lang.String name,
int blockSize,
int size,
Vector3f stepScale,
int[] heightMap,
boolean clod)
Constructor instantiates a new TerrainPage object. |
protected |
TerrainPage(java.lang.String name,
int blockSize,
int size,
Vector3f stepScale,
int[] heightMap,
boolean clod,
int totalSize,
Vector2f offset,
int offsetAmount)
Constructor instantiates a new TerrainPage object. |
| Method Summary | |
static int[] |
createHeightSubBlock(int[] heightMap,
int x,
int y,
int side)
|
void |
fixNormals()
|
float |
getHeight(float x,
float z)
getHeight returns the height of an arbitrary point on the
terrain. |
float |
getHeight(Vector2f position)
getHeight returns the height of an arbitrary point on the
terrain. |
float |
getHeight(Vector3f position)
getHeight returns the height of an arbitrary point on the
terrain. |
Vector2f |
getOffset()
Returns the current offset amount. |
int |
getOffsetAmount()
Returns the offset amount this terrain block uses for textures. |
int |
getSize()
Returns the size of this terrain page. |
Vector3f |
getStepScale()
Returns the step scale that stretches the height map. |
int |
getTotalSize()
Returns the total size of the terrain. |
void |
setDetailTexture(int unit,
int repeat)
setDetailTexture sets the detail texture coordinates to be
applied on top of the normal terrain texture. |
void |
setModelBound(BoundingVolume v)
setModelBound sets the model bounds for the terrain
blocks. |
void |
setOffset(Vector2f offset)
Sets the value for the current offset amount to use when building texture coordinates. |
void |
setOffsetAmount(int offsetAmount)
Sets the offset of this terrain texture map. |
void |
setSize(int size)
Sets the size of this terrain page. |
void |
setStepScale(Vector3f stepScale)
Sets the step scale of this terrain page's height map. |
void |
setTotalSize(int totalSize)
Sets the total size of the terrain . |
void |
updateModelBound()
updateModelBound updates the model bounds (generates the
bounds from the current vertices). |
| Methods inherited from class com.jme.scene.Node |
applyRenderState, attachChild, detachAllChildren, detachChild, detachChildAt, detachChildNamed, draw, drawBounds, findCollisions, findPick, getChild, getChild, getChildren, getQuantity, hasChild, hasCollision, putClone, setChild, setForceView, updateCollisionTree, updateWorldBound, updateWorldData |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public TerrainPage()
public TerrainPage(java.lang.String name)
name - The name of the page node.
public TerrainPage(java.lang.String name,
int blockSize,
int size,
Vector3f stepScale,
int[] heightMap,
boolean clod)
TerrainPage object. The
data is then split into either 4 new TerrainPages or 4 new
TerrainBlock.
name - the name of the page.blockSize - the size of the leaf nodes. This is used to determine if four
new TerrainPage objects should be the child or
four new TerrainBlock objects.size - the size of the heightmap for this page.stepScale - the scale of the axes.heightMap - the height data.clod - true will use level of detail, false will not.
protected TerrainPage(java.lang.String name,
int blockSize,
int size,
Vector3f stepScale,
int[] heightMap,
boolean clod,
int totalSize,
Vector2f offset,
int offsetAmount)
TerrainPage object. The
data is then split into either 4 new TerrainPages or 4 new
TerrainBlock.
name - the name of the page.blockSize - the size of the leaf nodes. This is used to determine if four
new TerrainPage objects should be the child or
four new TerrainBlock objects.size - the size of the heightmap for this page.stepScale - the scale of the axes.heightMap - the height data.clod - true will use level of detail, false will not.totalSize - the total terrain size, used if the page is an internal node
of a terrain system.offset - the texture offset for the page.offsetAmount - the amount of the offset.| Method Detail |
public void setDetailTexture(int unit,
int repeat)
setDetailTexture sets the detail texture coordinates to be
applied on top of the normal terrain texture.
unit - the texture unit to set the coordinates.repeat - the number of tiling for the texture.public void setModelBound(BoundingVolume v)
setModelBound sets the model bounds for the terrain
blocks.
v - the bounding volume to set for the terrain blocks.public void updateModelBound()
updateModelBound updates the model bounds (generates the
bounds from the current vertices).
public float getHeight(Vector2f position)
getHeight returns the height of an arbitrary point on the
terrain. If the point is between height point values, the height is
linearly interpolated. This provides smooth height calculations. If the
point provided is not within the bounds of the height map, the NaN
float value is returned (Float.NaN).
position - the vector representing the height location to check.
public float getHeight(Vector3f position)
getHeight returns the height of an arbitrary point on the
terrain. If the point is between height point values, the height is
linearly interpolated. This provides smooth height calculations. If the
point provided is not within the bounds of the height map, the NaN
float value is returned (Float.NaN).
position - the vector representing the height location to check.
Only the x and z values are used.
public float getHeight(float x,
float z)
getHeight returns the height of an arbitrary point on the
terrain. If the point is between height point values, the height is
linearly interpolated. This provides smooth height calculations. If the
point provided is not within the bounds of the height map, the NaN
float value is returned (Float.NaN).
x - the x coordinate to check.z - the z coordinate to check.
public Vector2f getOffset()
public int getTotalSize()
public int getSize()
public Vector3f getStepScale()
public int getOffsetAmount()
public void setOffset(Vector2f offset)
offset - The new texture offset.public void setTotalSize(int totalSize)
totalSize - The new total size.public void setSize(int size)
size - The new size.public void setStepScale(Vector3f stepScale)
stepScale - The new step scale.public void setOffsetAmount(int offsetAmount)
offsetAmount - The new texture offset.public void fixNormals()
public static int[] createHeightSubBlock(int[] heightMap,
int x,
int y,
int side)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||