mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-15 18:19:58 -05:00
Add documentation to Ephemeris classes
Remove unused "Reference" specification from mod files Add osirisrex files to gitgnore Make Ephemeris values into properties
This commit is contained in:
@@ -136,7 +136,9 @@ void BaseModule::internalInitialize() {
|
||||
|
||||
std::vector<Documentation> BaseModule::documentations() const {
|
||||
return {
|
||||
StaticScale::Documentation()
|
||||
StaticScale::Documentation(),
|
||||
StaticEphemeris::Documentation(),
|
||||
SpiceEphemeris::Documentation()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -29,83 +29,118 @@
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SpiceEphemeris";
|
||||
//const std::string keyGhosting = "EphmerisGhosting";
|
||||
#include <openspace/documentation/verifier.h>
|
||||
|
||||
namespace {
|
||||
const std::string KeyBody = "Body";
|
||||
const std::string KeyOrigin = "Observer";
|
||||
const std::string KeyObserver = "Observer";
|
||||
const std::string KeyKernels = "Kernels";
|
||||
|
||||
const std::string ReferenceFrame = "GALACTIC";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Documentation SpiceEphemeris::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
|
||||
return {
|
||||
"Spice Translation",
|
||||
"base_translation_spicetranslation",
|
||||
{
|
||||
{
|
||||
"Type",
|
||||
new StringEqualVerifier("SpiceEphemeris"),
|
||||
"",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyBody,
|
||||
new StringAnnotationVerifier("A valid SPICE NAIF name or identifier"),
|
||||
"This is the SPICE NAIF name for the body whose translation is to be "
|
||||
"computed by the SpiceTranslation. It can either be a fully qualified "
|
||||
"name (such as 'EARTH') or a NAIF integer id code (such as '399').",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyObserver,
|
||||
new StringAnnotationVerifier("A valid SPICE NAIF name or identifier"),
|
||||
"This is the SPICE NAIF name for the parent of the body whose "
|
||||
"translation is to be computed by the SpiceTranslation. It can either be "
|
||||
"a fully qualified name (such as 'SOLAR SYSTEM BARYCENTER') or a NAIF "
|
||||
"integer id code (such as '0').",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyKernels,
|
||||
new OrVerifier(
|
||||
new TableVerifier({
|
||||
{ "*", new StringVerifier }
|
||||
}),
|
||||
new StringVerifier
|
||||
),
|
||||
"A single kernel or list of kernels that this SpiceTranslation depends "
|
||||
"on. All provided kernels will be loaded before any other operation is "
|
||||
"performed.",
|
||||
Optional::Yes
|
||||
}
|
||||
},
|
||||
Exhaustive::Yes
|
||||
};
|
||||
}
|
||||
|
||||
SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: _targetName("")
|
||||
, _originName("")
|
||||
, _position()
|
||||
: _target("target", "Target", "")
|
||||
, _origin("origin", "Origin", "")
|
||||
, _kernelsLoadedSuccessfully(true)
|
||||
{
|
||||
const bool hasBody = dictionary.getValue(KeyBody, _targetName);
|
||||
if (!hasBody)
|
||||
LERROR("SpiceEphemeris does not contain the key '" << KeyBody << "'");
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"SpiceEphemeris"
|
||||
);
|
||||
|
||||
const bool hasObserver = dictionary.getValue(KeyOrigin, _originName);
|
||||
if (!hasObserver)
|
||||
LERROR("SpiceEphemeris does not contain the key '" << KeyOrigin << "'");
|
||||
|
||||
//dictionary.getValue(keyGhosting, _ghosting);
|
||||
|
||||
ghoul::Dictionary kernels;
|
||||
dictionary.getValue(KeyKernels, kernels);
|
||||
for (size_t i = 1; i <= kernels.size(); ++i) {
|
||||
std::string kernel;
|
||||
bool success = kernels.getValue(std::to_string(i), kernel);
|
||||
if (!success) {
|
||||
LERROR("'" << KeyKernels << "' has to be an array-style table");
|
||||
break;
|
||||
}
|
||||
_target = dictionary.value<std::string>(KeyBody);
|
||||
_origin = dictionary.value<std::string>(KeyObserver);
|
||||
|
||||
auto loadKernel = [](const std::string& kernel) {
|
||||
if (!FileSys.fileExists(kernel)) {
|
||||
LERROR("Kernel '" << kernel << "' does not exist");
|
||||
continue;
|
||||
throw SpiceManager::SpiceException("Kernel '" + kernel + "' does not exist");
|
||||
}
|
||||
|
||||
try {
|
||||
SpiceManager::ref().loadKernel(kernel);
|
||||
_kernelsLoadedSuccessfully = true;
|
||||
}
|
||||
catch (const SpiceManager::SpiceException& e) {
|
||||
LERROR("Could not load SPICE kernel: " << e.what());
|
||||
_kernelsLoadedSuccessfully = false;
|
||||
catch (const SpiceManager::SpiceException& exception) {
|
||||
LERRORC("SpiceEphemeris", exception.message);
|
||||
}
|
||||
};
|
||||
|
||||
if (dictionary.hasKey(KeyKernels)) {
|
||||
// Due to the specification, we can be sure it is either a Dictionary or a string
|
||||
if (dictionary.hasValue<std::string>(KeyKernels)) {
|
||||
std::string kernel = dictionary.value<std::string>(KeyKernels);
|
||||
loadKernel(kernel);
|
||||
}
|
||||
else {
|
||||
ghoul::Dictionary kernels = dictionary.value<ghoul::Dictionary>(KeyKernels);
|
||||
for (size_t i = 1; i <= kernels.size(); ++i) {
|
||||
std::string kernel = kernels.value<std::string>(std::to_string(i));
|
||||
loadKernel(kernel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const glm::dvec3& SpiceEphemeris::position() const {
|
||||
glm::dvec3 SpiceEphemeris::position() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void SpiceEphemeris::update(const UpdateData& data) {
|
||||
if (!_kernelsLoadedSuccessfully)
|
||||
return;
|
||||
|
||||
double lightTime = 0.0;
|
||||
glm::dvec3 position = SpiceManager::ref().targetPosition(
|
||||
_targetName, _originName, "GALACTIC", {}, data.time, lightTime);
|
||||
|
||||
//double interval = openspace::ImageSequencer::ref().getIntervalLength();
|
||||
//if (_ghosting == "TRUE" && interval > 60){
|
||||
// double _time = openspace::ImageSequencer::ref().getNextCaptureTime();
|
||||
// SpiceManager::ref().getTargetPosition(_targetName, _originName,
|
||||
// "GALACTIC", "NONE", _time, position, lightTime);
|
||||
//}
|
||||
//
|
||||
|
||||
|
||||
//_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
|
||||
//_position[3] += 3;
|
||||
_position = position * glm::pow(10.0, 3.0);
|
||||
_position = SpiceManager::ref().targetPosition(
|
||||
_target, _origin, ReferenceFrame, {}, data.time, lightTime
|
||||
) * glm::pow(10.0, 3.0);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
} // namespace openspace
|
||||
|
||||
@@ -27,23 +27,25 @@
|
||||
|
||||
#include <openspace/scene/ephemeris.h>
|
||||
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SpiceEphemeris : public Ephemeris {
|
||||
public:
|
||||
SpiceEphemeris(const ghoul::Dictionary& dictionary);
|
||||
virtual const glm::dvec3& position() const;
|
||||
glm::dvec3 position() const;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
static openspace::Documentation Documentation();
|
||||
|
||||
private:
|
||||
std::string _targetName;
|
||||
std::string _originName;
|
||||
properties::StringProperty _target;
|
||||
properties::StringProperty _origin;
|
||||
|
||||
glm::dvec3 _position;
|
||||
bool _kernelsLoadedSuccessfully;
|
||||
//std::string _ghosting;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -24,27 +24,69 @@
|
||||
|
||||
#include <modules/base/ephemeris/staticephemeris.h>
|
||||
|
||||
#include <openspace/documentation/verifier.h>
|
||||
|
||||
namespace {
|
||||
const std::string KeyPosition = "Position";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
StaticEphemeris::StaticEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: _position(0.0, 0.0, 0.0)
|
||||
Documentation StaticEphemeris::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
return {
|
||||
"Static Translation",
|
||||
"base_transform_translation_static",
|
||||
{
|
||||
{
|
||||
"Type",
|
||||
new StringEqualVerifier("StaticEphemeris"),
|
||||
"",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyPosition,
|
||||
new DoubleVector3Verifier,
|
||||
"Specifies the position (in meters) that this scenegraph node is located "
|
||||
"at relative to its parent",
|
||||
Optional::No
|
||||
}
|
||||
},
|
||||
Exhaustive::Yes
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
StaticEphemeris::StaticEphemeris()
|
||||
: _position(
|
||||
"position",
|
||||
"Position",
|
||||
glm::dvec3(0.0),
|
||||
glm::dvec3(-std::numeric_limits<double>::max()),
|
||||
glm::dvec3(std::numeric_limits<double>::max())
|
||||
)
|
||||
{
|
||||
const bool hasPosition = dictionary.hasKeyAndValue<glm::vec3>(KeyPosition);
|
||||
if (hasPosition) {
|
||||
dictionary.getValue(KeyPosition, _position);
|
||||
}
|
||||
addProperty(_position);
|
||||
}
|
||||
|
||||
StaticEphemeris::StaticEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: StaticEphemeris()
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"StaticEphemeris"
|
||||
);
|
||||
|
||||
_position = dictionary.value<glm::dvec3>(KeyPosition);
|
||||
}
|
||||
|
||||
StaticEphemeris::~StaticEphemeris() {}
|
||||
|
||||
const glm::dvec3& StaticEphemeris::position() const {
|
||||
glm::dvec3 StaticEphemeris::position() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void StaticEphemeris::update(const UpdateData&) {}
|
||||
|
||||
} // namespace openspace
|
||||
} // namespace openspace
|
||||
|
||||
@@ -27,17 +27,23 @@
|
||||
|
||||
#include <openspace/scene/ephemeris.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class StaticEphemeris: public Ephemeris {
|
||||
class StaticEphemeris : public Ephemeris {
|
||||
public:
|
||||
StaticEphemeris(const ghoul::Dictionary& dictionary
|
||||
= ghoul::Dictionary());
|
||||
StaticEphemeris();
|
||||
StaticEphemeris(const ghoul::Dictionary& dictionary);
|
||||
virtual ~StaticEphemeris();
|
||||
virtual const glm::dvec3& position() const;
|
||||
virtual glm::dvec3 position() const;
|
||||
virtual void update(const UpdateData& data) override;
|
||||
|
||||
static openspace::Documentation Documentation();
|
||||
|
||||
private:
|
||||
glm::dvec3 _position;
|
||||
properties::DVec3Property _position;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -599,8 +599,7 @@ bool RenderablePlanet::isReady() const {
|
||||
return ready;
|
||||
}
|
||||
|
||||
void RenderablePlanet::render(const RenderData& data)
|
||||
{
|
||||
void RenderablePlanet::render(const RenderData& data) {
|
||||
// activate shader
|
||||
_programObject->activate();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user