Unlike most other noise modules, the index value assigned to a source module determines its role in the blending operation:
- Source module 0
- Outputs one of the values to blend
- Source module 1
- Outputs one of the values to blend
- Source module 2
- Known as the control module. The control module determines the
weight of the blending operation. Negative values weigh the blend
towards the output value from the source module with an index value
of
0
. Positive values weigh the blend towards the output value from the source module with an index value of1
.
An application can pass the control module to the
setControlModule(NoiseModule)
method instead of the
NoiseModule.setSourceModule(int, NoiseModule)
method. This may make the application
code easier to read.
This noise module uses linear interpolation to perform the blending operation.
- Source Modules
- This module requires 3 source modules.
-
Field Summary
Fields inherited from class org.spongepowered.noise.module.NoiseModule
sourceModule
-
Constructor Summary
ConstructorDescriptionBlend()
Blend
(NoiseModule left, NoiseModule right, NoiseModule control) Create a new Blend module with the source modules pre-configured. -
Method Summary
Modifier and TypeMethodDescriptionReturns the control module.double
get
(double x, double y, double z) Generates an output value given the coordinates of the specified input value.void
setControlModule
(NoiseModule module) Sets the control module.Methods inherited from class org.spongepowered.noise.module.NoiseModule
setSourceModule, sourceModule, sourceModuleCount
-
Constructor Details
-
Blend
public Blend() -
Blend
Create a new Blend module with the source modules pre-configured.- Parameters:
left
- the first sourceright
- the second sourcecontrol
- the control module
-
-
Method Details
-
controlModule
Returns the control module.The control module determines the weight of the blending operation. Negative values weigh the blend towards the output value from the source module with an index value of
0
. Positive values weigh the blend towards the output value from the source module with an index value of1
.- Returns:
- the control module
- Throws:
NoModuleException
- if no control module has been set yet.
-
setControlModule
Sets the control module.The control module determines the weight of the blending operation. Negative values weigh the blend towards the output value from the source module with an index value of
0
. Positive values weigh the blend towards the output value from the source module with an index value of1
.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 theNoiseModule.setSourceModule(int, NoiseModule)
method while assigning that noise module an index value of2
.- Parameters:
module
- the control module
-
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
-