From f19b562e881ce84fec020a83ebc3398060dd9ab1 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 4 Jun 2014 14:17:39 -0700 Subject: [PATCH] add JointState::setRotation(rotModelFrame) --- interface/src/renderer/Model.cpp | 8 +++++--- interface/src/renderer/Model.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index beab69ecfb..bc383149d8 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -1270,9 +1270,7 @@ bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const gl if (useRotation) { JointState& state = _jointStates[jointIndex]; - // TODO: figure out what this is trying to do and combine it into one JointState method - endRotation = state.getRotation(); - state.applyRotationDelta(rotation * glm::inverse(endRotation), true, priority); + state.setRotation(rotation, true, priority); endRotation = state.getRotation(); } @@ -2033,6 +2031,10 @@ void JointState::clearTransformTranslation() { _transform[3][2] = 0.0f; } +void JointState::setRotation(const glm::quat& rotation, bool constrain, float priority) { + applyRotationDelta(rotation * glm::inverse(_rotation), true, priority); +} + void JointState::applyRotationDelta(const glm::quat& delta, bool constrain, float priority) { // NOTE: delta is in jointParent-frame assert(_fbxJoint != NULL); diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index cb91d74b3b..7d7406fc42 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -49,6 +49,9 @@ public: /// \return rotation from bind to model frame glm::quat getRotationFromBindToModelFrame() const; + /// \param rotation rotation of joint in model-frame + void setRotation(const glm::quat& rotation, bool constrain, float priority); + /// \param delta is in the jointParent-frame void applyRotationDelta(const glm::quat& delta, bool constrain = true, float priority = 1.0f);