getJointPositionInModelFrame -> getJointPosition

This commit is contained in:
Andrew Meadows 2014-06-04 13:51:43 -07:00
parent 971268d4f2
commit 3af4b1b333
3 changed files with 10 additions and 6 deletions

View file

@ -140,8 +140,8 @@ void SkeletonModel::applyHandPositionInModelFrame(int jointIndex, const glm::vec
const FBXGeometry& geometry = _geometry->getFBXGeometry(); const FBXGeometry& geometry = _geometry->getFBXGeometry();
glm::vec3 handPosition, elbowPosition; glm::vec3 handPosition, elbowPosition;
getJointPositionInModelFrame(jointIndex, handPosition); getJointPosition(jointIndex, handPosition);
getJointPositionInModelFrame(geometry.joints.at(jointIndex).parentIndex, elbowPosition); getJointPosition(geometry.joints.at(jointIndex).parentIndex, elbowPosition);
glm::vec3 forearmVector = handPosition - elbowPosition; glm::vec3 forearmVector = handPosition - elbowPosition;
float forearmLength = glm::length(forearmVector); float forearmLength = glm::length(forearmVector);
if (forearmLength < EPSILON) { if (forearmLength < EPSILON) {
@ -317,7 +317,7 @@ void SkeletonModel::setHandPositionInModelFrame(int jointIndex, const glm::vec3&
} }
int shoulderJointIndex = geometry.joints.at(elbowJointIndex).parentIndex; int shoulderJointIndex = geometry.joints.at(elbowJointIndex).parentIndex;
glm::vec3 shoulderPosition; glm::vec3 shoulderPosition;
if (!getJointPositionInModelFrame(shoulderJointIndex, shoulderPosition)) { if (!getJointPosition(shoulderJointIndex, shoulderPosition)) {
return; return;
} }
// precomputed lengths // precomputed lengths

View file

@ -718,14 +718,16 @@ bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) co
if (jointIndex == -1 || jointIndex >= _jointStates.size()) { if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false; return false;
} }
// position is in world-frame
position = _translation + _rotation * _jointStates[jointIndex].getPosition(); position = _translation + _rotation * _jointStates[jointIndex].getPosition();
return true; 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()) { if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false; return false;
} }
// position is in model-frame
position = extractTranslation(_jointStates[jointIndex].getTransform()); position = extractTranslation(_jointStates[jointIndex].getTransform());
return true; return true;
} }

View file

@ -164,11 +164,13 @@ public:
int getLastFreeJointIndex(int jointIndex) const; int getLastFreeJointIndex(int jointIndex) const;
bool getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const; bool getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const;
bool getJointRotationInWorldFrame(int jointIndex, glm::quat& rotation) const; bool getJointRotationInWorldFrame(int jointIndex, glm::quat& rotation) const;
bool getJointCombinedRotation(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; QStringList getJointNames() const;