From 4dbca687678b8075ef1084fc8b36e162586a2caa Mon Sep 17 00:00:00 2001 From: samcake Date: Fri, 6 Nov 2015 16:24:19 -0800 Subject: [PATCH] Updating the legacy file format to support the joint translation and also fix the replay problem oof the joints going to the moon --- libraries/avatars/src/Recorder.cpp | 10 ++++++---- libraries/avatars/src/Recording.cpp | 23 +++++++++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/libraries/avatars/src/Recorder.cpp b/libraries/avatars/src/Recorder.cpp index eeaa8cb1fd..68e667604b 100644 --- a/libraries/avatars/src/Recorder.cpp +++ b/libraries/avatars/src/Recorder.cpp @@ -100,13 +100,15 @@ void Recorder::record() { const RecordingContext& context = _recording->getContext(); RecordingFrame frame; frame.setBlendshapeCoefficients(_avatar->getHeadData()->getBlendshapeCoefficients()); - frame.setJointRotations(_avatar->getJointRotations()); - frame.setJointTranslations(_avatar->getJointTranslations()); + // FIXME: here we need to make sure the correct joint data on the AvatarData to get correct play back. + // This should be fixed by a fix coming from Howard soon + frame.setJointRotations(_avatar->::AvatarData::getJointRotations()); + frame.setJointTranslations(_avatar->::AvatarData::getJointTranslations()); + frame.setTranslation(context.orientationInv * (_avatar->getPosition() - context.position)); frame.setRotation(context.orientationInv * _avatar->getOrientation()); frame.setScale(_avatar->getTargetScale() / context.scale); - - + const HeadData* head = _avatar->getHeadData(); if (head) { glm::vec3 rotationDegrees = glm::vec3(head->getFinalPitch(), diff --git a/libraries/avatars/src/Recording.cpp b/libraries/avatars/src/Recording.cpp index 2e2f46552d..4ca56421e5 100644 --- a/libraries/avatars/src/Recording.cpp +++ b/libraries/avatars/src/Recording.cpp @@ -239,12 +239,21 @@ void writeRecordingToFile(RecordingPointer recording, const QString& filename) { if (i == 0 || frame._jointRotations[j] != previousFrame._jointRotations[j]) { writeQuat(stream, frame._jointRotations[j]); - // TODO -- handle translations mask.setBit(maskIndex); } maskIndex++; } - + + // Joint Translations + for (quint32 j = 0; j < numJoints; ++j) { + if (i == 0 || + frame._jointTranslations[j] != previousFrame._jointTranslations[j]) { + writeVec3(stream, frame._jointTranslations[j]); + mask.setBit(maskIndex); + } + maskIndex++; + } + // Translation if (i == 0) { mask.resize(mask.size() + 1); @@ -563,8 +572,14 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString } } - // TODO -- handle translations - + // Joint Translations + frame._jointTranslations.resize(numJoints); + for (quint32 j = 0; j < numJoints; ++j) { + if (!mask[maskIndex++] || !readVec3(stream, frame._jointTranslations[j])) { + frame._jointTranslations[j] = previousFrame._jointTranslations[j]; + } + } + if (!mask[maskIndex++] || !readVec3(stream, frame._translation)) { frame._translation = previousFrame._translation; }