From 3a4dfb92f65cd384031afbb1c2df5f1eed891d01 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 2 May 2014 19:37:42 -0700 Subject: [PATCH] Let's try using the neck parent rotation, rather than the neck, to fix separate heads. --- interface/src/avatar/FaceModel.cpp | 8 ++++---- interface/src/renderer/Model.cpp | 11 +++++++++++ interface/src/renderer/Model.h | 4 ++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/FaceModel.cpp b/interface/src/avatar/FaceModel.cpp index 709a9fc79d..90e596bde5 100644 --- a/interface/src/avatar/FaceModel.cpp +++ b/interface/src/avatar/FaceModel.cpp @@ -29,11 +29,11 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) { neckPosition = owningAvatar->getPosition(); } setTranslation(neckPosition); - glm::quat neckRotation; - if (!owningAvatar->getSkeletonModel().getNeckRotation(neckRotation)) { - neckRotation = owningAvatar->getOrientation(); + glm::quat neckParentRotation; + if (!owningAvatar->getSkeletonModel().getNeckParentRotation(neckParentRotation)) { + neckParentRotation = owningAvatar->getOrientation(); } - setRotation(neckRotation); + setRotation(neckParentRotation); const float MODEL_SCALE = 0.0006f; setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningHead->getScale() * MODEL_SCALE); diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 5c06d2fcf3..a177783955 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -434,6 +434,17 @@ bool Model::getNeckRotation(glm::quat& neckRotation) const { return isActive() && getJointRotation(_geometry->getFBXGeometry().neckJointIndex, neckRotation); } +bool Model::getNeckParentRotation(glm::quat& neckParentRotation) const { + if (!isActive()) { + return false; + } + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + if (geometry.neckJointIndex == -1) { + return false; + } + return getJointRotation(geometry.joints.at(geometry.neckJointIndex).parentIndex, neckParentRotation); +} + bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const { if (!isActive()) { return false; diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 14589d1464..ae2bcd79b8 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -132,6 +132,10 @@ public: /// \return whether or not the neck was found bool getNeckRotation(glm::quat& neckRotation) const; + /// Returns the rotation of the neck joint's parent. + /// \return whether or not the neck was found + bool getNeckParentRotation(glm::quat& neckRotation) const; + /// Retrieve the positions of up to two eye meshes. /// \return whether or not both eye meshes were found bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;