Class Displace


  • public class Displace
    extends Module
    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 getValue(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 Detail

      • Displace

        public Displace()
      • Displace

        public Displace​(Module source,
                        Module xDisplace,
                        Module yDisplace,
                        Module 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 Detail

      • getXDisplaceModule

        public Module getXDisplaceModule()
        Gets the x displacement module.

        The getValue(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​(Module x)
        Sets the x displacement module.

        The getValue(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 Module.setSourceModule(int, Module) method while assigning it an index value of 1.

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

        public Module getYDisplaceModule()
        Gets the y displacement module.

        The getValue(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​(Module y)
        Sets the y displacement module.

        The getValue(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 Module.setSourceModule(int, Module) method while assigning it an index value of 2.

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

        public Module getZDisplaceModule()
        Gets the z displacement module.

        The getValue(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​(Module z)
        Sets the z displacement module.

        The getValue(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 Module.setSourceModule(int, Module) method while assigning it an index value of 3.

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

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

        The getValue(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
      • getValue

        public double getValue​(double x,
                               double y,
                               double z)
        Description copied from class: Module
        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 Module.setSourceModule(int, Module) 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 Module.getSourceModuleCount() method.

        Specified by:
        getValue in class Module
        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