[][src]Module worldgen::noisemap

Generators for finite noise maps

A NoiseMap takes a NoiseProvider and uses it to generate a map of noise.

They have properties that can be set to specify the seed used for noise generation, the size of the generated map, and the scale of the coordinates used for generation.

A simple noise map is created by wrapping a source of noise, and then setting the required properties:

let noise = PerlinNoise::new();

let nm = NoiseMap::new(noise)
    .set(Seed::of("Hello!"))
    .set(Size::of(10, 10))
    .set(Step::of(0.02, 0.02));

By default, a noise map will generate values between -1 and 1, however one can be scaled by multiplying it by an integer:

let nm = nm * 3;

This produces a ScaledNoiseMap, which multiplies all of its values by the factor when they are generated.

Noise maps can also be combined by adding them together:

let nm = nm1 + nm2 * 3;

This final result will be normalised back between -1 and 1.

Once you have the noise map you want, you can then use it to produce a vector of rows of values:

for row in nm.generate_chunk(0, 0).iter() {
    for value in row.iter() {
        print!("{}", value);
    }
    println!("");
}

A noise map is essentially an infinite plane of numbers, and the generate method produces the central chunk of the size specified. You can use the generate_chunk method to generate specific chunks and produce infinite maps.

Structs

NoiseMap

The standard noise map.

NoiseMapCombination

A combination of noise maps.

ScaledNoiseMap

A scaled noise map.

Seed

Sets the seed that is used for generating the noise.

Size

Sets the size of the generated chunks.

Step

Sets the increment in x and y for each coordinate in the noise map.

Traits

NoiseMapGenerator

This trait contains functions used for initially creating and combining noisemaps. (The Mul requirement is used for scaling a noisemap)

NoiseMapGeneratorBase

Base trait for noise maps. This trait containts functions relevent to the actual map generation, and is all that is required for constraints to generate a world.

Property

A property is an option that can be set on a noise map.

Functions

next_id

Returns the next unique noisemap id. If implementing a custom noisemap, use this function to give each instance an id.