From 3af4b1b33398fd90daf6d007b6448758c5aad255 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 4 Jun 2014 13:51:43 -0700 Subject: [PATCH] getJointPositionInModelFrame -> getJointPosition --- interface/src/avatar/SkeletonModel.cpp | 6 +++--- interface/src/renderer/Model.cpp | 4 +++- interface/src/renderer/Model.h | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 63a2859366..008ea65557 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -140,8 +140,8 @@ void SkeletonModel::applyHandPositionInModelFrame(int jointIndex, const glm::vec const FBXGeometry& geometry = _geometry->getFBXGeometry(); glm::vec3 handPosition, elbowPosition; - getJointPositionInModelFrame(jointIndex, handPosition); - getJointPositionInModelFrame(geometry.joints.at(jointIndex).parentIndex, elbowPosition); + getJointPosition(jointIndex, handPosition); + getJointPosition(geometry.joints.at(jointIndex).parentIndex, elbowPosition); glm::vec3 forearmVector = handPosition - elbowPosition; float forearmLength = glm::length(forearmVector); if (forearmLength < EPSILON) { @@ -317,7 +317,7 @@ void SkeletonModel::setHandPositionInModelFrame(int jointIndex, const glm::vec3& } int shoulderJointIndex = geometry.joints.at(elbowJointIndex).parentIndex; glm::vec3 shoulderPosition; - if (!getJointPositionInModelFrame(shoulderJointIndex, shoulderPosition)) { + if (!getJointPosition(shoulderJointIndex, shoulderPosition)) { return; } // precomputed lengths diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 4f2bb79faf..66be7e4bfc 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -718,14 +718,16 @@ bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) co if (jointIndex == -1 || jointIndex >= _jointStates.size()) { return false; } + // position is in world-frame position = _translation + _rotation * _jointStates[jointIndex].getPosition(); return true; } -bool Model::getJointPositionInModelFrame(int jointIndex, glm::vec3& position) const { +bool Model::getJointPosition(int jointIndex, glm::vec3& position) const { if (jointIndex == -1 || jointIndex >= _jointStates.size()) { return false; } + // position is in model-frame position = extractTranslation(_jointStates[jointIndex].getTransform()); return true; } diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 7a0e6b1dbb..d6721d2bad 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -164,11 +164,13 @@ public: int getLastFreeJointIndex(int jointIndex) const; bool getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const; - bool getJointRotationInWorldFrame(int jointIndex, glm::quat& rotation) const; bool getJointCombinedRotation(int jointIndex, glm::quat& rotation) const; - bool getJointPositionInModelFrame(int jointIndex, glm::vec3& position) const; + /// \param jointIndex index of joint in model structure + /// \param position[out] position of joint in model-frame + /// \return true if joint exists + bool getJointPosition(int jointIndex, glm::vec3& position) const; QStringList getJointNames() const;