Class ParticleDepositionHeightMap

java.lang.Object
com.jme3.terrain.heightmap.AbstractHeightMap
com.jme3.terrain.heightmap.ParticleDepositionHeightMap
All Implemented Interfaces:
HeightMap

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.
  • 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 to load is recommended if attributes have changed using the set methods.
      Returns:
      true if the load was successful, false otherwise.
    • setJumps

      public void setJumps(int jumps) throws Exception
      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:
      Exception - if jumps is less than zero.
    • setPeakWalk

      public void setPeakWalk(int peakWalk) throws Exception
      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

      public void setCaldera(float caldera) throws Exception
      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

      public void setMinParticles(int minParticles) throws Exception
      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;