java.lang.Object
org.spongepowered.noise.module.NoiseModule
org.spongepowered.noise.module.modifier.Terrace

public class Terrace extends NoiseModule
Noise module that maps the output value from a source module onto a terrace-forming curve.

This noise module maps the output value from the source module onto a terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increases. This curve also contains control points which resets the slope to zero at that point, producing a "terracing" effect.

To add a control point to this noise module, call the addControlPoint(double) method.

An application must add a minimum of two control points to the curve. If that is not done, the get(double, double, double) method fails. The control points can have any value, although no two control points can have the same value. There is no limit to the number of control points that can be a dded to the curve.

This noise module clamps the output value from the source module if that value is less than the value of the lowest control point or greater than the value of the highest control point.

This noise module is often used to generate terrain features such as your stereotypical desert canyon.

Source Modules
This module requires one source module.
  • Constructor Details

    • Terrace

      public Terrace()
    • Terrace

      public Terrace(NoiseModule source)
      Create a new Terrace module with the source modules pre-configured.
      Parameters:
      source - the input module
  • Method Details

    • invertTerraces

      public boolean invertTerraces()
      Determine if the terrace-forming curve between the control points is inverted.
      Returns:
      true if the curve between the control points is inverted
    • setInvertTerraces

      public void setInvertTerraces(boolean invertTerraces)
      Enable or disable the inversion of the terrace-forming curve between control points.
      Parameters:
      invertTerraces - whether to invert the curve between the control points
    • controlPointCount

      public int controlPointCount()
      Get the number of control points on the terrace-forming curve.
      Returns:
      the number of control points on the terrace-forming curve
    • controlPoints

      public double[] controlPoints()
      Get the array of control points on the terrace-forming curve.

      Two or more control points define the terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increase. At the control points, its slope resets to zero.

      It is recommended that an application does not store this array for later use since the array may be re-allocated if the application calls another method of this object.

      Returns:
      the array of control points in this noise module
    • addControlPoint

      public void addControlPoint(double value)
      Add a control point to the terrace-forming curve.

      Two or more control points define the terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increase. At the control points, its slope resets to zero.

      It does not matter what order these points are added.

      Parameters:
      value - the value of the control point to add. Must not be the same value as any other control point.
    • clearControlPoints

      public void clearControlPoints()
      Deletes all the control points on the terrace-forming curve.
    • makeControlPoints

      public void makeControlPoints(int controlPointCount)
      Creates a number of equally-spaced control points that range from -1 to +1.

      This will replace all existing control points on the terrace-forming curve.

      Two or more control points define the terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increases. At the control points, its slope resets to zero.

      Parameters:
      controlPointCount - the number of control points to generate, must be ≥ 2
    • get

      public double get(double x, double y, double z)
      Description copied from class: NoiseModule
      Generates an output value given the coordinates of the specified input value.

      All source modules required by this module must have been connected with the NoiseModule.setSourceModule(int, NoiseModule) method. If these source modules are not connected, this method will throw a NoModuleException.

      To determine the number of source modules required by this noise module, call the NoiseModule.sourceModuleCount() method.

      Specified by:
      get in class NoiseModule
      Parameters:
      x - the x coordinate of the input value
      y - the y coordinate of the input value
      z - the z coordinate of the input value
      Returns:
      the output value