Class Blend


  • public class Blend
    extends Module
    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(Module) method instead of the Module.setSourceModule(int, Module) 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 Detail

      • Blend

        public Blend()
      • Blend

        public Blend​(Module left,
                     Module right,
                     Module 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 Detail

      • getControlModule

        public Module getControlModule()
        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​(Module 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 Module.setSourceModule(int, Module) method while assigning that noise module an index value of 2.

        Parameters:
        module - the control module
      • 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