Separated playback keyframe extraction into steps (file read & parse)

This commit is contained in:
GPayne
2019-10-17 18:20:37 -06:00
parent 6a0ddea83a
commit 27ef369338
4 changed files with 120 additions and 69 deletions

View File

@@ -54,6 +54,14 @@ public:
std::string focusNode;
float scale;
bool followFocusNodeRotation;
CameraPose(const openspace::datamessagestructures::CameraKeyframe& kf) {
position = kf._position;
rotation = kf._rotation;
focusNode = kf._focusNode;
scale = kf._scale;
followFocusNodeRotation = kf._followNodeRotation;
}
};
/**

View File

@@ -45,6 +45,12 @@ public:
Playback
};
struct timestamps {
double timeOs;
double timeRec;
double timeSim;
};
const std::string FileHeaderTitle = "OpenSpace_record/playback";
constexpr const size_t FileHeaderVersionLength = 5;
constexpr const char FileHeaderVersion[FileHeaderVersionLength] = {
@@ -216,6 +222,30 @@ 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 filenameRead a string containing the playback filename
* \param lineN line number in playback file where this keyframe resides
*/
static void readCameraKeyframeAscii(timestamps& times,
datamessagestructures::CameraKeyframe& kf, std::string filenameRead, int lineN);
private:
enum class RecordedType {
Camera = 0,

View File

@@ -233,6 +233,22 @@ struct CameraKeyframe {
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 {