![]() |
Amortized Noise Terrain Generator
A Program to Generate Terrain from Amortized Noise with Exponentially Distributed Gradient Magnitude
|
Main. More...
#include "defines.h"#include <stdlib.h>#include <stdio.h>#include "TerrainGenerator.h"#include "CPUtime.h"Functions | |
| void | SaveDEMFile (float **cell, const int n, const float scale, const float altitude, const char *basefilename) |
| Save a cell of terrain elevations. More... | |
| float | Generate2DNoise (float **cell, const int x, const int y, const int m0, const int m1, const int n) |
| Generate a cell of amortized noise. More... | |
| void | GenerateAndSave2DNoise (int nRow, int nCol, const int m0, const int m1, const float altitude, const int n) |
| Generate and save a cell of amortized noise. More... | |
| int | main (int argc, char *argv[]) |
| Main. More... | |
Variables | |
| CTerrainGenerator * | g_pTerrainGenerator = NULL |
| Pointer to the terrain generator. | |
| float Generate2DNoise | ( | float ** | cell, |
| const int | x, | ||
| const int | y, | ||
| const int | m0, | ||
| const int | m1, | ||
| const int | n | ||
| ) |
Generate a cell of 2D amortized noise using the infinite amortized noise generator.
| cell | Pointer to array in which to store the noise. |
| x | Tile column index. |
| y | Tile row index. |
| m0 | Largest octave. |
| m1 | Smallest octave. |
| n | Cell size. |
| void GenerateAndSave2DNoise | ( | int | nRow, |
| int | nCol, | ||
| const int | m0, | ||
| const int | m1, | ||
| const float | altitude, | ||
| const int | n | ||
| ) |
Generate a cell of amortized noise and save it as a DEM file. This function allocates memory for the cell, creates an infinite amortized noise generator, uses it to generate the noise, saves it as a DEM file, deallocates the generator and cell memory and returns.
| nRow | Tile row index. |
| nCol | Tile column index. |
| m0 | Largest octave. |
| m1 | Smallest octave. |
| altitude | Multiplier to convert noise to height. |
| n | Cell size. |
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Prompts the user for a random number seed, a tail multiplier and an altitude cap and then generates and saves a 4096x4096 cell of terrain elevations generated using 8 octaves of amortized noise with an exponentially distributed gradient magnitude.
| argc | Argument count |
| argv | Arguments. |
| void SaveDEMFile | ( | float ** | cell, |
| const int | n, | ||
| const float | scale, | ||
| const float | altitude, | ||
| const char * | basefilename | ||
| ) |
Save a cell of noise as a DEM file. The output file will have a ".asc" file expension, which is standard for DEM files.
| cell | Pointer to 2D array of elevations. |
| n | Width and height of array. |
| scale | Scale value to normalize amortized noise. |
| altitude | Multiplier to convert noise to height. |
| basefilename | Name of DEM file for output, without extension. |