2015-10-18 22:26:25 +00:00
|
|
|
#include "NoiseNode.h"
|
|
|
|
|
|
|
|
#include "NoiseGenerator.h"
|
|
|
|
#include "Logs.h"
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
NoiseNode::NoiseNode(DefinitionNode *parent) : DefinitionNode(parent, "noise") {
|
2015-10-18 22:26:25 +00:00
|
|
|
noise = new NoiseGenerator();
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
NoiseNode::~NoiseNode() {
|
2015-10-18 22:26:25 +00:00
|
|
|
delete noise;
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void NoiseNode::save(PackStream *stream) const {
|
2015-10-18 22:26:25 +00:00
|
|
|
noise->save(stream);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void NoiseNode::load(PackStream *stream) {
|
2015-10-18 22:26:25 +00:00
|
|
|
noise->load(stream);
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void NoiseNode::copy(DefinitionNode *destination) const {
|
|
|
|
if (destination->getTypeName() == getTypeName()) {
|
2015-10-18 22:26:25 +00:00
|
|
|
noise->copy(((NoiseNode *)destination)->noise);
|
2015-11-09 21:30:46 +00:00
|
|
|
} else {
|
2015-12-13 18:56:00 +00:00
|
|
|
Logs::error() << "[Definition] Can't copy from " << getTypeName() << " to " << destination->getTypeName() << endl;
|
2015-10-18 22:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void NoiseNode::validate() {
|
2015-10-18 22:26:25 +00:00
|
|
|
noise->validate();
|
|
|
|
}
|