Class Select


  • public class Select
    extends Module
    Noise module that outputs the value selected from one of two source modules chosen by the output value from a control module.

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

    Source module 0
    outputs a value
    Source module 1
    outputs a value
    Source module 2
    is known as the control module. If the output value from the control module is with a range of values known as the selection range, this noise module outputs the value from the source module with an index value of 1. Otherwise, this noise module outputs the value from the source module with an index value of 0.

    To specify the bounds of the selection range, call the setBounds(double, double) method.

    An application can pass the control module to the setControlModule(Module) method instead of the Module.setSourceModule(int, Module). This may make the application code easier to read.

    by default, there is an abrupt transition between the output values from the two source modules at the selection-range boundary. To smooth the transition, pass a non-zero value to the setEdgeFalloff(double) method. Higher values result in a smoother transition.

    Source Modules
    This module requires 3 source modules.
    • Field Detail

      • DEFAULT_SELECT_EDGE_FALLOFF

        public static final double DEFAULT_SELECT_EDGE_FALLOFF
        Default edge-falloff value for the Select noise module.
        See Also:
        Constant Field Values
      • DEFAULT_SELECT_LOWER_BOUND

        public static final double DEFAULT_SELECT_LOWER_BOUND
        Default lower bound of the selection range for the Select noise module.
        See Also:
        Constant Field Values
      • DEFAULT_SELECT_UPPER_BOUND

        public static final double DEFAULT_SELECT_UPPER_BOUND
        Default upper bound of the selection range for the Select noise module.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Select

        public Select()
      • Select

        public Select​(Module a,
                      Module b,
                      Module control)
        Create a new Select module with the source modules pre-configured.
        Parameters:
        a - a source module
        b - a source module
        control - the module to select between the two inputs
    • Method Detail

      • getControlModule

        public Module getControlModule()
        Get the control module.

        The control module determines the output value to select. If the output value from the control module is within a range of values known as the selection range, the getValue(double, double, double) method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.

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

        public void setControlModule​(Module m)
        Set the control module.

        The control module determines the output value to select. If the output value from the control module is within a range of values known as the selection range, the getValue(double, double, double) method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.

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

        public double getEdgeFalloff()
        Get the falloff value at the edge transition.

        The falloff value is the width of the edge transition at either edge of the selection range.

        By default, there is an abrupt transition between the output values from the two source modules at the selection-range boundary.

        Returns:
        the falloff value at the edge transition
      • setEdgeFalloff

        public void setEdgeFalloff​(double edgeFalloff)
        Sets the falloff value at the edge transition.

        The falloff value is the width of the edge transition at either edge of the selection range.

        By default, there is an abrupt transition between the values from the two source modules at the boundaries of the selection range.

        For example, if the selection range is 0.5 to 0.8, and the edge falloff value is 0.1, then the getValue(double, double, double) method outputs:

        • the output value from the source module with an index value of 0 if the output value from the control module is less than 0.4 ( = 0.5 - 0.1).
        • a linear blend between the two output values from the two source modules if the output from the control module is between 0.4 (= 0.5 - 0.1) and 0.6 (= 0.5 + 0.1).
        • the output value from the source module with an index value of 1 if the output value from the control module is between 0.6 (= 0.5 + 0.1) and 0.7 (= 0.8 - 0.1).
        • a linear blend between the output values from the two source modules if the output value from the control module is between 0.7 (= 0.8 - 0.1) and 0.9 (= 0.8 - 0.1).
        • the output value from the source module with an index value of 0 if the output value from the control module is greater than 0.9 (= 0.8 + 0.1).
        Parameters:
        edgeFalloff - the falloff value at the edge transition
      • getLowerBound

        public double getLowerBound()
        Get the lower bound of the selection range.

        If the output value from the control module is within the selection range, the getValue(double, double, double) method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.

        Returns:
        the lower bound of the selection range
      • getUpperBound

        public double getUpperBound()
        Get the upper bound of the selection range.

        If the output value from the control module is within the selection range, the getValue(double, double, double) method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.

        Returns:
        the upper bound of the selection range
      • setBounds

        public void setBounds​(double upper,
                              double lower)
        Set the lower and upper bounds of the selection range.

        If the output value from the control module is within the selection range, the getValue(double, double, double) method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.

        Parameters:
        upper - the upper bound
        lower - the lower bound
        Throws:
        IllegalArgumentException - if the lower bound is not less than or equal to the upper bound
      • 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