diff --git a/include/openspace/camera/camera.h b/include/openspace/camera/camera.h index 4010131d85..ee32007c05 100644 --- a/include/openspace/camera/camera.h +++ b/include/openspace/camera/camera.h @@ -31,6 +31,7 @@ namespace openspace { +struct CameraPose; class SceneGraphNode; /** @@ -67,6 +68,7 @@ public: ~Camera() = default; // Mutators + void setPose(CameraPose pose); void setPositionVec3(glm::dvec3 pos); void setRotation(glm::dquat rotation); void setScaling(float scaling); diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 004982a6d2..8596dc133c 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -65,6 +65,15 @@ struct CommandlineArguments { class OpenSpaceEngine { public: + // A mode that specifies which part of the system is currently in control. + // The mode can be used to limit certain features, like setting time, navigation + // or triggering scripts + enum class Mode { + UserControl = 0, + SessionRecordingPlayback, + CameraPath + }; + OpenSpaceEngine(); ~OpenSpaceEngine(); @@ -94,6 +103,10 @@ public: void toggleShutdownMode(); + Mode currentMode() const; + bool setMode(Mode newMode); + void resetMode(); + // Guaranteed to return a valid pointer AssetManager& assetManager(); LoadingScreen* loadingScreen(); @@ -113,7 +126,6 @@ private: void loadFonts(); void runGlobalCustomizationScripts(); - void configureLogging(); std::string generateFilePath(std::string openspaceRelativePath); void resetPropertyChangeFlagsOfSubowners(openspace::properties::PropertyOwner* po); @@ -137,6 +149,8 @@ private: // The first frame might take some more time in the update loop, so we need to know to // disable the synchronization; otherwise a hardware sync will kill us after 1 minute bool _isRenderingFirstFrame = true; + + Mode _currentMode = Mode::UserControl; }; /** diff --git a/include/openspace/interaction/externinteraction.h b/include/openspace/interaction/externinteraction.h deleted file mode 100644 index 7ad41139ae..0000000000 --- a/include/openspace/interaction/externinteraction.h +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2022 * - * * - * 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_CORE___EXTERNINTERACTION___H__ -#define __OPENSPACE_CORE___EXTERNINTERACTION___H__ - -#include -#include -#include - -#include - -namespace openspace { - -class ExternInteraction : public properties::PropertyOwner { -public: - ExternInteraction(); - /** - * Method that generates a keyframeNavigator CameraPose from a CameraKeyframe - * object, and then adds this to the navigationHandler's keyframe navigator. - * \param kf The camera keyframe to add. - */ - void cameraInteraction(datamessagestructures::CameraKeyframe kf); - /** - * Method that generates a TimeKeyframeData from a TimeKeyframe object, and - * then adds this to the timeManager. - * \param kf The time keyframe to add. - */ - void timeInteraction(datamessagestructures::TimeKeyframe kf); - /** - * Method that passes a ScriptMessage object to the script engine, calling its - * queueScript method to add it for execution. - * \param sm The ScriptMessage object to queue in the script engine. - */ - void scriptInteraction(datamessagestructures::ScriptMessage sm); - /** - * Method that accepts a reference to a CameraKeyframe object, and populates - * it with the current properties of the camera from the navigation handler. - * \returns CameraKeyframe with current state from NavigationHandler. - */ - datamessagestructures::CameraKeyframe generateCameraKeyframe(); - /** - * Method that accepts a reference to a TimeKeyframe object, and populates - * it with the current time values from the application time manager. - * \returns TimeKeyframe The time keyframe. - */ - datamessagestructures::TimeKeyframe generateTimeKeyframe(); - /** - * Method that accepts a reference to a ScriptMessage object and a script - * string, and populates the ScriptMessage with the script and timestamp - * of the current application time. - * \param script The script to execute in std::string form. - * \returns ScriptMessage The ScriptMessage data structure with script. - */ - datamessagestructures::ScriptMessage generateScriptMessage(std::string script); -private: -}; - -} // namespace openspace - -#endif // __OPENSPACE_CORE___EXTERNINTERACTION___H__ diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index 9ca3e1f41c..706377aa99 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -25,7 +25,8 @@ #ifndef __OPENSPACE_CORE___SESSIONRECORDING___H__ #define __OPENSPACE_CORE___SESSIONRECORDING___H__ -#include +#include + #include #include #include @@ -489,12 +490,12 @@ public: static std::string readHeaderElement(std::ifstream& stream, size_t readLen_chars); /** - * Reads header information from a session recording file - * - * \param stringstream reference to ifstream that contains the session recording file data - * \param readLen_chars number of characters to be read, which may be the expected - * length of the header line, or an arbitrary number of characters within it - */ + * Reads header information from a session recording file + * + * \param stringstream reference to ifstream that contains the session recording file data + * \param readLen_chars number of characters to be read, which may be the expected + * length of the header line, or an arbitrary number of characters within it + */ static std::string readHeaderElement(std::stringstream& stream, size_t readLen_chars); /** @@ -596,12 +597,11 @@ protected: Script, Invalid }; - struct timelineEntry { + struct TimelineEntry { RecordedType keyframeType; unsigned int idxIntoKeyframeTypeArray; Timestamps t3stamps; }; - ExternInteraction _externInteract; double _timestampRecordStarted = 0.0; Timestamps _timestamps3RecordStarted; double _timestampPlaybackStarted_application = 0.0; @@ -622,6 +622,8 @@ protected: bool playbackScript(); bool playbackAddEntriesToTimeline(); void signalPlaybackFinishedForComponent(RecordedType type); + void handlePlaybackEnd(); + bool findFirstCameraKeyframeInTimeline(); Timestamps generateCurrentTimestamp3(double keyframeTime); static void saveStringToFile(const std::string& s, unsigned char* kfBuffer, @@ -635,7 +637,7 @@ protected: datamessagestructures::TimeKeyframe keyframe, int lineNum); bool addKeyframe(Timestamps t3stamps, std::string scriptToQueue, int lineNum); - bool addKeyframeToTimeline(std::vector& timeline, RecordedType type, + bool addKeyframeToTimeline(std::vector& timeline, RecordedType type, size_t indexIntoTypeKeyframes, Timestamps t3stamps, int lineNum); void initializePlayback_time(double now); @@ -744,10 +746,10 @@ protected: std::vector _keyframesCamera; std::vector _keyframesTime; std::vector _keyframesScript; - std::vector _timeline; + std::vector _timeline; std::vector _keyframesSavePropertiesBaseline_scripts; - std::vector _keyframesSavePropertiesBaseline_timeline; + std::vector _keyframesSavePropertiesBaseline_timeline; std::vector _propertyBaselinesSaved; const std::vector _propertyBaselineRejects = { "NavigationHandler.OrbitalNavigator.Anchor", diff --git a/include/openspace/navigation/keyframenavigator.h b/include/openspace/navigation/keyframenavigator.h index 37d1aa714b..4c0cf75d0d 100644 --- a/include/openspace/navigation/keyframenavigator.h +++ b/include/openspace/navigation/keyframenavigator.h @@ -76,7 +76,6 @@ public: void removeKeyframesAfter(double timestamp, Inclusive inclusive = Inclusive::No); void clearKeyframes(); size_t nKeyframes() const; - const std::vector& keyframes() const; double currentTime() const; void setTimeReferenceMode(KeyframeTimeRef refType, double referenceTimestamp); diff --git a/include/openspace/navigation/navigationhandler.h b/include/openspace/navigation/navigationhandler.h index 7f6afc29c8..ddd33f1156 100644 --- a/include/openspace/navigation/navigationhandler.h +++ b/include/openspace/navigation/navigationhandler.h @@ -68,16 +68,12 @@ public: // Mutators void setFocusNode(SceneGraphNode* node); - void resetCameraDirection(); - void setCamera(Camera* camera); void setInterpolationTime(float durationInSeconds); void updateCamera(double deltaTime); - void setEnableKeyFrameInteraction(); - void setDisableKeyFrameInteraction(); - void triggerPlaybackStart(); - void stopPlayback(); + + void resetNavigationUpdateVariables(); // Accessors Camera* camera() const; @@ -155,8 +151,7 @@ public: private: void applyNavigationState(const NavigationState& ns); void updateCameraTransitions(); - - bool _playbackModeEnabled = false; + void clearGlobalJoystickStates(); MouseInputState _mouseInputState; KeyboardInputState _keyboardInputState; diff --git a/include/openspace/navigation/orbitalnavigator.h b/include/openspace/navigation/orbitalnavigator.h index 6820a2cfd9..3177a6273f 100644 --- a/include/openspace/navigation/orbitalnavigator.h +++ b/include/openspace/navigation/orbitalnavigator.h @@ -86,7 +86,7 @@ public: void startRetargetAim(); float retargetInterpolationTime() const; void setRetargetInterpolationTime(float durationInSeconds); - void resetNodeMovements(); + void updatePreviousStateVariables(); JoystickCameraStates& joystickStates(); const JoystickCameraStates& joystickStates() const; @@ -131,6 +131,9 @@ private: bool resetVelocitiesOnChange = true); void setAimNode(const SceneGraphNode* aimNode); + void updatePreviousAnchorState(); + void updatePreviousAimState(); + Camera* _camera; Friction _friction; diff --git a/include/openspace/network/messagestructureshelper.h b/include/openspace/network/messagestructureshelper.h new file mode 100644 index 0000000000..1f3465e140 --- /dev/null +++ b/include/openspace/network/messagestructureshelper.h @@ -0,0 +1,57 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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_CORE___MESSAGESTRUCTURESHELPER___H__ +#define __OPENSPACE_CORE___MESSAGESTRUCTURESHELPER___H__ + +#include + +namespace openspace::datamessagestructures { + +/** + * Method that creates a CameraKeyframe object and populates + * it with the current properties of the camera from the navigation handler. + * \returns CameraKeyframe with current state from NavigationHandler +*/ +CameraKeyframe generateCameraKeyframe(); + +/** + * Method that creates a TimeKeyframe object and populates + * it with the current time values from the application time manager. + * \returns TimeKeyframe The time keyframe + */ +TimeKeyframe generateTimeKeyframe(); + +/** + * Method that creates a ScriptMessage object from a given script + * string, and populates the ScriptMessage with the script and timestamp + * of the current application time. + * \param script The script to execute in std::string form + * \returns ScriptMessage The ScriptMessage data structure with script + */ +ScriptMessage generateScriptMessage(std::string script); + +} // namespace openspace::datamessagestructures + +#endif // __OPENSPACE_CORE___MESSAGESTRUCTURESHELPER___H__ diff --git a/include/openspace/network/parallelpeer.h b/include/openspace/network/parallelpeer.h index 3b9a523655..f9878473b4 100644 --- a/include/openspace/network/parallelpeer.h +++ b/include/openspace/network/parallelpeer.h @@ -25,16 +25,13 @@ #ifndef __OPENSPACE_CORE___PARALLELPEER___H__ #define __OPENSPACE_CORE___PARALLELPEER___H__ -#include -#include -#include -#include - #include +#include #include -#include #include +#include +#include #include #include #include @@ -133,8 +130,6 @@ private: std::unique_ptr _receiveThread = nullptr; std::shared_ptr> _connectionEvent; - ExternInteraction _externInteract; - ParallelConnection _connection; TimeManager::CallbackHandle _timeJumpCallback = -1; diff --git a/include/openspace/scripting/scriptscheduler.h b/include/openspace/scripting/scriptscheduler.h index ab14b2f0ba..2479bb0570 100644 --- a/include/openspace/scripting/scriptscheduler.h +++ b/include/openspace/scripting/scriptscheduler.h @@ -150,16 +150,6 @@ public: */ void setTimeReferenceMode(openspace::interaction::KeyframeTimeRef refType); - /** - * Sets the mode for scripts being run from playback - */ - void triggerPlaybackStart(); - - /** - * Sets the flag for scripts no longer being run from playback - */ - void stopPlayback(); - static LuaLibrary luaLibrary(); void setModeApplicationTime(); void setModeRecordedTime(); @@ -174,7 +164,6 @@ private: int _currentIndex = 0; double _currentTime = 0; - bool _playbackModeEnabled = false; openspace::interaction::KeyframeTimeRef _timeframeMode = openspace::interaction::KeyframeTimeRef::Absolute_simTimeJ2000; diff --git a/include/openspace/util/timemanager.h b/include/openspace/util/timemanager.h index 0fbfc2bf97..4e53512e1d 100644 --- a/include/openspace/util/timemanager.h +++ b/include/openspace/util/timemanager.h @@ -126,8 +126,6 @@ public: void removeTimeChangeCallback(CallbackHandle handle); void removeDeltaTimeChangeCallback(CallbackHandle handle); void removeDeltaTimeStepsChangeCallback(CallbackHandle handle); - void triggerPlaybackStart(); - void stopPlayback(); void removeTimeJumpCallback(CallbackHandle handle); void removeTimelineChangeCallback(CallbackHandle handle); @@ -142,6 +140,8 @@ private: double currentApplicationTimeForInterpolation() const; double previousApplicationTimeForInterpolation() const; + bool isPlayingBackSessionRecording() const; + Timeline _timeline; SyncData