Class MidPointHeightMapGenerator

java.lang.Object
com.ardor3d.extension.terrain.heightmap.MidPointHeightMapGenerator

public class MidPointHeightMapGenerator extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected float
    The filter is used to erode the terrain.
    protected float[]
    Height data information.
    protected float
    Allows scaling the Y height of the map.
    protected int
    The size of the height map's width.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MidPointHeightMapGenerator(int size, float roughness)
    Constructor builds a new height map using the midpoint displacement algorithm.
    MidPointHeightMapGenerator(int size, float roughness, long seed)
    Constructor builds a new height map using the midpoint displacement algorithm.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    erodeTerrain(float[][] tempBuffer)
    erodeTerrain is a convenience method that applies the FIR filter to a given height map.
    boolean
    load generates the height field using the Midpoint Displacement algorithm.
    float[]
     
    float
     
    protected void
    normalizeTerrain(float[][] tempBuffer)
    normalizeTerrain takes the current terrain data and converts it to values between 0 and NORMALIZE_RANGE.
    protected void
    setHeightAtPoint(float height, int x, int z)
    setHeightAtPoint sets the height value for a given coordinate.
    void
    setHeightRange(float heightRange)
     
    void
    setRoughness(float roughness)
    setRoughness sets the new roughness value of the height map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • heightData

      protected float[] heightData
      Height data information.
    • size

      protected int size
      The size of the height map's width.
    • heightScale

      protected float heightScale
      Allows scaling the Y height of the map.
    • filter

      protected float filter
      The filter is used to erode the terrain.
  • Constructor Details

    • MidPointHeightMapGenerator

      public MidPointHeightMapGenerator(int size, float roughness)
      Constructor builds a new height map using the midpoint displacement algorithm. Roughness determines how chaotic the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect creating smooth terrain, and < 1 late iterations have a disproportionately large effect creating chaotic terrain.
      Parameters:
      size - the size of the terrain, must be a power of 2.
      roughness - how chaotic to make the terrain.
      Throws:
      Ardor3dException - if size is less than or equal to zero or roughtness is less than 0.
    • MidPointHeightMapGenerator

      public MidPointHeightMapGenerator(int size, float roughness, long seed)
      Constructor builds a new height map using the midpoint displacement algorithm. Roughness determines how chaotic the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect creating smooth terrain, and < 1 late iterations have a disproportionately large effect creating chaotic terrain.
      Parameters:
      size - the size of the terrain, must be a power of 2.
      roughness - how chaotic to make the terrain.
      seed - the seed
      Throws:
      Ardor3dException - if size is less than or equal to zero or roughtness is less than 0.
  • Method Details

    • getHeightData

      public float[] getHeightData()
      Returns:
      the heightData
    • generateHeightData

      public boolean generateHeightData()
      load generates the height field using the Midpoint Displacement algorithm. load uses the latest attributes, so a call to load is recommended if attributes have changed using the set methods.
      Returns:
      true
    • setRoughness

      public void setRoughness(float roughness)
      setRoughness sets the new roughness value of the height map. Roughness determines how chaotic the terrain will be. Where 1 is perfectly self-similar, > 1 early iterations have a disproportionately large effect creating smooth terrain, and < 1 late iterations have a disproportionately large effect creating chaotic terrain.
      Parameters:
      roughness - how chaotic will the height map be.
    • setHeightAtPoint

      protected void setHeightAtPoint(float height, int x, int z)
      setHeightAtPoint sets the height value for a given coordinate.
      Parameters:
      height - the new height for the coordinate.
      x - the x (east/west) coordinate.
      z - the z (north/south) coordinate.
    • normalizeTerrain

      protected void normalizeTerrain(float[][] tempBuffer)
      normalizeTerrain takes the current terrain data and converts it to values between 0 and NORMALIZE_RANGE.
      Parameters:
      tempBuffer - the terrain to normalize.
    • erodeTerrain

      protected void erodeTerrain(float[][] tempBuffer)
      erodeTerrain is a convenience method that applies the FIR filter to a given height map. This simulates water errosion.
      Parameters:
      tempBuffer - the terrain to filter.
    • getHeightRange

      public float getHeightRange()
    • setHeightRange

      public void setHeightRange(float heightRange)