add getRotationInParentFrame()

This commit is contained in:
Andrew Meadows 2014-07-14 16:01:25 -07:00
parent b8fb5e0298
commit ecc83e9559
2 changed files with 17 additions and 6 deletions

View file

@ -82,16 +82,16 @@ void JointState::initTransform(const glm::mat4& parentTransform) {
}
void JointState::computeTransform(const glm::mat4& parentTransform) {
glm::quat rotationInConstrainedFrame = _fbxJoint->preRotation * _rotationInConstrainedFrame * _fbxJoint->postRotation;
glm::mat4 rotationInParentFrame = _fbxJoint->preTransform * glm::mat4_cast(rotationInConstrainedFrame) * _fbxJoint->postTransform;
_transform = parentTransform * glm::translate(_fbxJoint->translation) * rotationInParentFrame;
glm::quat rotationInParentFrame = _fbxJoint->preRotation * _rotationInConstrainedFrame * _fbxJoint->postRotation;
glm::mat4 transformInParentFrame = _fbxJoint->preTransform * glm::mat4_cast(rotationInParentFrame) * _fbxJoint->postTransform;
_transform = parentTransform * glm::translate(_fbxJoint->translation) * transformInParentFrame;
_rotation = extractRotation(_transform);
}
void JointState::computeVisibleTransform(const glm::mat4& parentTransform) {
glm::quat rotationInConstrainedFrame = _fbxJoint->preRotation * _visibleRotationInConstrainedFrame * _fbxJoint->postRotation;
glm::mat4 rotationInParentFrame = _fbxJoint->preTransform * glm::mat4_cast(rotationInConstrainedFrame) * _fbxJoint->postTransform;
_visibleTransform = parentTransform * glm::translate(_fbxJoint->translation) * rotationInParentFrame;
glm::quat rotationInParentFrame = _fbxJoint->preRotation * _visibleRotationInConstrainedFrame * _fbxJoint->postRotation;
glm::mat4 transformInParentFrame = _fbxJoint->preTransform * glm::mat4_cast(rotationInParentFrame) * _fbxJoint->postTransform;
_visibleTransform = parentTransform * glm::translate(_fbxJoint->translation) * transformInParentFrame;
_visibleRotation = extractRotation(_visibleTransform);
}
@ -99,6 +99,14 @@ glm::quat JointState::getRotationInBindFrame() const {
return _rotation * _fbxJoint->inverseBindRotation;
}
glm::quat JointState::getRotationInParentFrame() const {
return _fbxJoint->preRotation * _rotationInConstrainedFrame * _fbxJoint->postRotation;
}
glm::quat JointState::getVisibleRotationInParentFrame() const {
return _fbxJoint->preRotation * _visibleRotationInConstrainedFrame * _fbxJoint->postRotation;
}
void JointState::restoreRotation(float fraction, float priority) {
assert(_fbxJoint != NULL);
if (priority == _animationPriority || _animationPriority == 0.0f) {

View file

@ -48,6 +48,9 @@ public:
/// \return rotation from bind to model frame
glm::quat getRotationInBindFrame() const;
glm::quat getRotationInParentFrame() const;
glm::quat getVisibleRotationInParentFrame() const;
int getParentIndex() const { return _fbxJoint->parentIndex; }
/// \param rotation rotation of joint in model-frame