paysages3d/src/definition/CelestialBodyDefinition.cpp
Michaël Lemaire e6fc00a8ad Moon's fractal noise is not saved in scenery
This will make the moon rendering repeatable
2016-01-22 00:40:42 +01:00

34 lines
1.1 KiB
C++

#include "CelestialBodyDefinition.h"
#include <cmath>
#include "Vector3.h"
#include "FloatNode.h"
#include "Scenery.h"
#include "NoiseNode.h"
CelestialBodyDefinition::CelestialBodyDefinition(DefinitionNode *parent, const string &name)
: DefinitionNode(parent, name) {
distance = new FloatNode(this, "distance");
phi = new FloatNode(this, "phi");
theta = new FloatNode(this, "theta");
radius = new FloatNode(this, "radius");
noise = new NoiseNode(this, "noise");
}
Vector3 CelestialBodyDefinition::getGlobalDirection() const {
VectorSpherical spc = {1.0, theta->getValue(), -phi->getValue()};
return Vector3(spc);
}
Vector3 CelestialBodyDefinition::getLocation(bool over_water) const {
VectorSpherical spc = {distance->getValue(), theta->getValue(), -phi->getValue()};
if (over_water) {
return Vector3(spc).sub(VECTOR_DOWN.scale(Scenery::EARTH_RADIUS_SCALED));
} else {
return Vector3(spc);
}
}
double CelestialBodyDefinition::getAngularRadius() const {
return 2.0 * atan(radius->getValue() / distance->getValue());
}