|
||||||||||
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.jmex.terrain.TerrainPage
public class 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. 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 dependent 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.jme.scene.Spatial |
---|
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode |
Field Summary |
---|
Fields inherited from class com.jme.scene.Node |
---|
children |
Fields inherited from class com.jme.scene.Spatial |
---|
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, 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,
float[] heightMap)
Constructor instantiates a new TerrainPage object. |
protected |
TerrainPage(java.lang.String name,
int blockSize,
int size,
Vector3f stepScale,
float[] heightMap,
int totalSize,
Vector2f offset,
float offsetAmount)
Constructor instantiates a new TerrainPage object. |
Method Summary | |
---|---|
void |
addHeightMapValue(int x,
int y,
float toAdd)
addHeightMapValue adds to the value of this block's height
map at the given coords |
static float[] |
createHeightSubBlock(float[] 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. |
float |
getHeightFromWorld(Vector3f position)
getHeightFromWorld returns the height of an arbitrary
point on the terrain when given world coordinates. |
Vector2f |
getOffset()
Returns the current offset amount. |
float |
getOffsetAmount()
Returns the offset amount this terrain block uses for textures. |
short |
getQuadrant()
|
int |
getSize()
Returns the size of this terrain page. |
Vector3f |
getStepScale()
Returns the step scale that stretches the height map. |
Vector3f |
getSurfaceNormal(float x,
float z,
Vector3f store)
getSurfaceNormal returns the normal of an arbitrary point
on the terrain. |
Vector3f |
getSurfaceNormal(Vector2f position,
Vector3f store)
getSurfaceNormal returns the normal of an arbitrary point
on the terrain. |
Vector3f |
getSurfaceNormal(Vector3f position,
Vector3f store)
getSurfaceNormal returns the normal of an arbitrary point
on the terrain. |
int |
getTotalSize()
Returns the total size of the terrain. |
void |
multHeightMapValue(int x,
int y,
float toMult)
multHeightMapValue multiplies the value of this block's
height map at the given coords by the value given. |
void |
read(JMEImporter e)
|
void |
setDetailTexture(int unit,
int repeat)
setDetailTexture sets the detail texture coordinates to be
applied on top of the normal terrain texture. |
void |
setHeightMapValue(int x,
int y,
float newVal)
setHeightMapValue sets the value of this block's height
map at the given coords |
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(float offsetAmount)
Sets the offset of this terrain texture map. |
void |
setQuadrant(short quadrant)
|
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 |
updateFromHeightMap()
updateFromHeightMap updates the verts of all sub blocks
from the contents of their heightmaps. |
void |
updateModelBound()
updateModelBound updates the model bounds (generates the
bounds from the current vertices). |
void |
write(JMEExporter e)
|
Methods inherited from class com.jme.scene.Node |
---|
applyRenderState, attachChild, attachChildAt, childChange, detachAllChildren, detachChild, detachChildAt, detachChildNamed, draw, findCollisions, findPick, getChild, getChild, getChildIndex, getChildren, getQuantity, getTriangleCount, getVertexCount, hasChild, hasCollision, lockBounds, lockMeshes, lockShadows, lockTransforms, sortLights, swapChildren, unlockBounds, unlockMeshes, unlockShadows, unlockTransforms, updateWorldBound, updateWorldData, updateWorldVectors |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.jme.util.export.Savable |
---|
getClassTag |
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, float[] heightMap)
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.protected TerrainPage(java.lang.String name, int blockSize, int size, Vector3f stepScale, float[] heightMap, int totalSize, Vector2f offset, float 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.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.
setModelBound
in class Node
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).
updateModelBound
in class Node
public void updateFromHeightMap()
updateFromHeightMap
updates the verts of all sub blocks
from the contents of their heightmaps.
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 float getHeightFromWorld(Vector3f position)
getHeightFromWorld
returns the height of an arbitrary
point on the terrain when given world coordinates. 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 Vector3f getSurfaceNormal(Vector2f position, Vector3f store)
getSurfaceNormal
returns the normal of an arbitrary point
on the terrain. The normal is linearly interpreted from the normals of
the 4 nearest defined points. If the point provided is not within the
bounds of the height map, null is returned.
position
- the vector representing the location to find a normal at.store
- the Vector3f object to store the result in. If null, a new one
is created.
public Vector3f getSurfaceNormal(Vector3f position, Vector3f store)
getSurfaceNormal
returns the normal of an arbitrary point
on the terrain. The normal is linearly interpreted from the normals of
the 4 nearest defined points. If the point provided is not within the
bounds of the height map, null is returned.
position
- the vector representing the location to find a normal at. Only
the x and z values are used.store
- the Vector3f object to store the result in. If null, a new one
is created.
public Vector3f getSurfaceNormal(float x, float z, Vector3f store)
getSurfaceNormal
returns the normal of an arbitrary point
on the terrain. The normal is linearly interpreted from the normals of
the 4 nearest defined points. If the point provided is not within the
bounds of the height map, null is returned.
x
- the x coordinate to check.z
- the z coordinate to check.store
- the Vector3f object to store the result in. If null, a new one
is created.
public Vector2f getOffset()
public int getTotalSize()
public int getSize()
public Vector3f getStepScale()
public float 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(float offsetAmount)
offsetAmount
- The new texture offset.public void fixNormals()
public static final float[] createHeightSubBlock(float[] heightMap, int x, int y, int side)
public void setHeightMapValue(int x, int y, float newVal)
setHeightMapValue
sets the value of this block's height
map at the given coords
x
- y
- newVal
- public void addHeightMapValue(int x, int y, float toAdd)
addHeightMapValue
adds to the value of this block's height
map at the given coords
x
- y
- toAdd
- public void multHeightMapValue(int x, int y, float toMult)
multHeightMapValue
multiplies the value of this block's
height map at the given coords by the value given.
x
- y
- toMult
- public short getQuadrant()
public void setQuadrant(short quadrant)
quadrant
- The quadrant to set.public void write(JMEExporter e) throws java.io.IOException
write
in interface Savable
write
in class Node
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
read
in class Node
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |