From 26101b66cc84648be147ec60eb571d40cfe873d7 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 6 Oct 2021 13:05:14 +0200 Subject: [PATCH] Add action to play timelapse in reverse --- .../solarsystem/missions/jwst/timelaps.asset | 19 +++++++++++++++++++ data/profiles/jwst.profile | 10 +++++++++- include/openspace/scripting/scriptscheduler.h | 5 +++++ src/scripting/scriptscheduler.cpp | 4 ++++ src/util/timemanager.cpp | 2 ++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/timelaps.asset b/data/assets/scene/solarsystem/missions/jwst/timelaps.asset index 130a660147..53b153c874 100644 --- a/data/assets/scene/solarsystem/missions/jwst/timelaps.asset +++ b/data/assets/scene/solarsystem/missions/jwst/timelaps.asset @@ -266,6 +266,24 @@ local playForwards = { IsLocal = false } +local playBackwards = { + Identifier = "jwst.play.backwards", + Name = "Play JWST in reverse", + Command = [[ + openspace.scriptScheduler.clear(); + openspace.time.setDeltaTime(-1); + openspace.time.setTime('2018 OCT 16 09:06:04'); + ]] .. tostring(timelaps) .. [[ + openspace.scriptScheduler.loadScheduledScript( + "2018 OCT 01 14:06:02", + "openspace.scriptScheduler.clear()" + ) + ]], + Documentation = "Jump to the end of JWST deployment time and play the timelaps of deployment in reverse", + GuiPath = "/JWST", + IsLocal = false +} + local clearPlay = { Identifier = "jwst.play.clear", Name = "Clear JWST timelaps", @@ -285,6 +303,7 @@ local clearPlay = { asset.onInitialize(function() openspace.action.registerAction(playForwards) + openspace.action.registerAction(playBackwards) openspace.action.registerAction(clearPlay) end) diff --git a/data/profiles/jwst.profile b/data/profiles/jwst.profile index 562c025809..b717a1868c 100644 --- a/data/profiles/jwst.profile +++ b/data/profiles/jwst.profile @@ -59,7 +59,7 @@ { "documentation": "Toggle all planet and moon trails, except the Moon", "gui_path": "/JWST", - "identifier": "profile.toggel.trails_not_moon", + "identifier": "profile.toggle.trails_not_moon", "is_local": false, "name": "Toggle trails (except Moon)", "script": "local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled') for _,v in pairs(moonlist) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end openspace.setPropertyValueSingle('Scene.MoonTrail.Renderable.Enabled', true)" @@ -152,9 +152,17 @@ "action": "jwst.play.forwards", "key": "M" }, + { + "action": "jwst.play.backwards", + "key": "N" + }, { "action": "jwst.play.clear", "key": "B" + }, + { + "action": "profile.toggle.trails_not_moon", + "key": "G" } ], "mark_nodes": [ diff --git a/include/openspace/scripting/scriptscheduler.h b/include/openspace/scripting/scriptscheduler.h index 9beafef1d4..dd36cac09c 100644 --- a/include/openspace/scripting/scriptscheduler.h +++ b/include/openspace/scripting/scriptscheduler.h @@ -110,6 +110,11 @@ public: */ double currentTime() const; + /** + * Updates the current time to the given j2000 time value + */ + void setCurrentTime(double time); + /** * \returns a vector of all scripts that has been loaded */ diff --git a/src/scripting/scriptscheduler.cpp b/src/scripting/scriptscheduler.cpp index 9c90c7f28c..46b906b180 100644 --- a/src/scripting/scriptscheduler.cpp +++ b/src/scripting/scriptscheduler.cpp @@ -213,6 +213,10 @@ double ScriptScheduler::currentTime() const { return _currentTime; } +void ScriptScheduler::setCurrentTime(double time) { + _currentTime = time; +} + std::vector ScriptScheduler::allScripts() const { std::vector result; for (size_t i = 0; i < _timings.size(); ++i) { diff --git a/src/util/timemanager.cpp b/src/util/timemanager.cpp index 89f898dbd9..b76c66da08 100644 --- a/src/util/timemanager.cpp +++ b/src/util/timemanager.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -405,6 +406,7 @@ void TimeManager::setTimeNextFrame(Time t) { _shouldSetTime = true; _timeNextFrame = std::move(t); clearKeyframes(); + global::scriptScheduler->setCurrentTime(t.j2000Seconds()); } void TimeManager::setDeltaTime(double deltaTime) {