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.
-
Field Summary
Fields inherited from class org.spongepowered.noise.module.NoiseModule
sourceModule
-
Constructor Summary
ConstructorDescriptionTerrace()
Terrace
(NoiseModule source) Create a new Terrace module with the source modules pre-configured. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addControlPoint
(double value) Add a control point to the terrace-forming curve.void
Deletes all the control points on the terrace-forming curve.int
Get the number of control points on the terrace-forming curve.double[]
Get the array of control points on the terrace-forming curve.double
get
(double x, double y, double z) Generates an output value given the coordinates of the specified input value.boolean
Determine if the terrace-forming curve between the control points is inverted.void
makeControlPoints
(int controlPointCount) Creates a number of equally-spaced control points that range from -1 to +1.void
setInvertTerraces
(boolean invertTerraces) Enable or disable the inversion of the terrace-forming curve between control points.Methods inherited from class org.spongepowered.noise.module.NoiseModule
setSourceModule, sourceModule, sourceModuleCount
-
Constructor Details
-
Terrace
public Terrace() -
Terrace
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 aNoModuleException
.To determine the number of source modules required by this noise module, call the
NoiseModule.sourceModuleCount()
method.- Specified by:
get
in classNoiseModule
- Parameters:
x
- thex
coordinate of the input valuey
- they
coordinate of the input valuez
- thez
coordinate of the input value- Returns:
- the output value
-