Latest changes to session recording with support for new webGUI record/playback controls (#840)

* Added separate directory for session recording files
* Changed recording & playback paths to use RECORDINGS dir and prevent absolute or relative paths in filename.
* Updated .gitignore so that recordings directory is ignored.
* Added session recording topic for synchronization of rec/play state with web gui.
* Added support to sessionRecording for providing a list of available playback files to web GUI.
* Fixed problem with playback filenames in list
* Fixed problem with occasional large jump in camera pos/rotation after playback finishes.
* Fixed the remaining post-playback problem that was causing a jump in position and rotation.
* Fix path issue on mac
* Fixed bug with bad scale values in recordings saved in ascii format.
This commit is contained in:
Gene Payne
2019-05-17 06:05:03 -06:00
committed by Emil Axelsson
parent c4781b01de
commit 32ebea9e06
16 changed files with 341 additions and 58 deletions
@@ -56,6 +56,8 @@ public:
glm::dvec2 localRollVelocity() const;
glm::dvec2 globalRollVelocity() const;
void resetVelocities();
protected:
struct InteractionState {
InteractionState(double scaleFactor);
@@ -54,6 +54,7 @@ public:
void updateStatesFromInput(const InputState& inputState, double deltaTime);
void updateCameraStateFromStates(double deltaTime);
void resetVelocities();
Camera* camera() const;
void setCamera(Camera* camera);
@@ -66,6 +67,7 @@ public:
void startRetargetAim();
float retargetInterpolationTime() const;
void setRetargetInterpolationTime(float durationInSeconds);
void resetNodeMovements();
JoystickCameraStates& joystickStates();
@@ -148,7 +150,6 @@ private:
glm::dquat _previousAnchorNodeRotation;
glm::dvec3 _previousAimNodePosition;
glm::dquat _previousAimNodeRotation;
double _currentCameraToSurfaceDistance = 0.0;
bool _directlySetStereoDistance = false;
@@ -47,6 +47,15 @@ public:
Binary
};
enum class SessionState {
Idle = 0,
Recording = 1,
Playback = 2
};
using CallbackHandle = int;
using StateChangeCallback = std::function<void()>;
SessionRecording();
~SessionRecording();
/**
@@ -115,6 +124,12 @@ public:
*/
bool isPlayingBack() const;
/**
* Used to obtain the state of idle/recording/playback.
* \returns int value of state as defined by struct SessionState.
*/
SessionState state() const;
/**
* Used to trigger a save of the camera states (position, rotation, focus node,
* whether it is following the rotation of a node, and timestamp). The data will
@@ -141,12 +156,26 @@ public:
*/
static openspace::scripting::LuaLibrary luaLibrary();
/**
* Used to request a callback for notification of playback state change.
* \param cb function handle for callback.
* \returns CallbackHandle value of callback number.
*/
CallbackHandle addStateChangeCallback(StateChangeCallback cb);
/**
* Removes the callback for notification of playback state change.
* \param callback function handle for the callback.
*/
void removeStateChangeCallback(CallbackHandle handle);
/**
* Provides list of available playback files.
* \returns string of newline-delimited filenames in recordings dir.
*/
std::string playbackList();
private:
enum class SessionState {
Idle = 0,
Recording,
Playback
};
enum class RecordedType {
Camera = 0,
Time,
@@ -206,6 +235,7 @@ private:
bool isDataModeBinary();
unsigned int findIndexOfLastCameraKeyframeInTimeline();
bool doesTimelineEntryContainCamera(unsigned int index) const;
std::vector<std::pair<CallbackHandle, StateChangeCallback>> _stateChangeCallbacks;
RecordedType getNextKeyframeType();
RecordedType getPrevKeyframeType();
@@ -222,6 +252,7 @@ private:
RecordedDataMode _recordingDataMode = RecordedDataMode::Binary;
SessionState _state = SessionState::Idle;
SessionState _lastState = SessionState::Idle;
std::string _playbackFilename;
std::ifstream _playbackFile;
std::string _playbackLineParsing;
@@ -260,6 +291,8 @@ private:
unsigned int _idxTimeline_cameraFirstInTimeline = 0;
double _cameraFirstInTimeline_timestamp = 0;
int _nextCallbackHandle = 0;
};
} // namespace openspace