Class NoiseGenerator

java.lang.Object
redempt.redlib.worldgen.NoiseGenerator

public class NoiseGenerator extends Object
A Perlin Noise generator which can be faster than PerlinNoiseGenerator
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a noise generator with a random seed
    NoiseGenerator(long seed)
    Creates a noise generator with a seed
  • Method Summary

    Modifier and Type
    Method
    Description
    double
     
    double
     
    double
    noise(double x, double z)
    Gets a noise value at a specific 2D point
    double
    noise(double x, double y, double z)
    Gets a noise value at a specific 3D point
    void
    prefill(int x, int z, int width, int length)
    Pre-fills the gradient vectors in the specified area of this noise generator.
    void
    prefill(int x, int y, int z, int width, int height, int length)
    Pre-fills the gradient vectors in the specified area of this noise generator.
    void
    setScale(double scale)
    Sets the scale of this noise generator.
    void
    setSeed(long seed)
    Set the seed of this noise generator
    void
    setWeight(double weight)
    Sets the weight of this noise generator.
    static double
    smoothstep(double first, double second, double w)
    Smoothly interpolates between two values

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NoiseGenerator

      public NoiseGenerator(long seed)
      Creates a noise generator with a seed
      Parameters:
      seed - The seed to use
    • NoiseGenerator

      public NoiseGenerator()
      Creates a noise generator with a random seed
  • Method Details

    • smoothstep

      public static double smoothstep(double first, double second, double w)
      Smoothly interpolates between two values
      Parameters:
      first - The first value
      second - The second value
      w - The ratio
      Returns:
      The smoothly interpolated value
    • setScale

      public void setScale(double scale)
      Sets the scale of this noise generator. All inputs will be multiplied by the scale. Default value is 1.
      Parameters:
      scale - The scale to set
    • setWeight

      public void setWeight(double weight)
      Sets the weight of this noise generator. All outputs will be multiplied by the weight. Default value is 1.
      Parameters:
      weight - The weight to set
    • getScale

      public double getScale()
      Returns:
      The scale of this noise generator
    • getWeight

      public double getWeight()
      Returns:
      The weight of this noise generator
    • setSeed

      public void setSeed(long seed)
      Set the seed of this noise generator
      Parameters:
      seed - The seed to set
    • prefill

      public void prefill(int x, int y, int z, int width, int height, int length)
      Pre-fills the gradient vectors in the specified area of this noise generator. Call this method if you know what region you are going to be repeatedly requesting noise values from, as it significantly improves performance. Inputs for this method are scaled according to the scale of this noise generator.
      Parameters:
      x - The X coordinate to generate starting at
      y - The Y coordinate to generate starting at
      z - The Z coordiante to generate starting at
      width - The width along the X-axis to fill
      height - The height along the Y-axis to fill
      length - The length along the Z-axis to fill
    • prefill

      public void prefill(int x, int z, int width, int length)
      Pre-fills the gradient vectors in the specified area of this noise generator. Call this method if you know what region you are going to be repeatedly requesting noise values from, as it significantly improves performance. Inputs for this method are scaled according to the scale of this noise generator.
      Parameters:
      x - The X coordinate to generate starting at
      z - The Z coordiante to generate starting at
      width - The width along the X-axis to fill
      length - The length along the Z-axis to fill
    • noise

      public double noise(double x, double z)
      Gets a noise value at a specific 2D point
      Parameters:
      x - The X coordinate to get the noise at
      z - The Z coordinate to get the noise at
      Returns:
      A noise value between the weight and the negative weight
    • noise

      public double noise(double x, double y, double z)
      Gets a noise value at a specific 3D point
      Parameters:
      x - The X coordinate to get the noise at
      y - The Y coordinate to get the noise at
      z - The Z coordinate to get the noise at
      Returns:
      A noise value between the weight and the negative weight