Package redempt.redlib.worldgen
Class NoiseOctave
java.lang.Object
redempt.redlib.worldgen.NoiseOctave
Used to generate noise values for octaves of Perlin Noise
-
Constructor Summary
ConstructorDescriptionNoiseOctave
(int size) Creates a noise octave with a random seedNoiseOctave
(long seed, int size) Creates a noise octave with the given seed and size. -
Method Summary
Modifier and TypeMethodDescriptiondouble
noise
(double x, double z) Gets the noise value at the given pointdouble
noise
(double x, double y, double z) Gets the noise value at the given pointvoid
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 octavevoid
setSeed
(long seed) Sets the seed of this noise octave.void
setWeights
(double... weights) Sets the weight of every noise generator in this octaveint
size()
-
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 usesize
- 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 atz
- The Z coordinate to generate starting atwidth
- The width along the X-axis to filllength
- 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 aty
- The Y coordinate to generate starting atz
- The Z coordinate to generate starting atwidth
- The width along the X-axis to fillheight
- The height along the Y-axis to filllength
- 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 atz
- 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 aty
- The Y coordinate to get noise atz
- The Z coordinate to get noise at- Returns:
- A noise value between -1 and 1
-