com.jmex.terrain.util
Class ParticleDepositionHeightMap

java.lang.Object
  extended by com.jmex.terrain.util.AbstractHeightMap
      extended by com.jmex.terrain.util.ParticleDepositionHeightMap

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.

Version:
$Id: ParticleDepositionHeightMap.java 4133 2009-03-19 20:40:11Z blaine.dev $
Author:
Mark Powell

Field Summary
 
Fields inherited from class com.jmex.terrain.util.AbstractHeightMap
filter, heightData, heightScale, NORMALIZE_RANGE, size
 
Constructor Summary
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.
 
Method Summary
 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 aggitated.
 
Methods inherited from class com.jmex.terrain.util.AbstractHeightMap
erodeTerrain, getHeightMap, getInterpolatedHeight, getScaledHeightAtPoint, getSize, getTrueHeightAtPoint, normalizeTerrain, save, setHeightAtPoint, setHeightScale, setMagnificationFilter, setSize, unloadHeightMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParticleDepositionHeightMap

public 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.

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:
JmeException - 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 Detail

load

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.

Specified by:
load in class AbstractHeightMap
Returns:
true if the load was successful, false otherwise.

setJumps

public void setJumps(int jumps)
setJumps sets the number of jumps or peaks that will be created during the next call to load.

Parameters:
jumps - the number of jumps to use for next load.
Throws:
JmeException - if jumps is less than zero.

setPeakWalk

public void setPeakWalk(int peakWalk)
setPeakWalk sets how often the jump point will be aggitated. The lower the peakWalk, the more often the point will be aggitated.

Parameters:
peakWalk - the amount to aggitate the jump point.
Throws:
JmeException - if peakWalk is negative or zero.

setCaldera

public void setCaldera(float caldera)
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:
JmeException - 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.
Throws:
JmeException - if maxParticles is negative or less than the current number of minParticles.

setMinParticles

public void setMinParticles(int minParticles)
setMinParticles sets the minimum number of particles for a single jump.

Parameters:
minParticles - the minimum number of particles for a single jump.
Throws:
JmeException - if minParticles are greater than the current maxParticles;