java.lang.Object
org.spongepowered.noise.module.NoiseModule
org.spongepowered.noise.module.source.Voronoi

public class Voronoi extends NoiseModule
Noise module that outputs Voronoi cells.

In mathematics, a Voronoi cell is a region containing all the points that are closer to a specific seed point than to any other seed point. These cells mesh with one another, producing polygon-like formations.

By default, this noise module randomly places a seed point within each unit cube. By modifying the frequency of the seed points, an application can change the distance between seed points. The higher the frequency, the closer together this noise module places the seed points, which reduces the size of the cells. To specify the frequency of the cells, call the setFrequency(double) method.

This noise module assigns each Voronoi cell with a random constant value from a coherent-noise function. The displacement value controls the range of random values to assign to each cell. The range of random values is +/- the displacement value. Call the setDisplacement(double) method to specify the displacement value.

To modify the random positions of the seed points, call the setSeed(int) method.

This noise module can optionally add the distance from the nearest seed to the output value. To enable this feature, call the setEnableDistance(boolean) method. This causes the points in the Voronoi cells to increase in value the further away that point is from the nearest seed point.

Voronoi cells are often used to generate cracked-mud terrain formations or crystal-like textures.

Source Modules
This module does not require any source modules.
  • Field Details

    • DEFAULT_VORONOI_DISPLACEMENT

      public static final double DEFAULT_VORONOI_DISPLACEMENT
      Default displacement to apply to each cell for the Voronoi noise module.
      See Also:
    • DEFAULT_VORONOI_FREQUENCY

      public static final double DEFAULT_VORONOI_FREQUENCY
      Default frequency of the seed points for the Voronoi noise module.
      See Also:
    • DEFAULT_VORONOI_SEED

      public static final int DEFAULT_VORONOI_SEED
      Default seed of the noise function for the Voronoi noise module.
      See Also:
  • Constructor Details

    • Voronoi

      public Voronoi()
  • Method Details

    • displacement

      public double displacement()
      Get the displacement value of the Voronoi cells.

      This noise module assigns each Voronoi cell with a random constant value from a coherent-noise function. The displacement value controls the range of random values to assign to each cell. The range of random values is +/- the displacement value.

      Returns:
      the displacement value of the Voronoi cells
      See Also:
    • setDisplacement

      public void setDisplacement(double displacement)
      Set the displacement value of the Voronoi cells.

      This noise module assigns each Voronoi cell with a random constant value from a coherent-noise function. The displacement value controls the range of random values to assign to each cell. The range of random values is +/- the displacement value.

      Parameters:
      displacement - the displacement value of the Voronoi cells
    • enableDistance

      public boolean enableDistance()
      Get if the distance from the nearest seed point is applied to the output value.

      Applying the distance from the nearest seed point to the output value causes the points in the Voronoi cells to increase in value the further away that point is from the nearest seed point.

      Returns:
      whether to apply the distance to the output value or not
    • setEnableDistance

      public void setEnableDistance(boolean enableDistance)
      Enables or disables applying the distance from the nearest seed point to the output value.

      Applying the distance from the nearest seed point to the output value causes the points in the Voronoi cells to increase in value the further away that point is from the nearest seed point. Setting this value to true (and setting the displacement to a near-zero value) causes this noise module to generate cracked mud formations.

      Parameters:
      enableDistance - whether to apply the distance to the output value or not
    • frequency

      public double frequency()
      Get the frequency of the seed points.

      The frequency determines the size of the Voronoi cells and the distance between these cells.

      Returns:
      the frequency of the seed points
    • setFrequency

      public void setFrequency(double frequency)
      Set the frequency of the seed points.

      The frequency determines the size of the Voronoi cells and the distance between these cells.

      Parameters:
      frequency - the frequency of the seed points
    • seed

      public int seed()
      Get the seed value used by the Voronoi cells.

      The positions of the seed values are calculated by a coherent-noise function. By modifying the seed value, the output of that function changes.

      Returns:
      the seed value
    • setSeed

      public void setSeed(int seed)
      Set the seed value used by the Voronoi cells.

      The positions of the seed values are calculated by a coherent-noise function. By modifying the seed value, the output of that function changes.

      Parameters:
      seed - the seed 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