mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-25 21:48:57 -05:00
Resolve merge conflict
This commit is contained in:
@@ -62,10 +62,14 @@ public:
|
||||
std::string documentation = "", std::string name = "", std::string guiPath = "");
|
||||
|
||||
void removeKeyBinding(const std::string& key);
|
||||
void removeKeyBinding(const KeyWithModifier& key);
|
||||
|
||||
std::vector<std::pair<KeyWithModifier, KeyInformation>> keyBinding(
|
||||
const std::string& key) const;
|
||||
|
||||
std::vector<std::pair<KeyWithModifier, KeyInformation>> keyBinding(
|
||||
const KeyWithModifier& key) const;
|
||||
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
|
||||
@@ -50,10 +50,13 @@ public:
|
||||
|
||||
struct CameraPose {
|
||||
glm::dvec3 position = glm::dvec3(0.0);
|
||||
glm::quat rotation = glm::quat(1.f, 0.f, 0.f, 0.f);
|
||||
glm::quat rotation = glm::quat(0.f, 0.f, 0.f, 0.f);
|
||||
std::string focusNode;
|
||||
float scale;
|
||||
bool followFocusNodeRotation;
|
||||
float scale = 1.f;
|
||||
bool followFocusNodeRotation = false;
|
||||
|
||||
CameraPose() = default;
|
||||
CameraPose(datamessagestructures::CameraKeyframe&& kf);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,11 +33,24 @@
|
||||
|
||||
namespace openspace::interaction {
|
||||
|
||||
|
||||
class SessionRecording : public properties::PropertyOwner {
|
||||
public:
|
||||
enum class RecordedDataMode {
|
||||
inline static const std::string FileHeaderTitle = "OpenSpace_record/playback";
|
||||
inline static const std::string HeaderCameraAscii = "camera";
|
||||
inline static const std::string HeaderTimeAscii = "time";
|
||||
inline static const std::string HeaderScriptAscii = "script";
|
||||
inline static const std::string HeaderCommentAscii = "#";
|
||||
inline static const char HeaderCameraBinary = 'c';
|
||||
inline static const char HeaderTimeBinary = 't';
|
||||
inline static const char HeaderScriptBinary = 's';
|
||||
inline static const std::string FileExtensionBinary = ".osrec";
|
||||
inline static const std::string FileExtensionAscii = ".osrectxt";
|
||||
|
||||
enum class DataMode {
|
||||
Ascii = 0,
|
||||
Binary
|
||||
Binary,
|
||||
Unknown
|
||||
};
|
||||
|
||||
enum class SessionState {
|
||||
@@ -46,6 +59,24 @@ public:
|
||||
Playback
|
||||
};
|
||||
|
||||
struct Timestamps {
|
||||
double timeOs;
|
||||
double timeRec;
|
||||
double timeSim;
|
||||
};
|
||||
|
||||
static const size_t FileHeaderVersionLength = 5;
|
||||
static constexpr char FileHeaderVersion[FileHeaderVersionLength] = {
|
||||
'0', '0', '.', '8', '5'
|
||||
};
|
||||
static const char DataFormatAsciiTag = 'A';
|
||||
static const char DataFormatBinaryTag = 'B';
|
||||
static const size_t keyframeHeaderSize_bytes = 33;
|
||||
static const size_t saveBufferCameraSize_min = 82;
|
||||
static const size_t saveBufferStringSize_max = 500;
|
||||
static const size_t _saveBufferMaxSize_bytes = keyframeHeaderSize_bytes +
|
||||
+ saveBufferCameraSize_min + saveBufferStringSize_max;
|
||||
|
||||
using CallbackHandle = int;
|
||||
using StateChangeCallback = std::function<void()>;
|
||||
|
||||
@@ -101,7 +132,7 @@ public:
|
||||
*
|
||||
* \return \c true if recording to file starts without errors
|
||||
*/
|
||||
void setRecordDataFormat(RecordedDataMode dataMode);
|
||||
void setRecordDataFormat(DataMode dataMode);
|
||||
|
||||
/**
|
||||
* Used to stop a recording in progress. If open, the recording file will be closed,
|
||||
@@ -215,6 +246,195 @@ public:
|
||||
*/
|
||||
std::vector<std::string> playbackList() const;
|
||||
|
||||
/**
|
||||
* Reads a camera keyframe from a binary format playback file, and populates input
|
||||
* references with the parameters of the keyframe.
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a camera keyframe which contains camera details
|
||||
* \param file an ifstream reference to the playback file being read
|
||||
* \param lineN keyframe number in playback file where this keyframe resides
|
||||
*/
|
||||
static void readCameraKeyframeBinary(Timestamps& times,
|
||||
datamessagestructures::CameraKeyframe& kf, std::ifstream& file, int lineN);
|
||||
|
||||
/**
|
||||
* Reads a camera keyframe from an ascii format playback file, and populates input
|
||||
* references with the parameters of the keyframe.
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a camera keyframe which contains camera details
|
||||
* \param currentParsingLine string containing the most current line that was read
|
||||
* \param lineN line number in playback file where this keyframe resides
|
||||
*/
|
||||
static void readCameraKeyframeAscii(Timestamps& times,
|
||||
datamessagestructures::CameraKeyframe& kf, std::string currentParsingLine,
|
||||
int lineN);
|
||||
|
||||
/**
|
||||
* Reads a time keyframe from a binary format playback file, and populates input
|
||||
* references with the parameters of the keyframe.
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a time keyframe which contains time details
|
||||
* \param file an ifstream reference to the playback file being read
|
||||
* \param lineN keyframe number in playback file where this keyframe resides
|
||||
*/
|
||||
static void readTimeKeyframeBinary(Timestamps& times,
|
||||
datamessagestructures::TimeKeyframe& kf, std::ifstream& file, int lineN);
|
||||
|
||||
/**
|
||||
* Reads a time keyframe from an ascii format playback file, and populates input
|
||||
* references with the parameters of the keyframe.
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a time keyframe which contains time details
|
||||
* \param currentParsingLine string containing the most current line that was read
|
||||
* \param lineN line number in playback file where this keyframe resides
|
||||
*/
|
||||
static void readTimeKeyframeAscii(Timestamps& times,
|
||||
datamessagestructures::TimeKeyframe& kf, std::string currentParsingLine,
|
||||
int lineN);
|
||||
|
||||
/**
|
||||
* Reads a script keyframe from a binary format playback file, and populates input
|
||||
* references with the parameters of the keyframe.
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a script keyframe which contains the size of the script
|
||||
* (in chars) and the text itself
|
||||
* \param file an ifstream reference to the playback file being read
|
||||
* \param lineN keyframe number in playback file where this keyframe resides
|
||||
*/
|
||||
static void readScriptKeyframeBinary(Timestamps& times,
|
||||
datamessagestructures::ScriptMessage& kf, std::ifstream& file, int lineN);
|
||||
|
||||
/**
|
||||
* Reads a script keyframe from an ascii format playback file, and populates input
|
||||
* references with the parameters of the keyframe.
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a script keyframe which contains the size of the script
|
||||
* (in chars) and the text itself
|
||||
* \param currentParsingLine string containing the most current line that was read
|
||||
* \param lineN line number in playback file where this keyframe resides
|
||||
*/
|
||||
static void readScriptKeyframeAscii(Timestamps& times,
|
||||
datamessagestructures::ScriptMessage& kf, std::string currentParsingLine,
|
||||
int lineN);
|
||||
|
||||
/**
|
||||
* Writes a camera keyframe to a binary format recording file using a CameraKeyframe
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a camera keyframe which contains the camera details
|
||||
* \param kfBuffer a buffer temporarily used for preparing data to be written
|
||||
* \param file an ofstream reference to the recording file being written-to
|
||||
*/
|
||||
static void saveCameraKeyframeBinary(Timestamps times,
|
||||
datamessagestructures::CameraKeyframe& kf, unsigned char* kfBuffer,
|
||||
std::ofstream& file);
|
||||
|
||||
/**
|
||||
* Writes a camera keyframe to an ascii format recording file using a CameraKeyframe
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a camera keyframe which contains the camera details
|
||||
* \param file an ofstream reference to the recording file being written-to
|
||||
*/
|
||||
static void saveCameraKeyframeAscii(Timestamps times,
|
||||
datamessagestructures::CameraKeyframe& kf, std::ofstream& file);
|
||||
|
||||
/**
|
||||
* Writes a time keyframe to a binary format recording file using a TimeKeyframe
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a time keyframe which contains the time details
|
||||
* \param kfBuffer a buffer temporarily used for preparing data to be written
|
||||
* \param file an ofstream reference to the recording file being written-to
|
||||
*/
|
||||
static void saveTimeKeyframeBinary(Timestamps times,
|
||||
datamessagestructures::TimeKeyframe& kf, unsigned char* kfBuffer,
|
||||
std::ofstream& file);
|
||||
|
||||
/**
|
||||
* Writes a time keyframe to an ascii format recording file using a TimeKeyframe
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param kf reference to a time keyframe which contains the time details
|
||||
* \param file an ofstream reference to the recording file being written-to
|
||||
*/
|
||||
static void saveTimeKeyframeAscii(Timestamps times,
|
||||
datamessagestructures::TimeKeyframe& kf, std::ofstream& file);
|
||||
|
||||
/**
|
||||
* Writes a script keyframe to a binary format recording file using a ScriptMessage
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param sm reference to a ScriptMessage object which contains the script details
|
||||
* \param smBuffer a buffer temporarily used for preparing data to be written
|
||||
* \param file an ofstream reference to the recording file being written-to
|
||||
*/
|
||||
static void saveScriptKeyframeBinary(Timestamps times,
|
||||
datamessagestructures::ScriptMessage& sm, unsigned char* smBuffer,
|
||||
std::ofstream& file);
|
||||
|
||||
/**
|
||||
* Writes a script keyframe to an ascii format recording file using a ScriptMessage
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param sm reference to a ScriptMessage which contains the script details
|
||||
* \param file an ofstream reference to the recording file being written-to
|
||||
*/
|
||||
static void saveScriptKeyframeAscii(Timestamps times,
|
||||
datamessagestructures::ScriptMessage& sm, std::ofstream& file);
|
||||
|
||||
/**
|
||||
* Reads header information from a session recording file
|
||||
*
|
||||
* \param stream 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::ifstream& stream, size_t readLen_chars);
|
||||
|
||||
/**
|
||||
* Writes a header to a binary recording file buffer
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param type single character signifying the keyframe type
|
||||
* \param kfBuffer the char buffer holding the recording info to be written
|
||||
* \param idx index into write buffer (this is updated with the num of chars written)
|
||||
*/
|
||||
static void saveHeaderBinary(Timestamps times, char type, unsigned char* kfBuffer,
|
||||
size_t& idx);
|
||||
|
||||
/**
|
||||
* Writes a header to an ascii recording file buffer
|
||||
*
|
||||
* \param times reference to a timestamps structure which contains recorded times
|
||||
* \param type string signifying the keyframe type
|
||||
* \param line the stringstream buffer being written to
|
||||
*/
|
||||
static void saveHeaderAscii(Timestamps times, const std::string& type,
|
||||
std::stringstream& line);
|
||||
|
||||
/**
|
||||
* Saves a keyframe to an ascii recording file
|
||||
*
|
||||
* \param entry the ascii string version of the keyframe (any type)
|
||||
* \param file ofstream object to write to
|
||||
*/
|
||||
static void saveKeyframeToFile(std::string entry, std::ofstream& file);
|
||||
|
||||
/**
|
||||
* Checks if a specified recording file ends with a particular file extension
|
||||
*
|
||||
* \param filename the name of the file to record to
|
||||
* \param extension the file extension to check for
|
||||
*/
|
||||
static bool hasFileExtension(std::string filename, std::string extension);
|
||||
|
||||
private:
|
||||
properties::BoolProperty _renderPlaybackInformation;
|
||||
|
||||
@@ -238,25 +458,25 @@ private:
|
||||
double appropriateTimestamp(double timeOs, double timeRec, double timeSim);
|
||||
double equivalentSimulationTime(double timeOs, double timeRec, double timeSim);
|
||||
double equivalentApplicationTime(double timeOs, double timeRec, double timeSim);
|
||||
|
||||
void playbackCamera();
|
||||
void playbackTimeChange();
|
||||
void playbackScript();
|
||||
bool handleRecordingFile(std::string filenameIn);
|
||||
bool playbackCamera();
|
||||
bool playbackTimeChange();
|
||||
bool playbackScript();
|
||||
bool playbackAddEntriesToTimeline();
|
||||
void signalPlaybackFinishedForComponent(RecordedType type);
|
||||
void writeToFileBuffer(double src);
|
||||
void writeToFileBuffer(std::vector<char>& cvec);
|
||||
void writeToFileBuffer(unsigned char c);
|
||||
void writeToFileBuffer(bool b);
|
||||
void saveStringToFile(const std::string& s);
|
||||
void saveKeyframeToFileBinary(unsigned char* bufferSource, size_t size);
|
||||
void findFirstCameraKeyframeInTimeline();
|
||||
void saveKeyframeToFile(std::string entry);
|
||||
static void saveStringToFile(const std::string& s, unsigned char* kfBuffer,
|
||||
size_t& idx, std::ofstream& file);
|
||||
static void saveKeyframeToFileBinary(unsigned char* bufferSource, size_t size,
|
||||
std::ofstream& file);
|
||||
|
||||
void addKeyframe(double timestamp,
|
||||
interaction::KeyframeNavigator::CameraPose keyframe);
|
||||
void addKeyframe(double timestamp, datamessagestructures::TimeKeyframe keyframe);
|
||||
void addKeyframe(double timestamp, std::string scriptToQueue);
|
||||
bool addKeyframe(double timestamp,
|
||||
interaction::KeyframeNavigator::CameraPose keyframe, int lineNum);
|
||||
bool addKeyframe(double timestamp, datamessagestructures::TimeKeyframe keyframe,
|
||||
int lineNum);
|
||||
bool addKeyframe(double timestamp, std::string scriptToQueue, int lineNum);
|
||||
bool addKeyframeToTimeline(RecordedType type, size_t indexIntoTypeKeyframes,
|
||||
double timestamp, int lineNum);
|
||||
void moveAheadInTime();
|
||||
void lookForNonCameraKeyframesThatHaveComeDue(double currTime);
|
||||
void updateCameraWithOrWithoutNewKeyframes(double currTime);
|
||||
@@ -276,7 +496,12 @@ private:
|
||||
double getPrevTimestamp();
|
||||
void cleanUpPlayback();
|
||||
|
||||
RecordedDataMode _recordingDataMode = RecordedDataMode::Binary;
|
||||
static void writeToFileBuffer(unsigned char* buf, size_t& idx, double src);
|
||||
static void writeToFileBuffer(unsigned char* buf, size_t& idx, std::vector<char>& cv);
|
||||
static void writeToFileBuffer(unsigned char* buf, size_t& idx, unsigned char c);
|
||||
static void writeToFileBuffer(unsigned char* buf, size_t& idx, bool b);
|
||||
|
||||
DataMode _recordingDataMode = DataMode::Binary;
|
||||
SessionState _state = SessionState::Idle;
|
||||
SessionState _lastState = SessionState::Idle;
|
||||
std::string _playbackFilename;
|
||||
@@ -296,14 +521,7 @@ private:
|
||||
double _saveRenderingDeltaTime = 1.0 / 30.0;
|
||||
double _saveRenderingCurrentRecordedTime;
|
||||
|
||||
static const size_t keyframeHeaderSize_bytes = 33;
|
||||
static const size_t saveBufferCameraSize_min = 82;
|
||||
static const size_t saveBufferStringSize_max = 500;
|
||||
static const size_t _saveBufferMaxSize_bytes = keyframeHeaderSize_bytes +
|
||||
+ saveBufferCameraSize_min
|
||||
+ saveBufferStringSize_max;
|
||||
unsigned char _keyframeBuffer[_saveBufferMaxSize_bytes];
|
||||
size_t _bufferIndex = 0;
|
||||
|
||||
bool _cleanupNeeded = false;
|
||||
|
||||
|
||||
@@ -55,4 +55,11 @@ T prevKeyframeObj(unsigned int index, const std::vector<T>& keyframeContainer) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T readFromPlayback(std::ifstream& stream) {
|
||||
T res;
|
||||
stream.read(reinterpret_cast<char*>(&res), sizeof(T));
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace openspace::interaction
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* 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___CONVERTRECFORMATTASK___H__
|
||||
#define __OPENSPACE_CORE___CONVERTRECFORMATTASK___H__
|
||||
|
||||
#include <openspace/util/task.h>
|
||||
#include <openspace/interaction/sessionrecording.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
namespace openspace::interaction {
|
||||
|
||||
class ConvertRecFormatTask : public Task {
|
||||
public:
|
||||
enum class ConversionDirection {
|
||||
ToAscii = 0,
|
||||
ToBinary
|
||||
};
|
||||
ConvertRecFormatTask(const ghoul::Dictionary& dictionary);
|
||||
~ConvertRecFormatTask();
|
||||
std::string description() override;
|
||||
void perform(const Task::ProgressCallback& progressCallback) override;
|
||||
static documentation::Documentation documentation();
|
||||
void convert();
|
||||
|
||||
private:
|
||||
void convertToAscii();
|
||||
void convertToBinary();
|
||||
void determineFormatType();
|
||||
std::string addFileSuffix(const std::string& filePath, const std::string& suffix);
|
||||
std::string _inFilePath;
|
||||
std::string _outFilePath;
|
||||
std::ifstream _iFile;
|
||||
std::ofstream _oFile;
|
||||
SessionRecording::DataMode _fileFormatType;
|
||||
|
||||
std::string _valueFunctionLua;
|
||||
};
|
||||
|
||||
} // namespace openspace::interaction
|
||||
|
||||
#endif //__OPENSPACE_CORE___CONVERTRECFORMATTASK___H__
|
||||
@@ -26,10 +26,13 @@
|
||||
#define __OPENSPACE_CORE___MESSAGESTRUCTURES___H__
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
namespace openspace::datamessagestructures {
|
||||
|
||||
@@ -167,6 +170,26 @@ struct CameraKeyframe {
|
||||
out.write(reinterpret_cast<const char*>(&_timestamp), sizeof(_timestamp));
|
||||
};
|
||||
|
||||
void write(std::stringstream& out) const {
|
||||
// Add camera position
|
||||
out << std::fixed << std::setprecision(7) << _position.x << ' '
|
||||
<< std::fixed << std::setprecision(7) << _position.y << ' '
|
||||
<< std::fixed << std::setprecision(7) << _position.z << ' ';
|
||||
// Add camera rotation
|
||||
out << std::fixed << std::setprecision(7) << _rotation.x << ' '
|
||||
<< std::fixed << std::setprecision(7) << _rotation.y << ' '
|
||||
<< std::fixed << std::setprecision(7) << _rotation.z << ' '
|
||||
<< std::fixed << std::setprecision(7) << _rotation.w << ' ';
|
||||
out << std::scientific << _scale << ' ';
|
||||
if (_followNodeRotation) {
|
||||
out << "F ";
|
||||
}
|
||||
else {
|
||||
out << "- ";
|
||||
}
|
||||
out << _focusNode;
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
// Read position
|
||||
in->read(reinterpret_cast<char*>(&_position), sizeof(_position));
|
||||
@@ -194,6 +217,22 @@ struct CameraKeyframe {
|
||||
// Read timestamp
|
||||
in->read(reinterpret_cast<char*>(&_timestamp), sizeof(_timestamp));
|
||||
};
|
||||
|
||||
void read(std::istringstream& iss) {
|
||||
std::string rotationFollowing;
|
||||
|
||||
iss >> _position.x
|
||||
>> _position.y
|
||||
>> _position.z
|
||||
>> _rotation.x
|
||||
>> _rotation.y
|
||||
>> _rotation.z
|
||||
>> _rotation.w
|
||||
>> _scale
|
||||
>> rotationFollowing
|
||||
>> _focusNode;
|
||||
_followNodeRotation = (rotationFollowing == "F");
|
||||
};
|
||||
};
|
||||
|
||||
struct TimeKeyframe {
|
||||
@@ -226,9 +265,35 @@ struct TimeKeyframe {
|
||||
out->write(reinterpret_cast<const char*>(this), sizeof(TimeKeyframe));
|
||||
};
|
||||
|
||||
void write(std::stringstream& out) const {
|
||||
out << ' ' << _dt;
|
||||
if (_paused) {
|
||||
out << " P";
|
||||
}
|
||||
else {
|
||||
out << " R";
|
||||
}
|
||||
if (_requiresTimeJump) {
|
||||
out << " J";
|
||||
}
|
||||
else {
|
||||
out << " -";
|
||||
}
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
in->read(reinterpret_cast<char*>(this), sizeof(TimeKeyframe));
|
||||
};
|
||||
|
||||
void read(std::istringstream& iss) {
|
||||
std::string paused, jump;
|
||||
|
||||
iss >> _dt
|
||||
>> paused
|
||||
>> jump;
|
||||
_paused = (paused == "P");
|
||||
_requiresTimeJump = (jump == "J");
|
||||
};
|
||||
};
|
||||
|
||||
struct TimeTimeline {
|
||||
@@ -308,6 +373,12 @@ struct ScriptMessage {
|
||||
double _timestamp = 0.0;
|
||||
|
||||
void serialize(std::vector<char>& buffer) const {
|
||||
size_t strLen = _script.size();
|
||||
size_t writeSize_bytes = sizeof(size_t);
|
||||
|
||||
unsigned char const *p = reinterpret_cast<unsigned char const*>(&strLen);
|
||||
buffer.insert(buffer.end(), p, p + writeSize_bytes);
|
||||
|
||||
buffer.insert(buffer.end(), _script.begin(), _script.end());
|
||||
};
|
||||
|
||||
@@ -319,6 +390,29 @@ struct ScriptMessage {
|
||||
out->write(_script.c_str(), _script.size());
|
||||
};
|
||||
|
||||
void write(unsigned char* buf, size_t& idx, std::ofstream& file) const {
|
||||
size_t strLen = _script.size();
|
||||
size_t writeSize_bytes = sizeof(size_t);
|
||||
|
||||
unsigned char const *p = reinterpret_cast<unsigned char const*>(&strLen);
|
||||
memcpy((buf + idx), p, writeSize_bytes);
|
||||
idx += static_cast<unsigned int>(writeSize_bytes);
|
||||
|
||||
memcpy((buf + idx), _script.c_str(), _script.size());
|
||||
idx += static_cast<unsigned int>(strLen);
|
||||
file.write(reinterpret_cast<char*>(buf), idx);
|
||||
//Write directly to file because some scripts can be very long
|
||||
file.write(_script.c_str(), _script.size());
|
||||
};
|
||||
|
||||
void write(std::stringstream& ss) const {
|
||||
unsigned int numLinesInScript = static_cast<unsigned int>(
|
||||
std::count(_script.begin(), _script.end(), '\n')
|
||||
);
|
||||
ss << ' ' << (numLinesInScript + 1) << ' ';
|
||||
ss << _script;
|
||||
}
|
||||
|
||||
void read(std::istream* in) {
|
||||
size_t strLen;
|
||||
//Read string length from file
|
||||
@@ -331,6 +425,25 @@ struct ScriptMessage {
|
||||
_script.erase();
|
||||
_script = temp.data();
|
||||
};
|
||||
|
||||
void read(std::istringstream& iss) {
|
||||
int numScriptLines;
|
||||
iss >> numScriptLines;
|
||||
if (numScriptLines < 0) {
|
||||
numScriptLines = 0;
|
||||
}
|
||||
std::string tmpReadbackScript;
|
||||
_script.erase();
|
||||
for (int i = 0; i < numScriptLines; ++i) {
|
||||
std::getline(iss, tmpReadbackScript);
|
||||
size_t start = tmpReadbackScript.find_first_not_of(" ");
|
||||
tmpReadbackScript = tmpReadbackScript.substr(start);
|
||||
_script.append(tmpReadbackScript);
|
||||
if (i < (numScriptLines - 1)) {
|
||||
_script.append("\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace openspace::messagestructures
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
std::string author;
|
||||
std::string url;
|
||||
std::string license;
|
||||
std::string identifiers;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
@@ -40,6 +41,14 @@ namespace scripting { struct LuaLibrary; }
|
||||
|
||||
class Profile {
|
||||
public:
|
||||
struct ParsingError : public ghoul::RuntimeError {
|
||||
enum class Severity { Info, Warning, Error };
|
||||
|
||||
explicit ParsingError(Severity severity, std::string msg);
|
||||
|
||||
Severity severity;
|
||||
};
|
||||
|
||||
// Version
|
||||
struct Version {
|
||||
int major = 0;
|
||||
@@ -47,20 +56,16 @@ public:
|
||||
};
|
||||
struct Module {
|
||||
std::string name;
|
||||
std::string loadedInstruction;
|
||||
std::string notLoadedInstruction;
|
||||
std::optional<std::string> loadedInstruction;
|
||||
std::optional<std::string> notLoadedInstruction;
|
||||
};
|
||||
struct Meta {
|
||||
std::string name;
|
||||
std::string version;
|
||||
std::string description;
|
||||
std::string author;
|
||||
std::string url;
|
||||
std::string license;
|
||||
};
|
||||
struct Asset {
|
||||
std::string path;
|
||||
std::string name;
|
||||
std::optional<std::string> name;
|
||||
std::optional<std::string> version;
|
||||
std::optional<std::string> description;
|
||||
std::optional<std::string> author;
|
||||
std::optional<std::string> url;
|
||||
std::optional<std::string> license;
|
||||
};
|
||||
struct Property {
|
||||
enum class SetType {
|
||||
@@ -87,13 +92,13 @@ public:
|
||||
};
|
||||
|
||||
Type type;
|
||||
std::string time;
|
||||
std::string value;
|
||||
};
|
||||
struct CameraNavState {
|
||||
static constexpr const char* Type = "setNavigationState";
|
||||
|
||||
std::string anchor;
|
||||
std::string aim;
|
||||
std::optional<std::string> aim;
|
||||
std::string referenceFrame;
|
||||
glm::dvec3 position;
|
||||
std::optional<glm::dvec3> up;
|
||||
@@ -109,9 +114,9 @@ public:
|
||||
std::optional<double> altitude;
|
||||
};
|
||||
using CameraType = std::variant<CameraNavState, CameraGoToGeo>;
|
||||
|
||||
|
||||
Profile() = default;
|
||||
Profile(const std::vector<std::string>& content);
|
||||
explicit Profile(const std::string& content);
|
||||
std::string serialize() const;
|
||||
|
||||
std::string convertToScene() const;
|
||||
@@ -147,7 +152,7 @@ private:
|
||||
Version version = CurrentVersion;
|
||||
std::vector<Module> modules;
|
||||
std::optional<Meta> meta;
|
||||
std::vector<Asset> assets;
|
||||
std::vector<std::string> assets;
|
||||
std::vector<Property> properties;
|
||||
std::vector<Keybinding> keybindings;
|
||||
std::optional<Time> time;
|
||||
|
||||
@@ -159,6 +159,7 @@ private:
|
||||
|
||||
properties::StringProperty _guiPath;
|
||||
properties::StringProperty _guiDisplayName;
|
||||
properties::StringProperty _guiDescription;
|
||||
|
||||
// Transformation defined by ephemeris, rotation and scale
|
||||
struct {
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef __OPENSPACE_CORE___TIMEMANAGER___H__
|
||||
#define __OPENSPACE_CORE___TIMEMANAGER___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/syncdata.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/timeline.h>
|
||||
@@ -33,14 +36,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <openspace/util/timeline.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/syncdata.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct TimeKeyframeData {
|
||||
@@ -120,6 +115,7 @@ public:
|
||||
void removeDeltaTimeChangeCallback(CallbackHandle handle);
|
||||
void removeDeltaTimeStepsChangeCallback(CallbackHandle handle);
|
||||
void triggerPlaybackStart();
|
||||
void stopPlayback();
|
||||
void removeTimeJumpCallback(CallbackHandle handle);
|
||||
void removeTimelineChangeCallback(CallbackHandle handle);
|
||||
|
||||
@@ -129,6 +125,9 @@ private:
|
||||
TimeKeyframeData interpolate(const Keyframe<TimeKeyframeData>& past,
|
||||
const Keyframe<TimeKeyframeData>& future, double time);
|
||||
|
||||
void addDeltaTimesKeybindings();
|
||||
void clearDeltaTimesKeybindings();
|
||||
|
||||
Timeline<TimeKeyframeData> _timeline;
|
||||
SyncData<Time> _currentTime;
|
||||
SyncData<Time> _integrateFromTime;
|
||||
@@ -141,8 +140,9 @@ private:
|
||||
double _lastDeltaTime = 0.0;
|
||||
double _lastTargetDeltaTime = 0.0;
|
||||
|
||||
std::vector<double> _deltaTimeSteps;
|
||||
bool _deltaTimeStepsChanged = false;
|
||||
std::vector<double> _deltaTimeSteps;
|
||||
std::vector<KeyWithModifier> _deltaTimeStepKeybindings;
|
||||
|
||||
properties::FloatProperty _defaultTimeInterpolationDuration;
|
||||
properties::FloatProperty _defaultDeltaTimeInterpolationDuration;
|
||||
|
||||
Reference in New Issue
Block a user