com.jmex.terrain.util
Class FluidSimHeightMap

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

public class FluidSimHeightMap
extends AbstractHeightMap

FluidSimHeightMap generates a height map based using some sort of fluid simulation. The heightmap is treated as a highly viscous and rubbery fluid enabling to fine tune the generated heightmap using a number of parameters.

Version:
$Id: FluidSimHeightMap.java 4134 2009-03-19 21:04:38Z blaine.dev $
Author:
Frederik Bülthoff
See Also:
Terrain Generation Using Fluid Simulation

Field Summary
(package private)  float coefA
           
(package private)  float coefB
           
(package private)  float coefC
           
 
Fields inherited from class com.jmex.terrain.util.AbstractHeightMap
filter, heightData, heightScale, NORMALIZE_RANGE, size
 
Constructor Summary
FluidSimHeightMap(int size, int iterations)
          Constructor sets the attributes of the hill system and generates the height map.
FluidSimHeightMap(int size, int iterations, float minInitialHeight, float maxInitialHeight, float viscosity, float waveSpeed, float timestep, float nodeDistance, long seed)
          Constructor sets the attributes of the hill system and generates the height map.
 
Method Summary
 boolean load()
          load populates the height map data.
protected  void normalize(float[] buffer)
          Normalizes the heightmap values between 0.0 and 1.0.
 void setIterations(int iterations)
          Sets the number of times the fluid simulation should be iterated over the heightmap.
 void setMaxInitialHeight(float maxInitialHeight)
          Sets the maximum initial height of the terrain.
 void setMinInitialHeight(float minInitialHeight)
          Sets the minimum initial height of the terrain.
 void setNodeDistance(float nodeDistance)
          Sets the distance between each node of the heightmap.
 void setTimeStep(float timeStep)
          Sets the time-speed between each iteration of the fluid simulation algortithm.
 void setViscosity(float viscosity)
          Sets the viscosity of the simulated fuid.
 void setWaveSpeed(float waveSpeed)
          Sets the speed at which the waves trave.
 
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
 

Field Detail

coefA

float coefA

coefB

float coefB

coefC

float coefC
Constructor Detail

FluidSimHeightMap

public FluidSimHeightMap(int size,
                         int iterations,
                         float minInitialHeight,
                         float maxInitialHeight,
                         float viscosity,
                         float waveSpeed,
                         float timestep,
                         float nodeDistance,
                         long seed)
Constructor sets the attributes of the hill system and generates the height map. It gets passed a number of tweakable parameters which fine-tune the outcome.

Parameters:
size - size the size of the terrain to be generated
iterations - the number of iterations to do
minInitialHeight - the minimum initial height of a terrain value
maxInitialHeight - the maximum initial height of a terrain value
viscosity - the viscosity of the fluid
waveSpeed - the speed at which the waves travel
timestep - the constant time-step between each iteration
nodeDistance - the distance between each node of the heightmap
seed - the seed to generate the same heightmap again
Throws:
JmeException - if size of the terrain is not greater that zero, or number of iterations is not greater that zero, or the minimum initial height is greater than the maximum (or the other way around)

FluidSimHeightMap

public FluidSimHeightMap(int size,
                         int iterations)
Constructor sets the attributes of the hill system and generates the height map.

Parameters:
size - size the size of the terrain to be generated
iterations - the number of iterations to do
Throws:
JmeException - if size of the terrain is not greater that zero, or number of iterations is not greater that zero
Method Detail

load

public boolean load()
Description copied from class: AbstractHeightMap
load populates the height map data. This is dependent on the subclass's implementation.

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

normalize

protected void normalize(float[] buffer)
Normalizes the heightmap values between 0.0 and 1.0.

Parameters:
buffer - the buffer holding the heightmap data

setIterations

public void setIterations(int iterations)
Sets the number of times the fluid simulation should be iterated over the heightmap. The more often this is, the less features (hills, etc) the terrain will have, and the smoother it will be.

Parameters:
iterations - the number of iterations to do
Throws:
JmeException - if iterations if not greater than zero

setMaxInitialHeight

public void setMaxInitialHeight(float maxInitialHeight)
Sets the maximum initial height of the terrain.

Parameters:
maxInitialHeight - the maximum initial height
See Also:
#setMinInitialHeight(int)

setMinInitialHeight

public void setMinInitialHeight(float minInitialHeight)
Sets the minimum initial height of the terrain.

Parameters:
minInitialHeight - the minimum initial height
See Also:
#setMaxInitialHeight(int)

setNodeDistance

public void setNodeDistance(float nodeDistance)
Sets the distance between each node of the heightmap.

Parameters:
nodeDistance - the distance between each node

setTimeStep

public void setTimeStep(float timeStep)
Sets the time-speed between each iteration of the fluid simulation algortithm.

Parameters:
timeStep - the time-step between each iteration

setViscosity

public void setViscosity(float viscosity)
Sets the viscosity of the simulated fuid.

Parameters:
viscosity - the viscosity of the fluid

setWaveSpeed

public void setWaveSpeed(float waveSpeed)
Sets the speed at which the waves trave.

Parameters:
waveSpeed - the speed at which the waves travel