Unlike most other noise modules, the index value assigned to a source module determines its role in the selection operation.
- Source module 0
- outputs a value
- Source module 1
- outputs a value
- Source module 2
- is known as the control module. If the output value from the control module is with a range of values known as the selection range, this noise module outputs the value from the source module with an index value of 1. Otherwise, this noise module outputs the value from the source module with an index value of 0.
To specify the bounds of the selection range, call the
setBounds(double, double)
method.
An application can pass the control module to the
setControlModule(NoiseModule)
method instead of the
NoiseModule.setSourceModule(int, NoiseModule)
. This may make the application code
easier to read.
by default, there is an abrupt transition between the output values from
the two source modules at the selection-range boundary. To smooth the
transition, pass a non-zero value to the setEdgeFalloff(double)
method. Higher values result in a smoother transition.
- Source Modules
- This module requires 3 source modules.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
Default edge-falloff value for theSelect
noise module.static final double
Default lower bound of the selection range for theSelect
noise module.static final double
Default upper bound of the selection range for theSelect
noise module.Fields inherited from class org.spongepowered.noise.module.NoiseModule
sourceModule
-
Constructor Summary
ConstructorsConstructorDescriptionSelect()
Select
(NoiseModule a, NoiseModule b, NoiseModule control) Create a new Select module with the source modules pre-configured. -
Method Summary
Modifier and TypeMethodDescriptionGet the control module.double
Get the falloff value at the edge transition.double
get
(double x, double y, double z) Generates an output value given the coordinates of the specified input value.double
Get the lower bound of the selection range.void
setBounds
(double upper, double lower) Set the lower and upper bounds of the selection range.void
Set the control module.void
setEdgeFalloff
(double edgeFalloff) Sets the falloff value at the edge transition.double
Get the upper bound of the selection range.Methods inherited from class org.spongepowered.noise.module.NoiseModule
setSourceModule, sourceModule, sourceModuleCount
-
Field Details
-
DEFAULT_SELECT_EDGE_FALLOFF
public static final double DEFAULT_SELECT_EDGE_FALLOFFDefault edge-falloff value for theSelect
noise module.- See Also:
-
DEFAULT_SELECT_LOWER_BOUND
public static final double DEFAULT_SELECT_LOWER_BOUNDDefault lower bound of the selection range for theSelect
noise module.- See Also:
-
DEFAULT_SELECT_UPPER_BOUND
public static final double DEFAULT_SELECT_UPPER_BOUNDDefault upper bound of the selection range for theSelect
noise module.- See Also:
-
-
Constructor Details
-
Select
public Select() -
Select
Create a new Select module with the source modules pre-configured.- Parameters:
a
- a source moduleb
- a source modulecontrol
- the module to select between the two inputs
-
-
Method Details
-
controlModule
Get the control module.The control module determines the output value to select. If the output value from the control module is within a range of values known as the selection range, the
get(double, double, double)
method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.- Returns:
- the control module
- Throws:
NoModuleException
- if no control module has been set yet
-
setControlModule
Set the control module.The control module determines the output value to select. If the output value from the control module is within a range of values known as the selection range, the
get(double, double, double)
method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.This method assigns the control module an index value of 2. Passing the control module to this method produces the same results as passing the control module to the
NoiseModule.setSourceModule(int, NoiseModule)
method while assigning that noise module an index value of 2.- Parameters:
m
- the control module
-
edgeFalloff
public double edgeFalloff()Get the falloff value at the edge transition.The falloff value is the width of the edge transition at either edge of the selection range.
By default, there is an abrupt transition between the output values from the two source modules at the selection-range boundary.
- Returns:
- the falloff value at the edge transition
-
setEdgeFalloff
public void setEdgeFalloff(double edgeFalloff) Sets the falloff value at the edge transition.The falloff value is the width of the edge transition at either edge of the selection range.
By default, there is an abrupt transition between the values from the two source modules at the boundaries of the selection range.
For example, if the selection range is 0.5 to 0.8, and the edge falloff value is 0.1, then the
get(double, double, double)
method outputs:- the output value from the source module with an index value of
0
if the output value from the control module is less than 0.4 ( = 0.5 - 0.1). - a linear blend between the two output values from the two source modules if the output from the control module is between 0.4 (= 0.5 - 0.1) and 0.6 (= 0.5 + 0.1).
- the output value from the source module with an index value of
1
if the output value from the control module is between 0.6 (= 0.5 + 0.1) and 0.7 (= 0.8 - 0.1). - a linear blend between the output values from the two source modules if the output value from the control module is between 0.7 (= 0.8 - 0.1) and 0.9 (= 0.8 - 0.1).
- the output value from the source module with an index value of
0
if the output value from the control module is greater than 0.9 (= 0.8 + 0.1).
- Parameters:
edgeFalloff
- the falloff value at the edge transition
- the output value from the source module with an index value of
-
lowerBound
public double lowerBound()Get the lower bound of the selection range.If the output value from the control module is within the selection range, the
get(double, double, double)
method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.- Returns:
- the lower bound of the selection range
-
upperBound
public double upperBound()Get the upper bound of the selection range.If the output value from the control module is within the selection range, the
get(double, double, double)
method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.- Returns:
- the upper bound of the selection range
-
setBounds
public void setBounds(double upper, double lower) Set the lower and upper bounds of the selection range.If the output value from the control module is within the selection range, the
get(double, double, double)
method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.- Parameters:
upper
- the upper boundlower
- the lower bound- Throws:
IllegalArgumentException
- if the lower bound is not less than or equal to the upper bound
-
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
-