|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.terrain.heightmap.AbstractHeightMap
com.jme3.terrain.heightmap.MidpointDisplacementHeightMap
public class MidpointDisplacementHeightMap
MidpointDisplacementHeightMap
generates an heightmap based on
the midpoint displacement algorithm. See Constructor javadoc for more info.
Field Summary |
---|
Fields inherited from class com.jme3.terrain.heightmap.AbstractHeightMap |
---|
filter, heightData, heightScale, NORMALIZE_RANGE, size |
Constructor Summary | |
---|---|
MidpointDisplacementHeightMap(int size,
float range,
float persistence)
The constructor generates the heightmap. |
|
MidpointDisplacementHeightMap(int size,
float range,
float persistence,
long seed)
The constructor generates the heightmap. |
Method Summary | |
---|---|
protected int[] |
doDiamondStep(float[][] tempBuffer,
int[] coords,
int stepSize,
float offsetRange,
java.util.Random random)
Will fill the cell at (x+stepSize/2, y) with the average of the 4 corners of the diamond centered on that point with width and height of stepSize. |
protected int[] |
doSquareStep(float[][] tempBuffer,
int[] coords,
int stepSize,
float offsetRange,
java.util.Random random)
Will fill the value at (coords[0]+stepSize/2, coords[1]+stepSize/2) with the average from the corners of the square with topleft corner at (coords[0],coords[1]) and width of stepSize. |
protected float |
getOffset(java.util.Random random,
float offsetRange,
int[] coords,
float average)
Generate a random value to add to the computed average |
float |
getPersistence()
|
float |
getRange()
|
long |
getSeed()
|
boolean |
load()
Generate the heightmap. |
void |
setPersistence(float persistence)
|
void |
setRange(float range)
|
void |
setSeed(long seed)
|
Methods inherited from class com.jme3.terrain.heightmap.AbstractHeightMap |
---|
erodeTerrain, findMinMaxHeights, flatten, getHeightMap, getInterpolatedHeight, getScaledHeightAtPoint, getScaledHeightMap, getSize, getTrueHeightAtPoint, normalizeTerrain, save, setHeightAtPoint, setHeightScale, setMagnificationFilter, setSize, smooth, smooth, unloadHeightMap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MidpointDisplacementHeightMap(int size, float range, float persistence, long seed) throws java.lang.Exception
-range
and range
. The range
parameter is multiplied by
the persistence
parameter each pass to smoothen close cell heights.
Extends this class and override the getOffset function for more control of
the randomness (you can use the coordinates and/or the computed average height
to influence the random amount added.
size
- The size of the heightmap, must be 2^N+1range
- The range in which randomness will be added. A value of 1 will
allow -1 to 1 value changes.persistence
- The factor by which the range will evolve at each iteration.
A value of 0.5f will halve the range at each iteration and is
typically a good choiceseed
- A seed to feed the random number generator.
java.lang.Exception
public MidpointDisplacementHeightMap(int size, float range, float persistence) throws java.lang.Exception
-range
and range
. The range
parameter is multiplied by
the persistence
parameter each pass to smoothen close cell heights.
size
- The size of the heightmap, must be 2^N+1range
- The range in which randomness will be added. A value of 1 will
allow -1 to 1 value changes.persistence
- The factor by which the range will evolve at each iteration.
A value of 0.5f will halve the range at each iteration and is
typically a good choice
java.lang.Exception
Method Detail |
---|
public boolean load()
protected int[] doSquareStep(float[][] tempBuffer, int[] coords, int stepSize, float offsetRange, java.util.Random random)
tempBuffer
- the temprary heightmapcoords
- an int array of lenght 2 with the x coord in position 0stepSize
- the size of the squareoffsetRange
- the offset range within a random value is picked and added to the averagerandom
- the random generator
protected int[] doDiamondStep(float[][] tempBuffer, int[] coords, int stepSize, float offsetRange, java.util.Random random)
tempBuffer
- coords
- stepSize
- offsetRange
- random
-
protected float getOffset(java.util.Random random, float offsetRange, int[] coords, float average)
random
- the random generatoroffsetRange
- coords
- average
-
public float getPersistence()
public void setPersistence(float persistence)
public float getRange()
public void setRange(float range)
public long getSeed()
public void setSeed(long seed)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |