diff --git a/data/assets/examples/rotation/spicerotation/spice.asset b/data/assets/examples/rotation/spicerotation/spice.asset index e084dde9bb..be46c5f4ba 100644 --- a/data/assets/examples/rotation/spicerotation/spice.asset +++ b/data/assets/examples/rotation/spicerotation/spice.asset @@ -3,8 +3,9 @@ -- SceneGraphNode that only displays coordinate axes. The rotation of the coordinate axes -- are determined by SPICE, in this case pretending that the coordinate axes are rotating -- at the same rate as Earth. +-- For more information about SPICE see: https://naif.jpl.nasa.gov/naif/ --- Load the default SPICE kernels, which is the planetary constants and the DE430 kernel +-- Load the default SPICE kernels, which are the planetary constants and the DE430 kernel asset.require("spice/core") local Node = { diff --git a/data/assets/examples/translation/spicetranslation/fixeddate.asset b/data/assets/examples/translation/spicetranslation/fixeddate.asset new file mode 100644 index 0000000000..93285faa76 --- /dev/null +++ b/data/assets/examples/translation/spicetranslation/fixeddate.asset @@ -0,0 +1,38 @@ +-- Fixed Date +-- This asset creates a time-varying translation with information from a SPICE kernel and +-- applies it to a SceneGraphNode that only displays coordinate axes. The position of the +-- coordinate axes are determined by SPICE, in this case pretending that the axes are +-- orbiting the same way the Moon does around Earth. In this specific example, the +-- position is independent of the actual in-game time in OpenSpace and only uses a fixed +-- date of 2000 JAN 01 instead. +-- For more information about SPICE see: https://naif.jpl.nasa.gov/naif/ + +-- Load the default SPICE kernels, which are the planetary constants and the DE430 kernel +asset.require("spice/core") + +local Node = { + Identifier = "SpiceTranslation_Example_FixedDate", + Transform = { + Translation = { + Type = "SpiceTranslation", + Target = "MOON", + Observer = "EARTH", + FixedDate = "2000 JAN 01 00:00:00.000" + } + }, + Renderable = { + Type = "RenderableCartesianAxes" + }, + GUI = { + Name = "SpiceTranslation - Fixed Date", + Path = "/Examples" + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(Node) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(Node) +end) diff --git a/data/assets/examples/translation/spicetranslation/referenceframe.asset b/data/assets/examples/translation/spicetranslation/referenceframe.asset new file mode 100644 index 0000000000..cb16f29b19 --- /dev/null +++ b/data/assets/examples/translation/spicetranslation/referenceframe.asset @@ -0,0 +1,37 @@ +-- Reference Frame +-- This asset creates a time-varying translation with information from a SPICE kernel and +-- applies it to a SceneGraphNode that only displays coordinate axes. The position of the +-- coordinate axes are determined by SPICE, in this case pretending that the axes are +-- orbiting the same way the Moon does around Earth. The calculated position will be +-- provided in the rotating coordinate system of Earth itself. +-- For more information about SPICE see: https://naif.jpl.nasa.gov/naif/ + +-- Load the default SPICE kernels, which are the planetary constants and the DE430 kernel +asset.require("spice/core") + +local Node = { + Identifier = "SpiceTranslation_Example_ReferenceFrame", + Transform = { + Translation = { + Type = "SpiceTranslation", + Target = "MOON", + Observer = "EARTH", + Frame = "IAU_EARTH" + } + }, + Renderable = { + Type = "RenderableCartesianAxes" + }, + GUI = { + Name = "SpiceTranslation - Reference Frame", + Path = "/Examples" + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(Node) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(Node) +end) diff --git a/data/assets/examples/translation/spicetranslation/spice.asset b/data/assets/examples/translation/spicetranslation/spice.asset new file mode 100644 index 0000000000..49b33775e5 --- /dev/null +++ b/data/assets/examples/translation/spicetranslation/spice.asset @@ -0,0 +1,35 @@ +-- Basic +-- This asset creates a time-varying translation with information from a SPICE kernel and +-- applies it to a SceneGraphNode that only displays coordinate axes. The position of the +-- coordinate axes are determined by SPICE, in this case pretending that the axes are +-- orbiting the same way the Moon does around Earth. +-- For more information about SPICE see: https://naif.jpl.nasa.gov/naif/ + +-- Load the default SPICE kernels, which are the planetary constants and the DE430 kernel +asset.require("spice/core") + +local Node = { + Identifier = "SpiceTranslation_Example", + Transform = { + Translation = { + Type = "SpiceTranslation", + Target = "MOON", + Observer = "EARTH" + } + }, + Renderable = { + Type = "RenderableCartesianAxes" + }, + GUI = { + Name = "SpiceTranslation - Basic", + Path = "/Examples" + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(Node) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(Node) +end) diff --git a/modules/space/translation/spicetranslation.cpp b/modules/space/translation/spicetranslation.cpp index e8bddcc75f..80025e78d4 100644 --- a/modules/space/translation/spicetranslation.cpp +++ b/modules/space/translation/spicetranslation.cpp @@ -41,34 +41,39 @@ namespace { constexpr openspace::properties::Property::PropertyInfo TargetInfo = { "Target", "Target", - "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').", + "This is the SPICE 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'). The resulting translation will be a " + "vector leading from the `Target` to the `Observer`.", openspace::properties::Property::Visibility::AdvancedUser }; constexpr openspace::properties::Property::PropertyInfo ObserverInfo = { "Observer", "Observer", - "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').", + "This is the SPICE 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'). The " + "resulting translation will be a vector leading from the `Target` to the " + "`Observer`.", openspace::properties::Property::Visibility::AdvancedUser }; constexpr openspace::properties::Property::PropertyInfo FrameInfo = { "Frame", "Reference Frame", - "This is the SPICE NAIF name for the reference frame in which the position " - "should be retrieved. The default value is GALACTIC.", + "This is the SPICE name of the reference frame in which the position should be " + "calculated. The default value is GALACTIC.", openspace::properties::Property::Visibility::AdvancedUser }; constexpr openspace::properties::Property::PropertyInfo FixedDateInfo = { "FixedDate", "Fixed Date", - "A time to lock the position to. Setting this to an empty string will " - "unlock the time and return to position based on current simulation time.", + "If this value is specified, the position will be locked to a specific time " + "rather than following the in-game in the system. Setting this to an empty " + "string will unlock the time and return to position based on current simulation " + "time.", openspace::properties::Property::Visibility::User }; @@ -82,8 +87,8 @@ namespace { std::optional frame [[codegen::annotation("A valid SPICE NAIF name for a reference frame")]]; - std::optional fixedDate - [[codegen::annotation("A date to lock the position to")]]; + // [[codegen::verbatim(FixedDateInfo.description)]] + std::optional fixedDate; }; #include "spicetranslation_codegen.cpp" } // namespace @@ -155,16 +160,13 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) glm::dvec3 SpiceTranslation::position(const UpdateData& data) const { double lightTime = 0.0; - double time = data.time.j2000Seconds(); - if (_fixedEphemerisTime.has_value()) { - time = *_fixedEphemerisTime; - } + // Spice handles positions in KM, but we use meters in OpenSpace return SpiceManager::ref().targetPosition( _cachedTarget, _cachedObserver, _cachedFrame, {}, - time, + _fixedEphemerisTime.value_or(data.time.j2000Seconds()), lightTime ) * 1000.0; }