paysages3d/src/definition/NoiseNode.cpp

42 lines
1 KiB
C++
Raw Normal View History

2015-10-18 22:26:25 +00:00
#include "NoiseNode.h"
#include "NoiseGenerator.h"
#include "Logs.h"
NoiseNode::NoiseNode(DefinitionNode *parent) : DefinitionNode(parent, "noise") {
2015-10-18 22:26:25 +00:00
noise = new NoiseGenerator();
}
NoiseNode::~NoiseNode() {
2015-10-18 22:26:25 +00:00
delete noise;
}
void NoiseNode::setLevels(int levels, double min_value, double max_value) {
2015-10-18 22:26:25 +00:00
noise->clearLevels();
noise->addLevelsSimple(levels, 1.0, -1.0, 1.0, 0.5);
noise->normalizeAmplitude(min_value, max_value, false);
noise->randomizeOffsets();
noise->validate();
}
void NoiseNode::save(PackStream *stream) const {
2015-10-18 22:26:25 +00:00
noise->save(stream);
}
void NoiseNode::load(PackStream *stream) {
2015-10-18 22:26:25 +00:00
noise->load(stream);
}
void NoiseNode::copy(DefinitionNode *destination) const {
if (destination->getTypeName() == getTypeName()) {
2015-10-18 22:26:25 +00:00
noise->copy(((NoiseNode *)destination)->noise);
} else {
2015-12-13 19:08:38 +00:00
Logs::error("Definition") << "Can't copy from " << getTypeName() << " to " << destination->getTypeName()
<< endl;
2015-10-18 22:26:25 +00:00
}
}
void NoiseNode::validate() {
2015-10-18 22:26:25 +00:00
noise->validate();
}