mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
Work in progress, fixing the animation playback
This commit is contained in:
parent
2dfbbd2193
commit
46d9a14951
6 changed files with 36 additions and 5 deletions
|
@ -888,6 +888,17 @@ glm::quat Avatar::getJointRotation(int index) const {
|
|||
return rotation;
|
||||
}
|
||||
|
||||
QVector<glm::vec3> Avatar::getJointTranslations() const {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
return AvatarData::getJointTranslations();
|
||||
}
|
||||
QVector<glm::vec3> jointTranslations(_skeletonModel.getJointStateCount());
|
||||
for (int i = 0; i < _skeletonModel.getJointStateCount(); ++i) {
|
||||
_skeletonModel.getJointTranslation(i, jointTranslations[i]);
|
||||
}
|
||||
return jointTranslations;
|
||||
}
|
||||
|
||||
glm::vec3 Avatar::getJointTranslation(int index) const {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
return AvatarData::getJointTranslation(index);
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
|
||||
virtual QVector<glm::quat> getJointRotations() const;
|
||||
virtual glm::quat getJointRotation(int index) const;
|
||||
virtual QVector<glm::vec3> getJointTranslations() const;
|
||||
virtual glm::vec3 getJointTranslation(int index) const;
|
||||
virtual int getJointIndex(const QString& name) const;
|
||||
virtual QStringList getJointNames() const;
|
||||
|
|
|
@ -1146,6 +1146,21 @@ void AvatarData::setJointRotations(QVector<glm::quat> jointRotations) {
|
|||
}
|
||||
}
|
||||
|
||||
QVector<glm::vec3> AvatarData::getJointTranslations() const {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QVector<glm::vec3> result;
|
||||
QMetaObject::invokeMethod(const_cast<AvatarData*>(this),
|
||||
"getJointTranslations", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(QVector<glm::vec3>, result));
|
||||
return result;
|
||||
}
|
||||
QVector<glm::vec3> jointTranslations(_jointData.size());
|
||||
for (int i = 0; i < _jointData.size(); ++i) {
|
||||
jointTranslations[i] = _jointData[i].translation;
|
||||
}
|
||||
return jointTranslations;
|
||||
}
|
||||
|
||||
void AvatarData::setJointTranslations(QVector<glm::vec3> jointTranslations) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QVector<glm::quat> result;
|
||||
|
|
|
@ -260,6 +260,7 @@ public:
|
|||
|
||||
Q_INVOKABLE virtual QVector<glm::quat> getJointRotations() const;
|
||||
Q_INVOKABLE virtual void setJointRotations(QVector<glm::quat> jointRotations);
|
||||
Q_INVOKABLE virtual QVector<glm::vec3> getJointTranslations() const;
|
||||
Q_INVOKABLE virtual void setJointTranslations(QVector<glm::vec3> jointTranslations);
|
||||
|
||||
Q_INVOKABLE virtual void clearJointsData();
|
||||
|
|
|
@ -247,19 +247,20 @@ void Player::play() {
|
|||
_frameInterpolationFactor);
|
||||
_avatar->setTargetScale(context->scale * scale);
|
||||
|
||||
|
||||
float animFactor = 0.0f;
|
||||
|
||||
QVector<glm::quat> jointRotations(currentFrame.getJointRotations().size());
|
||||
for (int i = 0; i < currentFrame.getJointRotations().size(); ++i) {
|
||||
jointRotations[i] = safeMix(currentFrame.getJointRotations()[i],
|
||||
nextFrame.getJointRotations()[i],
|
||||
_frameInterpolationFactor);
|
||||
animFactor);
|
||||
}
|
||||
|
||||
QVector<glm::vec3> jointTranslations(currentFrame.getJointTranslations().size());
|
||||
for (int i = 0; i < currentFrame.getJointTranslations().size(); ++i) {
|
||||
jointTranslations[i] =
|
||||
currentFrame.getJointTranslations()[i] * (1.0f - _frameInterpolationFactor) +
|
||||
nextFrame.getJointTranslations()[i] * _frameInterpolationFactor;
|
||||
jointTranslations[i] = glm::mix(currentFrame.getJointTranslations()[i],
|
||||
nextFrame.getJointTranslations()[i],
|
||||
animFactor);
|
||||
}
|
||||
|
||||
_avatar->setJointRotations(jointRotations);
|
||||
|
|
|
@ -101,6 +101,7 @@ void Recorder::record() {
|
|||
RecordingFrame frame;
|
||||
frame.setBlendshapeCoefficients(_avatar->getHeadData()->getBlendshapeCoefficients());
|
||||
frame.setJointRotations(_avatar->getJointRotations());
|
||||
frame.setJointTranslations(_avatar->getJointTranslations());
|
||||
frame.setTranslation(context.orientationInv * (_avatar->getPosition() - context.position));
|
||||
frame.setRotation(context.orientationInv * _avatar->getOrientation());
|
||||
frame.setScale(_avatar->getTargetScale() / context.scale);
|
||||
|
@ -124,6 +125,7 @@ void Recorder::record() {
|
|||
qCDebug(avatars) << "Recording frame #" << _recording->getFrameNumber();
|
||||
qCDebug(avatars) << "Blendshapes:" << frame.getBlendshapeCoefficients().size();
|
||||
qCDebug(avatars) << "JointRotations:" << frame.getJointRotations().size();
|
||||
qCDebug(avatars) << "JointRotations:" << frame.getJointTranslations().size();
|
||||
qCDebug(avatars) << "Translation:" << frame.getTranslation();
|
||||
qCDebug(avatars) << "Rotation:" << frame.getRotation();
|
||||
qCDebug(avatars) << "Scale:" << frame.getScale();
|
||||
|
|
Loading…
Reference in a new issue