2013-11-16 18:12:42 +00:00
|
|
|
#include "TexturesDefinition.h"
|
|
|
|
|
|
|
|
#include "TextureLayerDefinition.h"
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
static DefinitionNode *_layer_constructor(Layers *parent) {
|
2013-11-16 18:12:42 +00:00
|
|
|
return new TextureLayerDefinition(parent);
|
|
|
|
}
|
|
|
|
|
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-11-09 21:30:46 +00:00
|
|
|
void TexturesDefinition::applyPreset(TexturesPreset preset) {
|
|
|
|
TextureLayerDefinition *layer;
|
2013-11-16 18:12:42 +00:00
|
|
|
clear();
|
|
|
|
|
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_MUD);
|
|
|
|
layer->setName("Mud");
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
if (preset == TEXTURES_PRESET_FULL) {
|
2013-11-16 18:12:42 +00:00
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK);
|
|
|
|
layer->setName("Ground");
|
|
|
|
|
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_GRASS);
|
|
|
|
layer->setName("Grass");
|
|
|
|
|
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SAND);
|
|
|
|
layer->setName("Sand");
|
|
|
|
|
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SNOW);
|
|
|
|
layer->setName("Snow");
|
2015-11-09 21:30:46 +00:00
|
|
|
} else if (preset == TEXTURES_PRESET_IRELAND) {
|
2013-11-16 18:12:42 +00:00
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK);
|
|
|
|
layer->setName("Ground");
|
|
|
|
|
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_GRASS);
|
|
|
|
layer->setName("Grass");
|
2015-11-09 21:30:46 +00:00
|
|
|
} else if (preset == TEXTURES_PRESET_ALPS) {
|
2013-11-16 18:12:42 +00:00
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_ROCK);
|
|
|
|
layer->setName("Ground");
|
|
|
|
|
|
|
|
layer = getTextureLayer(addLayer());
|
|
|
|
layer->applyPreset(TextureLayerDefinition::TEXTURES_LAYER_PRESET_SNOW);
|
|
|
|
layer->setName("Snow");
|
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;
|
|
|
|
int n = count();
|
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;
|
|
|
|
}
|