Package com.jme3.terrain.heightmap
Class ParticleDepositionHeightMap
java.lang.Object
com.jme3.terrain.heightmap.AbstractHeightMap
com.jme3.terrain.heightmap.ParticleDepositionHeightMap
- All Implemented Interfaces:
HeightMap
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.-
Field Summary
Fields inherited from class com.jme3.terrain.heightmap.AbstractHeightMap
filter, heightData, heightScale, NORMALIZE_RANGE, size
-
Constructor Summary
ConstructorDescriptionParticleDepositionHeightMap
(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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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 toload
.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.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
-
Constructor Details
-
ParticleDepositionHeightMap
public ParticleDepositionHeightMap(int size, int jumps, int peakWalk, int minParticles, int maxParticles, float caldera) throws Exception Constructor sets the attributes of the Particle Deposition Height Map and then generates the map.- Parameters:
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.- Throws:
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.
-
-
Method Details
-
load
public boolean load()load
generates the heightfield using the Particle Deposition algorithm.load
uses the latest attributes, so a call toload
is recommended if attributes have changed using the set methods.- Returns:
- true if the load was successful, false otherwise.
-
setJumps
setJumps
sets the number of jumps or peaks that will be created during the next call toload
.- Parameters:
jumps
- the number of jumps to use for next load.- Throws:
Exception
- if jumps is less than zero.
-
setPeakWalk
setPeakWalk
sets how often the jump point will be agitated. The lower the peakWalk, the more often the point will be agitated.- Parameters:
peakWalk
- the amount to agitate the jump point.- Throws:
Exception
- if peakWalk is negative or zero.
-
setCaldera
setCaldera
sets the level at which a peak will be inverted.- Parameters:
caldera
- the level at which a peak will be inverted. This must be between 0 and 1, as it is represented as a percentage.- Throws:
Exception
- if caldera is not between 0 and 1.
-
setMaxParticles
public void setMaxParticles(int maxParticles) setMaxParticles
sets the maximum number of particles for a single jump.- Parameters:
maxParticles
- the maximum number of particles for a single jump.
-
setMinParticles
setMinParticles
sets the minimum number of particles for a single jump.- Parameters:
minParticles
- the minimum number of particles for a single jump.- Throws:
Exception
- if minParticles are greater than the current maxParticles;
-