Class MidPointHeightMapGenerator
java.lang.Object
com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator
-
Field Summary
Modifier and TypeFieldDescriptionprotected float
The filter is used to erode the terrain.protected float[]
Height data information.protected float
Allows scaling the Y height of the map.protected int
The size of the height map's width. -
Constructor Summary
ConstructorDescriptionMidPointHeightMapGenerator
(int size, float roughness) Constructor builds a new height map using the midpoint displacement algorithm.MidPointHeightMapGenerator
(int size, float roughness, long seed) Constructor builds a new height map using the midpoint displacement algorithm. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
erodeTerrain
(float[][] tempBuffer) erodeTerrain
is a convenience method that applies the FIR filter to a given height map.boolean
load
generates the height field using the Midpoint Displacement algorithm.float[]
float
protected void
normalizeTerrain
(float[][] tempBuffer) normalizeTerrain
takes the current terrain data and converts it to values between 0 and NORMALIZE_RANGE.protected void
setHeightAtPoint
(float height, int x, int z) setHeightAtPoint
sets the height value for a given coordinate.void
setHeightRange
(float heightRange) void
setRoughness
(float roughness) setRoughness
sets the new roughness value of the height map.
-
Field Details
-
heightData
protected float[] heightDataHeight data information. -
size
protected int sizeThe size of the height map's width. -
heightScale
protected float heightScaleAllows scaling the Y height of the map. -
filter
protected float filterThe filter is used to erode the terrain.
-
-
Constructor Details
-
MidPointHeightMapGenerator
public MidPointHeightMapGenerator(int size, float roughness) Constructor builds a new height map using the midpoint displacement algorithm. Roughness determines how chaotic the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect creating smooth terrain, and < 1 late iterations have a disproportionately large effect creating chaotic terrain.- Parameters:
size
- the size of the terrain, must be a power of 2.roughness
- how chaotic to make the terrain.- Throws:
Ardor3dException
- if size is less than or equal to zero or roughtness is less than 0.
-
MidPointHeightMapGenerator
public MidPointHeightMapGenerator(int size, float roughness, long seed) Constructor builds a new height map using the midpoint displacement algorithm. Roughness determines how chaotic the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect creating smooth terrain, and < 1 late iterations have a disproportionately large effect creating chaotic terrain.- Parameters:
size
- the size of the terrain, must be a power of 2.roughness
- how chaotic to make the terrain.seed
- the seed- Throws:
Ardor3dException
- if size is less than or equal to zero or roughtness is less than 0.
-
-
Method Details
-
getHeightData
public float[] getHeightData()- Returns:
- the heightData
-
generateHeightData
public boolean generateHeightData()load
generates the height field using the Midpoint Displacement algorithm.load
uses the latest attributes, so a call toload
is recommended if attributes have changed using the set methods.- Returns:
true
-
setRoughness
public void setRoughness(float roughness) setRoughness
sets the new roughness value of the height map. Roughness determines how chaotic the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect creating smooth terrain, and < 1 late iterations have a disproportionately large effect creating chaotic terrain.- Parameters:
roughness
- how chaotic will the height map be.
-
setHeightAtPoint
protected void setHeightAtPoint(float height, int x, int z) setHeightAtPoint
sets the height value for a given coordinate.- Parameters:
height
- the new height for the coordinate.x
- the x (east/west) coordinate.z
- the z (north/south) coordinate.
-
normalizeTerrain
protected void normalizeTerrain(float[][] tempBuffer) normalizeTerrain
takes the current terrain data and converts it to values between 0 and NORMALIZE_RANGE.- Parameters:
tempBuffer
- the terrain to normalize.
-
erodeTerrain
protected void erodeTerrain(float[][] tempBuffer) erodeTerrain
is a convenience method that applies the FIR filter to a given height map. This simulates water errosion.- Parameters:
tempBuffer
- the terrain to filter.
-
getHeightRange
public float getHeightRange() -
setHeightRange
public void setHeightRange(float heightRange)
-