mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:10:25 +02:00
Trying to fix the animation recording and playback, but still not good
This commit is contained in:
parent
5bc827981d
commit
77e21b7190
4 changed files with 91 additions and 13 deletions
|
@ -247,22 +247,50 @@ void Player::play() {
|
||||||
_frameInterpolationFactor);
|
_frameInterpolationFactor);
|
||||||
_avatar->setTargetScale(context->scale * scale);
|
_avatar->setTargetScale(context->scale * scale);
|
||||||
|
|
||||||
QVector<glm::quat> jointRotations(currentFrame.getJointRotations().size());
|
const auto& prevJointArray = currentFrame.getJointArray();
|
||||||
|
const auto& nextJointArray = currentFrame.getJointArray();
|
||||||
|
QVector<JointData> jointArray(prevJointArray.size());
|
||||||
|
QVector<glm::quat> jointRotations(prevJointArray.size());
|
||||||
|
QVector<glm::vec3> jointTranslations(prevJointArray.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < jointArray.size(); i++) {
|
||||||
|
const auto& prevJoint = prevJointArray[i];
|
||||||
|
const auto& nextJoint = nextJointArray[i];
|
||||||
|
auto& joint = jointArray[i];
|
||||||
|
|
||||||
|
// Rotation
|
||||||
|
joint.rotationSet = prevJoint.rotationSet || nextJoint.rotationSet;
|
||||||
|
if (joint.rotationSet) {
|
||||||
|
joint.rotation = safeMix(prevJoint.rotation, nextJoint.rotation, _frameInterpolationFactor);
|
||||||
|
jointRotations[i] = joint.rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
joint.translationSet = prevJoint.translationSet || nextJoint.translationSet;
|
||||||
|
if (joint.translationSet) {
|
||||||
|
joint.translation = glm::mix(prevJoint.translation, nextJoint.translation, _frameInterpolationFactor);
|
||||||
|
jointTranslations[i] = joint.translation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// _avatar->setRawJointData(jointArray);
|
||||||
|
_avatar->setJointRotations(jointRotations);
|
||||||
|
// _avatar->setJointTranslations(jointTranslations);
|
||||||
|
|
||||||
|
/* QVector<glm::quat> jointRotations(currentFrame.getJointRotations().size());
|
||||||
for (int i = 0; i < currentFrame.getJointRotations().size(); ++i) {
|
for (int i = 0; i < currentFrame.getJointRotations().size(); ++i) {
|
||||||
jointRotations[i] = safeMix(currentFrame.getJointRotations()[i],
|
jointRotations[i] = safeMix(currentFrame.getJointRotations()[i],
|
||||||
nextFrame.getJointRotations()[i],
|
nextFrame.getJointRotations()[i],
|
||||||
_frameInterpolationFactor);
|
_frameInterpolationFactor);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
QVector<glm::vec3> jointTranslations(currentFrame.getJointTranslations().size());
|
/* QVector<glm::vec3> jointTranslations(currentFrame.getJointTranslations().size());
|
||||||
for (int i = 0; i < currentFrame.getJointTranslations().size(); ++i) {
|
for (int i = 0; i < currentFrame.getJointTranslations().size(); ++i) {
|
||||||
jointTranslations[i] = glm::mix(currentFrame.getJointTranslations()[i],
|
jointTranslations[i] = glm::mix(currentFrame.getJointTranslations()[i],
|
||||||
nextFrame.getJointTranslations()[i],
|
nextFrame.getJointTranslations()[i],
|
||||||
_frameInterpolationFactor);
|
_frameInterpolationFactor);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
_avatar->setJointRotations(jointRotations);
|
// _avatar->setJointRotations(jointRotations);
|
||||||
_avatar->setJointTranslations(jointTranslations);
|
// _avatar->setJointTranslations(jointTranslations);
|
||||||
|
|
||||||
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
|
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
|
||||||
if (head) {
|
if (head) {
|
||||||
|
@ -422,3 +450,4 @@ bool Player::computeCurrentFrame() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,11 @@ void Recorder::record() {
|
||||||
frame.setBlendshapeCoefficients(_avatar->getHeadData()->getBlendshapeCoefficients());
|
frame.setBlendshapeCoefficients(_avatar->getHeadData()->getBlendshapeCoefficients());
|
||||||
// FIXME: here we need to make sure the correct joint data on the AvatarData to get correct play back.
|
// 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
|
// This should be fixed by a fix coming from Howard soon
|
||||||
frame.setJointRotations(_avatar->::AvatarData::getJointRotations());
|
auto& jointData = _avatar->getRawJointData();
|
||||||
frame.setJointTranslations(_avatar->::AvatarData::getJointTranslations());
|
|
||||||
|
frame.setJointArray(jointData);
|
||||||
|
// frame.setJointRotations(_avatar->::AvatarData::getJointRotations());
|
||||||
|
// frame.setJointTranslations(_avatar->::AvatarData::getJointTranslations());
|
||||||
|
|
||||||
frame.setTranslation(context.orientationInv * (_avatar->getPosition() - context.position));
|
frame.setTranslation(context.orientationInv * (_avatar->getPosition() - context.position));
|
||||||
frame.setRotation(context.orientationInv * _avatar->getOrientation());
|
frame.setRotation(context.orientationInv * _avatar->getOrientation());
|
||||||
|
|
|
@ -229,7 +229,28 @@ void writeRecordingToFile(RecordingPointer recording, const QString& filename) {
|
||||||
++maskIndex;
|
++maskIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joint Rotations
|
const auto& jointArray = frame.getJointArray();
|
||||||
|
if (i == 0) {
|
||||||
|
numJoints = jointArray.size();
|
||||||
|
stream << numJoints;
|
||||||
|
// 2 fields per joints
|
||||||
|
mask.resize(mask.size() + numJoints * 2);
|
||||||
|
}
|
||||||
|
for (int j = 0; j < numJoints; j++) {
|
||||||
|
const auto& joint = jointArray[j];
|
||||||
|
if (joint.rotationSet) {
|
||||||
|
writeQuat(stream, joint.rotation);
|
||||||
|
mask.setBit(maskIndex);
|
||||||
|
}
|
||||||
|
maskIndex++;
|
||||||
|
if (joint.translationSet) {
|
||||||
|
writeVec3(stream, joint.translation);
|
||||||
|
mask.setBit(maskIndex);
|
||||||
|
}
|
||||||
|
maskIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* // Joint Rotations
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
numJoints = frame.getJointRotations().size();
|
numJoints = frame.getJointRotations().size();
|
||||||
stream << numJoints;
|
stream << numJoints;
|
||||||
|
@ -252,7 +273,7 @@ void writeRecordingToFile(RecordingPointer recording, const QString& filename) {
|
||||||
mask.setBit(maskIndex);
|
mask.setBit(maskIndex);
|
||||||
}
|
}
|
||||||
maskIndex++;
|
maskIndex++;
|
||||||
}
|
} */
|
||||||
|
|
||||||
// Translation
|
// Translation
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
@ -561,10 +582,29 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString
|
||||||
stream >> frame._blendshapeCoefficients[j];
|
stream >> frame._blendshapeCoefficients[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Joint Rotations
|
// Joint Array
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
stream >> numJoints;
|
stream >> numJoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame._jointArray.resize(numJoints);
|
||||||
|
for (quint32 j = 0; j < numJoints; ++j) {
|
||||||
|
auto& joint = frame._jointArray[2];
|
||||||
|
|
||||||
|
if (mask[maskIndex++] && readQuat(stream, joint.rotation)) {
|
||||||
|
joint.rotationSet = true;
|
||||||
|
} else {
|
||||||
|
joint.rotationSet = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask[maskIndex++] || readVec3(stream, joint.translation)) {
|
||||||
|
joint.translationSet = true;
|
||||||
|
} else {
|
||||||
|
joint.translationSet = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
frame._jointRotations.resize(numJoints);
|
frame._jointRotations.resize(numJoints);
|
||||||
for (quint32 j = 0; j < numJoints; ++j) {
|
for (quint32 j = 0; j < numJoints; ++j) {
|
||||||
if (!mask[maskIndex++] || !readQuat(stream, frame._jointRotations[j])) {
|
if (!mask[maskIndex++] || !readQuat(stream, frame._jointRotations[j])) {
|
||||||
|
@ -573,12 +613,13 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joint Translations
|
// Joint Translations
|
||||||
frame._jointTranslations.resize(numJoints);
|
/*frame._jointTranslations.resize(numJoints);
|
||||||
for (quint32 j = 0; j < numJoints; ++j) {
|
for (quint32 j = 0; j < numJoints; ++j) {
|
||||||
if (!mask[maskIndex++] || !readVec3(stream, frame._jointTranslations[j])) {
|
if (!mask[maskIndex++] || !readVec3(stream, frame._jointTranslations[j])) {
|
||||||
frame._jointTranslations[j] = previousFrame._jointTranslations[j];
|
frame._jointTranslations[j] = previousFrame._jointTranslations[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (!mask[maskIndex++] || !readVec3(stream, frame._translation)) {
|
if (!mask[maskIndex++] || !readVec3(stream, frame._translation)) {
|
||||||
frame._translation = previousFrame._translation;
|
frame._translation = previousFrame._translation;
|
||||||
|
|
|
@ -25,6 +25,7 @@ class AttachmentData;
|
||||||
class Recording;
|
class Recording;
|
||||||
class RecordingFrame;
|
class RecordingFrame;
|
||||||
class Sound;
|
class Sound;
|
||||||
|
class JointData;
|
||||||
|
|
||||||
typedef QSharedPointer<Recording> RecordingPointer;
|
typedef QSharedPointer<Recording> RecordingPointer;
|
||||||
|
|
||||||
|
@ -82,6 +83,7 @@ private:
|
||||||
class RecordingFrame {
|
class RecordingFrame {
|
||||||
public:
|
public:
|
||||||
QVector<float> getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
QVector<float> getBlendshapeCoefficients() const { return _blendshapeCoefficients; }
|
||||||
|
QVector<JointData> getJointArray() const { return _jointArray; }
|
||||||
QVector<glm::quat> getJointRotations() const { return _jointRotations; }
|
QVector<glm::quat> getJointRotations() const { return _jointRotations; }
|
||||||
QVector<glm::vec3> getJointTranslations() const { return _jointTranslations; }
|
QVector<glm::vec3> getJointTranslations() const { return _jointTranslations; }
|
||||||
glm::vec3 getTranslation() const { return _translation; }
|
glm::vec3 getTranslation() const { return _translation; }
|
||||||
|
@ -94,6 +96,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setBlendshapeCoefficients(QVector<float> blendshapeCoefficients);
|
void setBlendshapeCoefficients(QVector<float> blendshapeCoefficients);
|
||||||
|
void setJointArray(const QVector<JointData>& jointArray) { _jointArray = jointArray; }
|
||||||
void setJointRotations(QVector<glm::quat> jointRotations) { _jointRotations = jointRotations; }
|
void setJointRotations(QVector<glm::quat> jointRotations) { _jointRotations = jointRotations; }
|
||||||
void setJointTranslations(QVector<glm::vec3> jointTranslations) { _jointTranslations = jointTranslations; }
|
void setJointTranslations(QVector<glm::vec3> jointTranslations) { _jointTranslations = jointTranslations; }
|
||||||
void setTranslation(const glm::vec3& translation) { _translation = translation; }
|
void setTranslation(const glm::vec3& translation) { _translation = translation; }
|
||||||
|
@ -108,6 +111,8 @@ private:
|
||||||
QVector<float> _blendshapeCoefficients;
|
QVector<float> _blendshapeCoefficients;
|
||||||
QVector<glm::quat> _jointRotations;
|
QVector<glm::quat> _jointRotations;
|
||||||
QVector<glm::vec3> _jointTranslations;
|
QVector<glm::vec3> _jointTranslations;
|
||||||
|
QVector<JointData> _jointArray;
|
||||||
|
|
||||||
glm::vec3 _translation;
|
glm::vec3 _translation;
|
||||||
glm::quat _rotation;
|
glm::quat _rotation;
|
||||||
float _scale;
|
float _scale;
|
||||||
|
|
Loading…
Reference in a new issue