|
||||||||||
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.Geometry
com.jme.scene.TriMesh
com.jmex.terrain.TerrainBlock
public class TerrainBlock
TerrainBlock
defines the lowest level of the terrain system.
TerrainBlock
is the actual part of the terrain system that
renders to the screen. The terrain is built from a heightmap defined by a one
dimenensional int array. The step scale is used to define the amount of units
each block line will extend. By directly creating a TerrainBlock
yourself, you can generate a brute force terrain. This is many times
sufficient for small terrains on modern hardware. If terrain is to be large,
it is recommended that you make use of the TerrainPage
class.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.jme.scene.TriMesh |
---|
TriMesh.Mode |
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.TriMesh |
---|
indexBuffer, mode, triangleQuantity |
Fields inherited from class com.jme.scene.Geometry |
---|
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity |
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 | |
---|---|
TerrainBlock()
Empty Constructor to be used internally only. |
|
TerrainBlock(java.lang.String name)
For internal use only. |
|
TerrainBlock(java.lang.String name,
int size,
Vector3f stepScale,
float[] heightMap,
Vector3f origin)
Constructor instantiates a new TerrainBlock object. |
|
TerrainBlock(java.lang.String name,
int size,
Vector3f stepScale,
float[] heightMap,
Vector3f origin,
int totalSize,
Vector2f offset,
float offsetAmount)
Constructor instantiates a new TerrainBlock object. |
Method Summary | |
---|---|
void |
addHeightMapValue(int x,
int y,
float toAdd)
setHeightMapValue adds to the value of this block's height
map at the given coords |
void |
buildTextureCoordinates()
buildTextureCoordinates calculates the texture coordinates
of the terrain. |
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. |
float[] |
getHeightMap()
Returns the height map this terrain block is using. |
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 block. |
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. |
boolean |
hasChanged()
|
void |
multHeightMapValue(int x,
int y,
float toMult)
setHeightMapValue 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,
float repeat)
setDetailTexture copies the texture coordinates from the
first texture channel to another channel specified by unit, mulitplying
by the factor specified by repeat so that the texture in that channel
will be repeated that many times across the block. |
void |
setHeightMap(float[] heightMap)
Sets the terrain's height map. |
void |
setHeightMapValue(int x,
int y,
float newVal)
setHeightMapValue sets the value of this block's height
map at the given coords |
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 block. |
void |
setStepScale(Vector3f stepScale)
Sets the step scale of this terrain block's height map. |
void |
setTotalSize(int totalSize)
Sets the total size of the terrain . |
void |
updateFromHeightMap()
Updates the block's vertices and normals from the current height map values. |
void |
write(JMEExporter e)
|
Methods inherited from class com.jme.scene.TriMesh |
---|
clearBuffers, draw, findCollisions, findTriangleCollision, findTrianglePick, getIndexBuffer, getMaxIndex, getMeshAsTriangles, getMeshAsTrianglesVertices, getMode, getTriangle, getTriangle, getTriangleCount, getTriangleIndices, getVertIndex, hasCollision, hasTriangleCollision, randomPointOnTriangles, recalcTriangleQuantity, reconstruct, setIndexBuffer, setMode, setTriangleQuantity |
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 TerrainBlock()
public TerrainBlock(java.lang.String name)
name
- The name.public TerrainBlock(java.lang.String name, int size, Vector3f stepScale, float[] heightMap, Vector3f origin)
TerrainBlock
object. The
parameters and heightmap data are then processed to generate a
TriMesh
object for rendering.
name
- the name of the terrain block.size
- the size of the heightmap.stepScale
- the scale for the axes.heightMap
- the height data.origin
- the origin offset of the block.public TerrainBlock(java.lang.String name, int size, Vector3f stepScale, float[] heightMap, Vector3f origin, int totalSize, Vector2f offset, float offsetAmount)
TerrainBlock
object. The
parameters and heightmap data are then processed to generate a
TriMesh
object for renderering.
name
- the name of the terrain block.size
- the size of the block.stepScale
- the scale for the axes.heightMap
- the height data.origin
- the origin offset of the block.totalSize
- the total size of the terrain. (Higher if the block is part of
a TerrainPage
tree.offset
- the offset for texture coordinates.offsetAmount
- the total offset amount. Used for texture coordinates.Method Detail |
---|
public void setDetailTexture(int unit, float repeat)
setDetailTexture
copies the texture coordinates from the
first texture channel to another channel specified by unit, mulitplying
by the factor specified by repeat so that the texture in that channel
will be repeated that many times across the block.
unit
- channel to copy coords torepeat
- number of times to repeat the texture across and down the
blockpublic 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 void buildTextureCoordinates()
buildTextureCoordinates
calculates the texture coordinates
of the terrain.
public float[] getHeightMap()
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 void setHeightMap(float[] heightMap)
heightMap
- The new height map.public void updateFromHeightMap()
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)
setHeightMapValue
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)
setHeightMapValue
multiplies the value of this block's
height map at the given coords by the value given.
x
- y
- toMult
- public boolean hasChanged()
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 TriMesh
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
read
in class TriMesh
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |