2015-12-29 23:20:20 +00:00
|
|
|
#include "CelestialBodyDefinition.h"
|
|
|
|
|
2016-01-15 17:01:01 +00:00
|
|
|
#include <cmath>
|
2015-12-29 23:20:20 +00:00
|
|
|
#include "Vector3.h"
|
|
|
|
#include "FloatNode.h"
|
2016-01-14 23:39:33 +00:00
|
|
|
#include "Scenery.h"
|
2016-01-21 23:40:42 +00:00
|
|
|
#include "NoiseNode.h"
|
2016-01-14 23:07:02 +00:00
|
|
|
|
2015-12-29 23:20:20 +00:00
|
|
|
CelestialBodyDefinition::CelestialBodyDefinition(DefinitionNode *parent, const string &name)
|
|
|
|
: DefinitionNode(parent, name) {
|
2016-01-14 23:07:02 +00:00
|
|
|
distance = new FloatNode(this, "distance");
|
2015-12-29 23:20:20 +00:00
|
|
|
phi = new FloatNode(this, "phi");
|
|
|
|
theta = new FloatNode(this, "theta");
|
|
|
|
radius = new FloatNode(this, "radius");
|
2016-01-21 23:40:42 +00:00
|
|
|
noise = new NoiseNode(this, "noise");
|
2015-12-29 23:20:20 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 17:01:01 +00:00
|
|
|
Vector3 CelestialBodyDefinition::getGlobalDirection() const {
|
|
|
|
VectorSpherical spc = {1.0, theta->getValue(), -phi->getValue()};
|
|
|
|
return Vector3(spc);
|
|
|
|
}
|
|
|
|
|
2016-01-14 23:07:02 +00:00
|
|
|
Vector3 CelestialBodyDefinition::getLocation(bool over_water) const {
|
|
|
|
VectorSpherical spc = {distance->getValue(), theta->getValue(), -phi->getValue()};
|
|
|
|
if (over_water) {
|
2016-01-14 23:39:33 +00:00
|
|
|
return Vector3(spc).sub(VECTOR_DOWN.scale(Scenery::EARTH_RADIUS_SCALED));
|
2016-01-14 23:07:02 +00:00
|
|
|
} else {
|
|
|
|
return Vector3(spc);
|
|
|
|
}
|
2015-12-29 23:20:20 +00:00
|
|
|
}
|
2016-01-15 17:01:01 +00:00
|
|
|
|
|
|
|
double CelestialBodyDefinition::getAngularRadius() const {
|
|
|
|
return 2.0 * atan(radius->getValue() / distance->getValue());
|
|
|
|
}
|