Class NoiseOctave

java.lang.Object
redempt.redlib.worldgen.NoiseOctave

public class NoiseOctave extends Object
Used to generate noise values for octaves of Perlin Noise
  • Constructor Summary

    Constructors
    Constructor
    Description
    NoiseOctave(int size)
    Creates a noise octave with a random seed
    NoiseOctave(long seed, int size)
    Creates a noise octave with the given seed and size.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    noise(double x, double z)
    Gets the noise value at the given point
    double
    noise(double x, double y, double z)
    Gets the noise value at the given point
    void
    prefill(int x, int z, int width, int length)
    Pre-fills gradient vectors in the noise generators in this octave for the given region.
    void
    prefill(int x, int y, int z, int width, int height, int length)
    Pre-fills gradient vectors in the noise generators in this octave for the given region.
    void
    setScales(double... scales)
    Sets the scale of every noise generator in this octave
    void
    setSeed(long seed)
    Sets the seed of this noise octave.
    void
    setWeights(double... weights)
    Sets the weight of every noise generator in this octave
    int
     

    Methods inherited from class java.lang.Object

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

    • NoiseOctave

      public NoiseOctave(long seed, int size)
      Creates a noise octave with the given seed and size. All noise generators within this octave will be initialized with the seed plus their position inside this octave.
      Parameters:
      seed - The seed to use
      size - The number of noise generators to use
    • NoiseOctave

      public NoiseOctave(int size)
      Creates a noise octave with a random seed
      Parameters:
      size - The number of noise generators to use
  • Method Details

    • setSeed

      public void setSeed(long seed)
      Sets the seed of this noise octave.
      Parameters:
      seed - The seed to set
    • size

      public int size()
      Returns:
      The size of this noise octave
    • setScales

      public void setScales(double... scales)
      Sets the scale of every noise generator in this octave
      Parameters:
      scales - A vararg of scales to set. The length of this vararg must be the same as the size of this noise octave.
    • setWeights

      public void setWeights(double... weights)
      Sets the weight of every noise generator in this octave
      Parameters:
      weights - A vararg of weights to set. The length of this vararg must be the same as the size of this noise octave.
    • prefill

      public void prefill(int x, int z, int width, int length)
      Pre-fills gradient vectors in the noise generators in this octave for the given region. Call this method whenever you know a region you will be repeatedly requesting noise values from, as it significantly increases performance.
      Parameters:
      x - The X coordinate to generate starting at
      z - The Z coordinate to generate starting at
      width - The width along the X-axis to fill
      length - The length along the Z-axis to fill
    • prefill

      public void prefill(int x, int y, int z, int width, int height, int length)
      Pre-fills gradient vectors in the noise generators in this octave for the given region. Call this method whenever you know a region you will be repeatedly requesting noise values from, as it significantly increases performance.
      Parameters:
      x - The X coordinate to generate starting at
      y - The Y coordinate to generate starting at
      z - The Z coordinate 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
    • noise

      public double noise(double x, double z)
      Gets the noise value at the given point
      Parameters:
      x - The X coordinate to get noise at
      z - The Z coordinate to get noise at
      Returns:
      A noise value between -1 and 1
    • noise

      public double noise(double x, double y, double z)
      Gets the noise value at the given point
      Parameters:
      x - The X coordinate to get noise at
      y - The Y coordinate to get noise at
      z - The Z coordinate to get noise at
      Returns:
      A noise value between -1 and 1