public class ParticleDepositionHeightMap extends AbstractHeightMap
ParticleDepositionHeightMap
creates a heightmap based on the
Particle Deposition algorithm based on Jason Shankel's paper from
"Game Programming Gems". A heightmap is created using a Molecular beam
epitaxy, or MBE, for depositing thin layers of atoms on a substrate.
We drop a sequence of particles and simulate their flow across a surface
of previously dropped particles. This creates a few high peaks, for further
realism we can define a caldera. Similar to the way volcano's form
islands, rock is deposited via lava, when the lava cools, it recedes
into the volcano, creating the caldera.filter, heightData, heightScale, NORMALIZE_RANGE, size
Constructor and Description |
---|
ParticleDepositionHeightMap(int size,
int jumps,
int peakWalk,
int minParticles,
int maxParticles,
float caldera)
Constructor sets the attributes of the Particle Deposition
Height Map and then generates the map.
|
Modifier and Type | Method and Description |
---|---|
boolean |
load()
load generates the heightfield using the Particle Deposition
algorithm. |
void |
setCaldera(float caldera)
setCaldera sets the level at which a peak will be
inverted. |
void |
setJumps(int jumps)
setJumps sets the number of jumps or peaks that will
be created during the next call to load . |
void |
setMaxParticles(int maxParticles)
setMaxParticles sets the maximum number of particles
for a single jump. |
void |
setMinParticles(int minParticles)
setMinParticles sets the minimum number of particles
for a single jump. |
void |
setPeakWalk(int peakWalk)
setPeakWalk sets how often the jump point will be
agitated. |
erodeTerrain, findMinMaxHeights, flatten, getHeightMap, getInterpolatedHeight, getScaledHeightAtPoint, getScaledHeightMap, getSize, getTrueHeightAtPoint, normalizeTerrain, save, setHeightAtPoint, setHeightScale, setMagnificationFilter, setSize, smooth, smooth, unloadHeightMap
public ParticleDepositionHeightMap(int size, int jumps, int peakWalk, int minParticles, int maxParticles, float caldera) throws java.lang.Exception
size
- the size of the terrain where the area is size x size.jumps
- number of areas to drop particles. Can also think
of it as the number of peaks.peakWalk
- determines how much to agitate the drop point
during a creation of a single peak. The lower the number
the more the drop point will be agitated. 1 will insure
agitation every round.minParticles
- defines the minimum number of particles to
drop during a single jump.maxParticles
- defines the maximum number of particles to
drop during a single jump.caldera
- defines the altitude to invert a peak. This is
represented as a percentage, where 0.0 will not invert
anything, and 1.0 will invert all.java.lang.Exception
- if any value is less than zero, and
if caldera is not between 0 and 1. If minParticles is greater than
max particles as well.public boolean load()
load
generates the heightfield using the Particle Deposition
algorithm. load
uses the latest attributes, so a call
to load
is recommended if attributes have changed using
the set methods.public void setJumps(int jumps) throws java.lang.Exception
setJumps
sets the number of jumps or peaks that will
be created during the next call to load
.jumps
- the number of jumps to use for next load.java.lang.Exception
- if jumps is less than zero.public void setPeakWalk(int peakWalk) throws java.lang.Exception
setPeakWalk
sets how often the jump point will be
agitated. The lower the peakWalk, the more often the point will
be agitated.peakWalk
- the amount to agitate the jump point.java.lang.Exception
- if peakWalk is negative or zero.public void setCaldera(float caldera) throws java.lang.Exception
setCaldera
sets the level at which a peak will be
inverted.caldera
- the level at which a peak will be inverted. This must be
between 0 and 1, as it is represented as a percentage.java.lang.Exception
- if caldera is not between 0 and 1.public void setMaxParticles(int maxParticles)
setMaxParticles
sets the maximum number of particles
for a single jump.maxParticles
- the maximum number of particles for a single jump.public void setMinParticles(int minParticles) throws java.lang.Exception
setMinParticles
sets the minimum number of particles
for a single jump.minParticles
- the minimum number of particles for a single jump.java.lang.Exception
- if minParticles are greater than
the current maxParticles;