2013-11-16 18:12:42 +00:00
|
|
|
#include "TexturesDefinition.h"
|
|
|
|
|
|
|
|
#include "TextureLayerDefinition.h"
|
|
|
|
|
2015-11-20 00:07:31 +00:00
|
|
|
static DefinitionNode *_layer_constructor(Layers *parent, const std::string &name) {
|
|
|
|
return new TextureLayerDefinition(parent, name);
|
2013-11-16 18:12:42 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
TexturesDefinition::TexturesDefinition(DefinitionNode *parent) : Layers(parent, "textures", _layer_constructor) {
|
2013-11-16 18:12:42 +00:00
|
|
|
}
|
|
|
|
|
2015-12-10 18:40:39 +00:00
|
|
|
void TexturesDefinition::applyPreset(TexturesPreset preset, RandomGenerator &random) {
|
2015-11-20 00:07:31 +00:00
|
|
|
TextureLayerDefinition layer(NULL, "temp");
|
2013-11-16 18:12:42 +00:00
|
|
|
clear();
|
|
|
|
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_MUD, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Mud");
|
|
|
|
addLayer(layer);
|
2013-11-16 18:12:42 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
if (preset == TEXTURES_PRESET_FULL) {
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Ground");
|
|
|
|
addLayer(layer);
|
2013-11-16 18:12:42 +00:00
|
|
|
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_GRASS, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Grass");
|
|
|
|
addLayer(layer);
|
2013-11-16 18:12:42 +00:00
|
|
|
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SAND, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Sand");
|
|
|
|
addLayer(layer);
|
2013-11-16 18:12:42 +00:00
|
|
|
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SNOW, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Snow");
|
|
|
|
addLayer(layer);
|
2015-11-09 21:30:46 +00:00
|
|
|
} else if (preset == TEXTURES_PRESET_IRELAND) {
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Ground");
|
|
|
|
addLayer(layer);
|
2013-11-16 18:12:42 +00:00
|
|
|
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_GRASS, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Grass");
|
|
|
|
addLayer(layer);
|
2015-11-09 21:30:46 +00:00
|
|
|
} else if (preset == TEXTURES_PRESET_ALPS) {
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Ground");
|
|
|
|
addLayer(layer);
|
2013-11-16 18:12:42 +00:00
|
|
|
|
2015-12-10 18:40:39 +00:00
|
|
|
layer.applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SNOW, random);
|
2015-11-20 00:07:31 +00:00
|
|
|
layer.setName("Snow");
|
|
|
|
addLayer(layer);
|
2015-11-09 21:30:46 +00:00
|
|
|
} else if (preset == TEXTURES_PRESET_CANYON) {
|
2013-11-16 18:12:42 +00:00
|
|
|
/* TODO */
|
|
|
|
}
|
|
|
|
}
|
2013-12-29 13:14:49 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
double TexturesDefinition::getMaximalDisplacement() {
|
2013-12-29 13:14:49 +00:00
|
|
|
double result = 0.0;
|
2015-11-20 00:07:31 +00:00
|
|
|
int n = getLayerCount();
|
2015-11-09 21:30:46 +00:00
|
|
|
for (int i = 0; i < n; i++) {
|
2013-12-29 13:14:49 +00:00
|
|
|
result += getTextureLayer(i)->displacement_height;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|