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

public class Displace extends NoiseModule
Noise module that uses three source modules to displace each coordinate of the input value before returning the output value from a source module.

Unlike most other noise modules, the index value assigned to a source module determines its role in the displacement operation:

Source module 0
Outputs a value
Source module 1
specifies the offset to apply to the x coordinate of the input value.
Source module 2
specifies the offset to apply to the y coordinate of the input value.
Source module 3
specifies the offset to apply to the z coordinate of the input value.

The get(double, double, double) method modifies the (x, y, z) coordinates of the input value using the output values from the three displacement modules before retrieving the output value from the source module.

The Turbulence noise module is a special case of the displacement module. Internally, there are three Perlin-noise modules that perform the displacement operation.

Source Modules
This module requires 4 source modules.
  • Constructor Details

    • Displace

      public Displace()
    • Displace

      public Displace(NoiseModule source, NoiseModule xDisplace, NoiseModule yDisplace, NoiseModule zDisplace)
      Create a new Displace module with the source modules pre-configured.
      Parameters:
      source - the source
      xDisplace - the x displacement module
      yDisplace - the y displacement module
      zDisplace - the z displacement module
  • Method Details

    • xDisplaceModule

      public NoiseModule xDisplaceModule()
      Gets the x displacement module.

      The get(double, double, double) method displaces the input value by adding the output value from this displacement module to the x coordinate of the input value before returning the output value from the source module.

      Returns:
      the x displacement module
      Throws:
      NoModuleException - if this displacement module has not yet been set
    • setXDisplaceModule

      public void setXDisplaceModule(NoiseModule x)
      Sets the x displacement module.

      The get(double, double, double) method displaces the input value by adding the output value from this displacement module to the x coordinate of the input value before returning the output value from the source module.

      This method assigns an index value of 1 to the x displacement module. Passing the displacement module to this method produces the same results as passing the displacement module to the NoiseModule.setSourceModule(int, NoiseModule) method while assigning it an index value of 1.

      Parameters:
      x - displacement module that displaces the x coordinate
    • yDisplaceModule

      public NoiseModule yDisplaceModule()
      Gets the y displacement module.

      The get(double, double, double) method displaces the input value by adding the output value from this displacement module to the y coordinate of the input value before returning the output value from the source module.

      Returns:
      the y displacement module
      Throws:
      NoModuleException - if this displacement module has not yet been set
    • setYDisplaceModule

      public void setYDisplaceModule(NoiseModule y)
      Sets the y displacement module.

      The get(double, double, double) method displaces the input value by adding the output value from this displacement module to the y coordinate of the input value before returning the output value from the source module.

      This method assigns an index value of 2 to the y displacement module. Passing the displacement module to this method produces the same results as passing the displacement module to the NoiseModule.setSourceModule(int, NoiseModule) method while assigning it an index value of 2.

      Parameters:
      y - displacement module that displaces the y coordinate
    • zDisplaceModule

      public NoiseModule zDisplaceModule()
      Gets the z displacement module.

      The get(double, double, double) method displaces the input value by adding the output value from this displacement module to the z coordinate of the input value before returning the output value from the source module.

      Returns:
      the z displacement module
      Throws:
      NoModuleException - if this displacement module has not yet been set
    • setZDisplaceModule

      public void setZDisplaceModule(NoiseModule z)
      Sets the z displacement module.

      The get(double, double, double) method displaces the input value by adding the output value from this displacement module to the z coordinate of the input value before returning the output value from the source module.

      This method assigns an index value of 3 to the z displacement module. Passing the displacement module to this method produces the same results as passing the displacement module to the NoiseModule.setSourceModule(int, NoiseModule) method while assigning it an index value of 3.

      Parameters:
      z - displacement module that displaces the z coordinate
    • setDisplaceModules

      public void setDisplaceModules(NoiseModule x, NoiseModule y, NoiseModule z)
      Set the x, y, and z displacement modules.

      The get(double, double, double) method displaces the input value by adding the output value from each of the displacement modules to the corresponding coordinates of the input value before returning the output value from the source module.

      This method assigns an index value of 1 to the x displacement module, an index value of 2 to the y displacement module, and an index value of 3 to the z displacement module.

      Parameters:
      x - module that displaces the x coordinate of the input value
      y - module that displaces the y coordinate of the input value
      z - module that displaces the z coordinate of the input value
    • 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