enum Function{SIMPLEX, GRADIENT};
struct DensityNoise
{
float xScale, yScale, zScale, extra, magnitude;
int function;
int occurrence;
};
struct TypeNoise
{
float xScale, yScale, zScale, extra, threshold;
int type;
int function;
int occurrence;
};
struct OccurrenceNoise
{
float xScale, yScale, zScale, extra, magnitude, minCap, maxCap;
int function;
};
struct BiomeNoise
{
float xScale, yScale, zScale;
};
struct BiomeRule
{
int noise;
float low;
float high;
};
struct Biome
{
Biome()
{
occurrenceNoiseAmount = 0;
densityNoiseAmount = 0;
typeNoiseAmount = 0;
ruleAmount = 0;
r = 0.5f;
g = 0.5f;
b = 0.5f;
}
void addDensityNoise(float xScale, float yScale, float zScale, float extra, float magnitude, Function function, int occurrence)
{
densityNoises[densityNoiseAmount].xScale = xScale;
densityNoises[densityNoiseAmount].yScale = yScale;
densityNoises[densityNoiseAmount].zScale = zScale;
densityNoises[densityNoiseAmount].extra = extra;
densityNoises[densityNoiseAmount].magnitude = fabs(magnitude);
densityNoises[densityNoiseAmount].function = function;
densityNoises[densityNoiseAmount].occurrence = occurrence;
if(function == GRADIENT)
{
Vector3D vector;
vector.setValue(xScale, yScale, zScale);
vector = vector.normalise();
densityNoises[densityNoiseAmount].xScale = vector.getX();
densityNoises[densityNoiseAmount].yScale = vector.getY();
densityNoises[densityNoiseAmount].zScale = vector.getZ();
}
densityNoiseAmount++;
}
void addTypeNoise(float xScale, float yScale, float zScale, float extra, float threshold, int type, Function function, int occurrence)
{
typeNoises[typeNoiseAmount].xScale = xScale;
typeNoises[typeNoiseAmount].yScale = yScale;
typeNoises[typeNoiseAmount].zScale = zScale;
typeNoises[typeNoiseAmount].extra = extra;
typeNoises[typeNoiseAmount].threshold = threshold;
typeNoises[typeNoiseAmount].type = type;
typeNoises[typeNoiseAmount].function = function;
typeNoises[typeNoiseAmount].occurrence = occurrence;
if(function == GRADIENT)
{
Vector3D vector;
vector.setValue(xScale, yScale, zScale);
vector = vector.normalise();
typeNoises[typeNoiseAmount].xScale = vector.getX();
typeNoises[typeNoiseAmount].yScale = vector.getY();
typeNoises[typeNoiseAmount].zScale = vector.getZ();
}
typeNoiseAmount++;
}
void addOccurrenceNoise(float xScale, float yScale, float zScale, float extra, float magnitude, Function function, float minCap, float maxCap)
{
occurrenceNoises[occurrenceNoiseAmount].xScale = xScale;
occurrenceNoises[occurrenceNoiseAmount].yScale = yScale;
occurrenceNoises[occurrenceNoiseAmount].zScale = zScale;
occurrenceNoises[occurrenceNoiseAmount].extra = extra;
occurrenceNoises[occurrenceNoiseAmount].magnitude = fabs(magnitude);
occurrenceNoises[occurrenceNoiseAmount].function = function;
occurrenceNoises[occurrenceNoiseAmount].minCap = minCap;
occurrenceNoises[occurrenceNoiseAmount].maxCap = maxCap;
if(function == GRADIENT)
{
Vector3D vector;
vector.setValue(xScale, yScale, zScale);
vector = vector.normalise();
occurrenceNoises[occurrenceNoiseAmount].xScale = vector.getX();
occurrenceNoises[occurrenceNoiseAmount].yScale = vector.getY();
occurrenceNoises[occurrenceNoiseAmount].zScale = vector.getZ();
}
}
void addRule(int noise, float low, float high)
{
rules[ruleAmount].noise = noise;
rules[ruleAmount].low= low;
rules[ruleAmount].high = high;
ruleAmount++;
}
int defaultType;
int surfaceLevel;
int surfaceType;
BiomeRule rules[5];
int ruleAmount;
OccurrenceNoise occurrenceNoises[8];
int occurrenceNoiseAmount;
DensityNoise densityNoises[8];
int densityNoiseAmount;
TypeNoise typeNoises[8];
int typeNoiseAmount;
float r, g, b;
};
struct BiomeSettings
{
BiomeSettings()
{
biomeNoiseAmount = 0;
biomeAmount = 0;
}
void addBiome(Biome biome)
{
biomes[biomeAmount] = biome;
biomeAmount++;
}
void addBiomeNoise(float xScale, float yScale, float zScale)
{
biomeNoises[biomeNoiseAmount].xScale = xScale;
biomeNoises[biomeNoiseAmount].yScale = yScale;
biomeNoises[biomeNoiseAmount].zScale = zScale;
biomeNoiseAmount++;
}
Biome biomes[25];
int biomeAmount;
BiomeNoise biomeNoises[5];
int biomeNoiseAmount;
};
struct Landscape
{
unsigned int seed;
BiomeSettings biomeSettings;
};