public abstract class AbstractHeightMap extends java.lang.Object implements HeightMap
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.| Modifier and Type | Field and Description | 
|---|---|
| protected float | filterThe filter is used to erode the terrain. | 
| protected float[] | heightDataHeight data information. | 
| protected float | heightScaleAllows scaling the Y height of the map. | 
| static float | NORMALIZE_RANGEThe range used to normalize terrain | 
| protected int | sizeThe size of the height map's width. | 
| Constructor and Description | 
|---|
| AbstractHeightMap() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | erodeTerrain()erodeTerrainis a convenience method that applies the FIR
 filter to a given height map. | 
| float[] | findMinMaxHeights()Find the minimum and maximum height values. | 
| void | flatten(byte flattening)Flattens out the valleys. | 
| float[] | getHeightMap()getHeightMapreturns the entire grid of height data. | 
| float | getInterpolatedHeight(float x,
                     float z)getInterpolatedHeightreturns the height of a point that
 does not fall directly on the height posts. | 
| float | getScaledHeightAtPoint(int x,
                      int z)getScaledHeightAtPointreturns the scaled value at the
 point provided. | 
| float[] | getScaledHeightMap()Build a new array of height data with the scaled values. | 
| int | getSize()getSizereturns the size of one side the height map. | 
| float | getTrueHeightAtPoint(int x,
                    int z)getTrueHeightAtPointreturns the non-scaled value at the
 point provided. | 
| void | normalizeTerrain(float value)normalizeTerraintakes the current terrain data and
 converts it to values between 0 andvalue. | 
| boolean | save(java.lang.String filename)savewill save the heightmap data into a new RAW file
 denoted by the supplied filename. | 
| void | setHeightAtPoint(float height,
                int x,
                int z)setHeightAtPointsets the height value for a given
 coordinate. | 
| void | setHeightScale(float scale)setHeightScalesets the scale of the height values. | 
| void | setMagnificationFilter(float filter)setFiltersets the erosion value for the filter. | 
| void | setSize(int size)setSizesets the size of the terrain where the area is
 size x size. | 
| void | smooth(float np)Smooth the terrain. | 
| void | smooth(float np,
      int radius)Smooth the terrain. | 
| void | unloadHeightMap()unloadHeightMapclears the data of the height map. | 
protected float[] heightData
protected int size
protected float heightScale
protected float filter
public static float NORMALIZE_RANGE
public void unloadHeightMap()
unloadHeightMap clears the data of the height map. This
 insures it is ready for reloading.unloadHeightMap in interface HeightMappublic 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.setHeightScale in interface HeightMapscale - the scale to multiply height values by.public void setHeightAtPoint(float 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.setHeightAtPoint in interface HeightMapheight - the new height for the coordinate.x - the x (east/west) coordinate.z - the z (north/south) coordinate.public void setSize(int size)
             throws java.lang.Exception
setSize sets the size of the terrain where the area is
 size x size.public void setMagnificationFilter(float filter)
                            throws java.lang.Exception
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.setMagnificationFilter in interface HeightMapfilter - the erosion value.java.lang.ExceptionJmeException - if filter is less than 0 or greater than 1.public float getTrueHeightAtPoint(int x,
                                  int z)
getTrueHeightAtPoint returns the non-scaled value at the
 point provided.getTrueHeightAtPoint in interface HeightMapx - 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.getScaledHeightAtPoint in interface HeightMapx - 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.getInterpolatedHeight in interface HeightMapx - the x coordinate of the point.z - the y coordinate of the point.public float[] getHeightMap()
getHeightMap returns the entire grid of height data.getHeightMap in interface HeightMappublic float[] getScaledHeightMap()
getScaledHeightMap in interface HeightMappublic 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)
             throws java.lang.Exception
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.java.lang.ExceptionJmeException - if filename is null.public void normalizeTerrain(float value)
normalizeTerrain takes the current terrain data and
 converts it to values between 0 and value.value - the value to normalize to.public float[] findMinMaxHeights()
public void erodeTerrain()
erodeTerrain is a convenience method that applies the FIR
 filter to a given height map. This simulates water erosion.public void flatten(byte flattening)
flattening - the power of flattening applied, 1 means nonepublic void smooth(float np)
np between 0 and 1
 
 You must first load() the heightmap data before this will have any effect.np - The factor to what extend the neighbors average has an influence.
          Value of 0 will ignore neighbors (no smoothing)
          Value of 1 will ignore the node old height.public void smooth(float np,
                   int radius)
np between 0 and 1
 You must first load() the heightmap data before this will have any effect.np - The factor to what extend the neighbors average has an influence.
          Value of 0 will ignore neighbors (no smoothing)
          Value of 1 will ignore the node old height.