Amortized Noise Terrain Generator
A Program to Generate Terrain from Amortized Noise with Exponentially Distributed Gradient Magnitude
Functions | Variables
main.cpp File Reference

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

CTerrainGeneratorg_pTerrainGenerator = NULL
 Pointer to the terrain generator.
 

Function Documentation

◆ Generate2DNoise()

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.

Parameters
cellPointer to array in which to store the noise.
xTile column index.
yTile row index.
m0Largest octave.
m1Smallest octave.
nCell size.

◆ GenerateAndSave2DNoise()

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.

Parameters
nRowTile row index.
nColTile column index.
m0Largest octave.
m1Smallest octave.
altitudeMultiplier to convert noise to height.
nCell size.

◆ main()

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.

Parameters
argcArgument count
argvArguments.
Returns
0 for success, 1 for failure.

◆ SaveDEMFile()

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.

Parameters
cellPointer to 2D array of elevations.
nWidth and height of array.
scaleScale value to normalize amortized noise.
altitudeMultiplier to convert noise to height.
basefilenameName of DEM file for output, without extension.