2015-10-18 15:26:19 +00:00
|
|
|
#include "VegetationDefinition.h"
|
|
|
|
|
|
|
|
#include "VegetationLayerDefinition.h"
|
|
|
|
#include "VegetationModelDefinition.h"
|
|
|
|
|
2015-11-20 00:16:48 +00:00
|
|
|
static DefinitionNode *_layer_constructor(Layers *parent, const std::string &name) {
|
|
|
|
return new VegetationLayerDefinition(parent, name);
|
2015-10-18 15:26:19 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:38:00 +00:00
|
|
|
VegetationDefinition::VegetationDefinition(DefinitionNode *parent) : Layers(parent, "vegetation", _layer_constructor) {
|
2015-10-18 15:26:19 +00:00
|
|
|
}
|
|
|
|
|
2015-11-09 21:38:00 +00:00
|
|
|
double VegetationDefinition::getMaxHeight() const {
|
2015-11-02 22:00:02 +00:00
|
|
|
double max_height = 0.0;
|
2015-11-20 00:16:48 +00:00
|
|
|
int n = getLayerCount();
|
2015-11-02 22:00:02 +00:00
|
|
|
|
2015-11-09 21:38:00 +00:00
|
|
|
for (int i = 0; i < n; i++) {
|
2015-11-02 22:00:02 +00:00
|
|
|
double layer_height = getVegetationLayer(i)->getMaxHeight();
|
2015-11-09 21:38:00 +00:00
|
|
|
if (layer_height > max_height) {
|
2015-11-02 22:00:02 +00:00
|
|
|
max_height = layer_height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return max_height;
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:38:00 +00:00
|
|
|
void VegetationDefinition::applyPreset(VegetationPreset preset) {
|
2015-11-20 00:16:48 +00:00
|
|
|
VegetationLayerDefinition layer(this, "temp");
|
2015-10-18 15:26:19 +00:00
|
|
|
|
|
|
|
clear();
|
|
|
|
|
2015-11-09 21:38:00 +00:00
|
|
|
if (preset == VEGETATION_PRESET_TEMPERATE) {
|
2015-11-20 00:16:48 +00:00
|
|
|
layer.applyPreset(VegetationLayerDefinition::VEGETATION_BASIC_TREES);
|
|
|
|
layer.setName("Basic tree");
|
|
|
|
addLayer(layer);
|
2015-10-18 15:26:19 +00:00
|
|
|
}
|
|
|
|
}
|