|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjme.locale.external.data.AbstractHeightMap
AbstractHeightMap
provides a base implementation of height
data for terrain rendering. The loading of the data is dependent on the
subclass. The abstract implementation provides a means to retrieve the
height data and to save it.
It is the general contract that any subclass provide a means of editing
required attributes and calling load
again to recreate a
heightfield with these new parameters.
Field Summary | |
protected float |
filter
|
protected int[][] |
heightData
|
protected float |
heightScale
|
protected int |
size
|
Constructor Summary | |
AbstractHeightMap()
|
Method Summary | |
protected void |
erodeTerrain(float[][] tempBuffer)
erodeTerrain is a convenience method that applies
the FIR filter to a given height map. |
int[][] |
getHeightMap()
getHeightMap returns the entire grid of height data. |
float |
getInterpolatedHeight(float x,
float z)
getInterpolatedHeight returns the height of a point that
does not fall directly on the height posts. |
float |
getScaledHeightAtPoint(int x,
int z)
getScaledHeightAtPoint returns the scaled value at the
point provided. |
int |
getSize()
getSize returns the size of one side the height map. |
int |
getTrueHeightAtPoint(int x,
int z)
getTrueHeightAtPoint returns the non-scaled value at the
point provided. |
abstract boolean |
load()
load populates the height map data. |
void |
normalizeTerrain(float[][] tempBuffer)
normalizeTerrain takes the current terrain data and
converts it to values between 0 and 255. |
boolean |
save(java.lang.String filename)
save will save the heightmap data into a new RAW file
denoted by the supplied filename. |
void |
setFilter(float filter)
setFilter sets the erosion value for the filter. |
void |
setHeightAtPoint(int height,
int x,
int z)
setHeightAtPoint sets the height value for a given
coordinate. |
void |
setHeightScale(float scale)
setHeightScale sets the scale of the height values. |
void |
setSize(int size)
setSize sets the size of the terrain where the area is
size x size. |
void |
unloadHeightMap()
unloadHeightMap clears the data of the height map. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int[][] heightData
protected int size
protected float heightScale
protected float filter
Constructor Detail |
public AbstractHeightMap()
Method Detail |
public void unloadHeightMap()
unloadHeightMap
clears the data of the height map. This
insures it is ready for reloading.
public void setHeightScale(float scale)
setHeightScale
sets the scale of the height values.
Typically, the height is a little too extreme and should be
scaled to a smaller value (i.e. 0.25), to produce cleaner slopes.
scale
- the scale to multiply height values by.public void setHeightAtPoint(int height, int x, int z)
setHeightAtPoint
sets the height value for a given
coordinate. It is recommended that the height value be within the
0 - 255 range.
height
- the new height for the coordinate.x
- the x (east/west) coordinate.z
- the z (north/south) coordinate.public void setSize(int size)
setSize
sets the size of the terrain where the area is
size x size.
size
- the new size of the terrain.
MonkeyRuntimeException
- if the size is less than or equal to
zero.public void setFilter(float filter)
setFilter
sets the erosion value for the filter. This
value must be between 0 and 1, where 0.2 - 0.4 produces arguably the
best results.
filter
- the erosion value.
MonkeyRuntimeException
- if filter is less than 0 or greater than
1.public int getTrueHeightAtPoint(int x, int z)
getTrueHeightAtPoint
returns the non-scaled value at the
point provided.
x
- the x (east/west) coordinate.z
- the z (north/south) coordinate.
public float getScaledHeightAtPoint(int x, int z)
getScaledHeightAtPoint
returns the scaled value at the
point provided.
x
- the x (east/west) coordinate.z
- the z (north/south) coordinate.
public float getInterpolatedHeight(float x, float z)
getInterpolatedHeight
returns the height of a point that
does not fall directly on the height posts.
x
- the x coordinate of the point.z
- the y coordinate of the point.
public int[][] getHeightMap()
getHeightMap
returns the entire grid of height data.
public int getSize()
getSize
returns the size of one side the height map. Where
the area of the height map is size x size.
public boolean save(java.lang.String filename)
save
will save the heightmap data into a new RAW file
denoted by the supplied filename.
filename
- the file name to save the current data as.
MonkeyRuntimeException
- if filename is null.public void normalizeTerrain(float[][] tempBuffer)
normalizeTerrain
takes the current terrain data and
converts it to values between 0 and 255.
tempBuffer
- the terrain to normalize.protected void erodeTerrain(float[][] tempBuffer)
erodeTerrain
is a convenience method that applies
the FIR filter to a given height map. This simulates water errosion.
tempBuffer
- the terrain to filter.public abstract boolean load()
load
populates the height map data. This is dependent
on the subclass's implementation.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |