Feature/timeline translation (#931)

* Work on timeline translations
* Add Apollo 11 Descent data
* Ability to display negative altitudes
* Expose globe translation properties
* Added timeline rotation, and some scene updates. 
* Cleaning up apollo_sites scene; fixing boulder 1 in place to adress heightmap issue
* Use quaternion slerp instaet of linear interpolation + Cleanup
* Change to old lem model while waiting for new version to be pushed to data repo
* Small fixes
This commit is contained in:
Emil Axelsson
2019-07-17 15:21:13 +02:00
committed by Alexander Bock
parent 87df4a11a9
commit c97d5126ec
22 changed files with 4085 additions and 158 deletions
+9 -4
View File
@@ -54,8 +54,7 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimagelocal.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/timelinerotation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/constantrotation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/fixedrotation.h
${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.h
@@ -65,6 +64,10 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/scale/timedependentscale.h
${CMAKE_CURRENT_SOURCE_DIR}/timeframe/timeframeinterval.h
${CMAKE_CURRENT_SOURCE_DIR}/timeframe/timeframeunion.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.h
${CMAKE_CURRENT_SOURCE_DIR}/translation/timelinetranslation.h
)
source_group("Header Files" FILES ${HEADER_FILES})
@@ -98,8 +101,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimagelocal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimageonline.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/timelinerotation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/constantrotation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/fixedrotation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.cpp
@@ -109,6 +111,9 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/scale/timedependentscale.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timeframe/timeframeinterval.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timeframe/timeframeunion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/luatranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translation/timelinetranslation.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
+7
View File
@@ -55,9 +55,11 @@
#include <modules/base/rotation/fixedrotation.h>
#include <modules/base/rotation/luarotation.h>
#include <modules/base/rotation/staticrotation.h>
#include <modules/base/rotation/timelinerotation.h>
#include <modules/base/scale/luascale.h>
#include <modules/base/scale/staticscale.h>
#include <modules/base/scale/timedependentscale.h>
#include <modules/base/translation/timelinetranslation.h>
#include <modules/base/translation/luatranslation.h>
#include <modules/base/translation/statictranslation.h>
#include <modules/base/timeframe/timeframeinterval.h>
@@ -131,6 +133,7 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
auto fTranslation = FactoryManager::ref().factory<Translation>();
ghoul_assert(fTranslation, "Ephemeris factory was not created");
fTranslation->registerClass<TimelineTranslation>("TimelineTranslation");
fTranslation->registerClass<LuaTranslation>("LuaTranslation");
fTranslation->registerClass<StaticTranslation>("StaticTranslation");
@@ -141,6 +144,8 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
fRotation->registerClass<FixedRotation>("FixedRotation");
fRotation->registerClass<LuaRotation>("LuaRotation");
fRotation->registerClass<StaticRotation>("StaticRotation");
fRotation->registerClass<TimelineRotation>("TimelineRotation");
auto fScale = FactoryManager::ref().factory<Scale>();
ghoul_assert(fScale, "Scale factory was not created");
@@ -198,6 +203,7 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
FixedRotation::Documentation(),
LuaRotation::Documentation(),
StaticRotation::Documentation(),
TimelineRotation::Documentation(),
LuaScale::Documentation(),
StaticScale::Documentation(),
@@ -205,6 +211,7 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
LuaTranslation::Documentation(),
StaticTranslation::Documentation(),
TimelineTranslation::Documentation(),
TimeFrameInterval::Documentation(),
TimeFrameUnion::Documentation(),
+118
View File
@@ -0,0 +1,118 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/base/rotation/timelinerotation.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <openspace/util/time.h>
namespace {
constexpr const char* KeyType = "Type";
constexpr const char* KeyKeyframes = "Keyframes";
} // namespace
namespace openspace {
documentation::Documentation TimelineRotation::Documentation() {
using namespace documentation;
return {
"Timeline Rotation",
"base_transform_rotation_keyframe",
{
{
KeyType,
new StringEqualVerifier("TimelineRotation"),
Optional::No
},
{
KeyKeyframes,
new TableVerifier({
{ "*", new TableVerifier(), Optional::No, "Any translation object" }
}),
Optional::No,
"A table of keyframes, with keys formatted as YYYY-MM-DDTHH:MM:SS"
"and values that are valid Rotation objects."
}
}
};
}
TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary) {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"TimelineTranslation"
);
const ghoul::Dictionary& keyframes =
dictionary.value<ghoul::Dictionary>(KeyKeyframes);
std::vector<std::string> timeStrings = keyframes.keys();
for (const std::string& timeString : timeStrings) {
const double t = Time::convertTime(timeString);
std::unique_ptr<Rotation> rotation =
Rotation::createFromDictionary(
keyframes.value<ghoul::Dictionary>(timeString)
);
if (rotation) {
_timeline.addKeyframe(t, std::move(rotation));
}
}
}
glm::dmat3 TimelineRotation::matrix(const UpdateData& data) const {
const double now = data.time.j2000Seconds();
using KeyframePointer = const Keyframe<std::unique_ptr<Rotation>>*;
KeyframePointer prev = _timeline.lastKeyframeBefore(now, true);
KeyframePointer next = _timeline.firstKeyframeAfter(now, true);
if (!prev && !next) {
return glm::dmat3(0.0);
}
if (!prev) {
prev = next;
}
if (!next) {
next = prev;
}
const double prevTime = prev->timestamp;
const double nextTime = next->timestamp;
double t = 0.0;
if (nextTime - prevTime > 0.0) {
t = (now - prevTime) / (nextTime - prevTime);
}
const glm::dquat nextRot = glm::quat_cast(next->data->matrix(data));
const glm::dquat prevRot = glm::quat_cast(prev->data->matrix(data));
return glm::dmat3(glm::slerp(prevRot, nextRot, t));
}
} // namespace openspace
+49
View File
@@ -0,0 +1,49 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_BASE___TIMELINEROTATION___H__
#define __OPENSPACE_MODULE_BASE___TIMELINEROTATION___H__
#include <openspace/scene/rotation.h>
#include <openspace/util/timeline.h>
namespace openspace {
struct UpdateData;
namespace documentation { struct Documentation; }
class TimelineRotation : public Rotation {
public:
TimelineRotation(const ghoul::Dictionary& dictionary);
glm::dmat3 matrix(const UpdateData& data) const override;
static documentation::Documentation Documentation();
private:
Timeline<std::unique_ptr<Rotation>> _timeline;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___TIMELINEROTATION___H__
@@ -0,0 +1,114 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/base/translation/timelinetranslation.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <openspace/util/time.h>
namespace {
constexpr const char* KeyType = "Type";
constexpr const char* KeyKeyframes = "Keyframes";
} // namespace
namespace openspace {
documentation::Documentation TimelineTranslation::Documentation() {
using namespace documentation;
return {
"Timeline Translation",
"base_transform_translation_keyframe",
{
{
KeyType,
new StringEqualVerifier("TimelineTranslation"),
Optional::No
},
{
KeyKeyframes,
new TableVerifier({
{ "*", new TableVerifier(), Optional::No, "Any translation object" }
}),
Optional::No,
"A table of keyframes, with keys formatted as YYYY-MM-DDTHH:MM:SS"
"and values that are valid Translation objects."
}
}
};
}
TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary) {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"TimelineTranslation"
);
const ghoul::Dictionary& keyframes =
dictionary.value<ghoul::Dictionary>(KeyKeyframes);
std::vector<std::string> timeStrings = keyframes.keys();
for (const std::string& timeString : timeStrings) {
const double t = Time::convertTime(timeString);
std::unique_ptr<Translation> translation =
Translation::createFromDictionary(
keyframes.value<ghoul::Dictionary>(timeString)
);
if (translation) {
_timeline.addKeyframe(t, std::move(translation));
}
}
}
glm::dvec3 TimelineTranslation::position(const UpdateData& data) const {
const double now = data.time.j2000Seconds();
using KeyframePointer = const Keyframe<std::unique_ptr<Translation>>*;
KeyframePointer prev = _timeline.lastKeyframeBefore(now, true);
KeyframePointer next = _timeline.firstKeyframeAfter(now, true);
if (!prev && !next) {
return glm::dvec3(0.0);
}
if (!prev) {
prev = next;
}
if (!next) {
next = prev;
}
const double prevTime = prev->timestamp;
const double nextTime = next->timestamp;
double t = 0.0;
if (nextTime - prevTime > 0.0) {
t = (now - prevTime) / (nextTime - prevTime);
}
return t * next->data->position(data) + (1.0 - t) * prev->data->position(data);
}
} // namespace openspace
@@ -0,0 +1,50 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_BASE___TIMELINETRANSLATION___H__
#define __OPENSPACE_MODULE_BASE___TIMELINETRANSLATION___H__
#include <openspace/scene/translation.h>
#include <openspace/util/timeline.h>
namespace openspace {
struct UpdateData;
namespace documentation { struct Documentation; }
class TimelineTranslation : public Translation {
public:
TimelineTranslation(const ghoul::Dictionary& dictionary);
glm::dvec3 position(const UpdateData& data) const override;
static documentation::Documentation Documentation();
private:
Timeline<std::unique_ptr<Translation>> _timeline;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___TIMELINETRANSLATION___H__