java.lang.Object
org.spongepowered.noise.module.NoiseModule
org.spongepowered.noise.module.combiner.Blend

public class Blend extends NoiseModule
Noise module that outputs a weighted blend of the output values of two source modules given the output of a control module.

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 of 1.

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.
  • Constructor Details

    • Blend

      public Blend()
    • Blend

      public Blend(NoiseModule left, NoiseModule right, NoiseModule control)
      Create a new Blend module with the source modules pre-configured.
      Parameters:
      left - the first source
      right - the second source
      control - the control module
  • Method Details

    • controlModule

      public NoiseModule 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 of 1.

      Returns:
      the control module
      Throws:
      NoModuleException - if no control module has been set yet.
    • setControlModule

      public void setControlModule(NoiseModule module)
      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 of 1.

      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:
      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 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