From ecc83e9559322790143cfcc1f2adc92fde88aa3c Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 14 Jul 2014 16:01:25 -0700 Subject: [PATCH] add getRotationInParentFrame() --- interface/src/renderer/JointState.cpp | 20 ++++++++++++++------ interface/src/renderer/JointState.h | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/interface/src/renderer/JointState.cpp b/interface/src/renderer/JointState.cpp index bcf7d724ba..01b81f6e56 100644 --- a/interface/src/renderer/JointState.cpp +++ b/interface/src/renderer/JointState.cpp @@ -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) { diff --git a/interface/src/renderer/JointState.h b/interface/src/renderer/JointState.h index 99cf14bf3a..b4c3633dfa 100644 --- a/interface/src/renderer/JointState.h +++ b/interface/src/renderer/JointState.h @@ -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