Package redempt.redlib.worldgen
Class NoiseGenerator
java.lang.Object
redempt.redlib.worldgen.NoiseGenerator
A Perlin Noise generator which can be faster than
PerlinNoiseGenerator
-
Constructor Summary
ConstructorDescriptionCreates a noise generator with a random seedNoiseGenerator
(long seed) Creates a noise generator with a seed -
Method Summary
Modifier and TypeMethodDescriptiondouble
getScale()
double
double
noise
(double x, double z) Gets a noise value at a specific 2D pointdouble
noise
(double x, double y, double z) Gets a noise value at a specific 3D pointvoid
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 generatorvoid
setWeight
(double weight) Sets the weight of this noise generator.static double
smoothstep
(double first, double second, double w) Smoothly interpolates between two values
-
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 valuesecond
- The second valuew
- 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 aty
- The Y coordinate to generate starting atz
- The Z coordiante 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
-
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 atz
- The Z coordiante to generate starting atwidth
- The width along the X-axis to filllength
- 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 atz
- 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 aty
- The Y coordinate to get the noise atz
- The Z coordinate to get the noise at- Returns:
- A noise value between the weight and the negative weight
-