2012-12-09 17:49:28 +00:00
|
|
|
#include "private.h"
|
|
|
|
|
2013-01-19 22:42:50 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2012-12-09 17:49:28 +00:00
|
|
|
/*
|
|
|
|
* Terrain presets.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void terrainAutoPreset(TerrainDefinition* definition, TerrainPreset preset)
|
|
|
|
{
|
2013-01-14 12:08:38 +00:00
|
|
|
int resolution = 8;
|
2012-12-09 17:49:28 +00:00
|
|
|
switch (preset)
|
|
|
|
{
|
2013-05-11 21:34:30 +00:00
|
|
|
case TERRAIN_PRESET_STANDARD:
|
|
|
|
noiseRandomizeOffsets(definition->_height_noise);
|
|
|
|
noiseClearLevels(definition->_height_noise);
|
|
|
|
noiseAddLevelSimple(definition->_height_noise, pow(2.0, resolution + 1), -1.0, 1.0);
|
|
|
|
noiseAddLevelsSimple(definition->_height_noise, resolution - 2, pow(2.0, resolution - 1), -0.7, 0.7, 0.5);
|
|
|
|
noiseNormalizeAmplitude(definition->_height_noise, -1.0, 1.0, 0);
|
|
|
|
noiseSetFunctionParams(definition->_height_noise, NOISE_FUNCTION_SIMPLEX, 0.0, 0.0);
|
|
|
|
definition->scaling = 1.0;
|
2013-06-09 13:11:03 +00:00
|
|
|
definition->height = 30.0;
|
2013-05-11 21:34:30 +00:00
|
|
|
definition->shadow_smoothing = 0.03;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
2012-12-09 17:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TerrainDefinitionClass.validate(definition);
|
|
|
|
}
|