remove JointState::_combinedRotation

instead use JointState::_rotationInModelFrame
This commit is contained in:
Andrew Meadows 2014-06-04 11:56:20 -07:00
parent 19f0f453a5
commit d46a90d763
2 changed files with 7 additions and 12 deletions

View file

@ -201,13 +201,12 @@ QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
if (parentIndex == -1) {
_rootIndex = i;
glm::mat4 baseTransform = glm::mat4_cast(_rotation) * glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
state.computeTransforms(baseTransform, _rotation);
state.computeTransforms(baseTransform);
++numJointsSet;
jointIsSet[i] = true;
} else if (jointIsSet[parentIndex]) {
const JointState& parentState = jointStates.at(parentIndex);
glm::quat parentRotation = _rotation * parentState.getRotationInModelFrame();
state.computeTransforms(parentState.getHybridTransform(), parentRotation);
state.computeTransforms(parentState.getHybridTransform());
++numJointsSet;
jointIsSet[i] = true;
}
@ -1280,11 +1279,10 @@ void Model::updateJointState(int index) {
if (parentIndex == -1) {
const FBXGeometry& geometry = _geometry->getFBXGeometry();
glm::mat4 baseTransform = glm::mat4_cast(_rotation) * glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
state.computeTransforms(baseTransform, _rotation);
state.computeTransforms(baseTransform);
} else {
const JointState& parentState = _jointStates.at(parentIndex);
glm::quat parentRotation = _rotation * parentState.getRotationInModelFrame();
state.computeTransforms(parentState.getHybridTransform(), parentRotation);
state.computeTransforms(parentState.getHybridTransform());
}
}
@ -2039,7 +2037,6 @@ void JointState::copyState(const JointState& state) {
_transformInModelFrame = state._transformInModelFrame;
_rotationInModelFrame = extractRotation(_transformInModelFrame);
_combinedRotation = state._combinedRotation;
_transform = state._transform;
_animationPriority = state._animationPriority;
@ -2053,13 +2050,12 @@ void JointState::computeTransformInModelFrame(const glm::mat4& parentTransform)
_rotationInModelFrame = extractRotation(_transformInModelFrame);
}
void JointState::computeTransforms(const glm::mat4& parentTransform, const glm::quat& baseRotation) {
void JointState::computeTransforms(const glm::mat4& parentTransform) {
assert(_fbxJoint != NULL);
glm::quat modifiedRotation = _fbxJoint->preRotation * _rotation * _fbxJoint->postRotation;
glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(modifiedRotation) * _fbxJoint->postTransform;
_transform = parentTransform * glm::translate(_fbxJoint->translation) * modifiedTransform;
_combinedRotation = baseRotation * modifiedRotation;
}
glm::quat JointState::getRotationFromBindToModelFrame() const {

View file

@ -46,8 +46,8 @@ public:
glm::quat getRotationInModelFrame() const { return _rotationInModelFrame; }
glm::vec3 getPositionInModelFrame() const { return extractTranslation(_transformInModelFrame); }
/// computes new _transform and _combinedRotation
void computeTransforms(const glm::mat4& baseTransform, const glm::quat& baseRotation);
/// computes new _transform
void computeTransforms(const glm::mat4& baseTransform);
/// \return rotation from bind to model frame
glm::quat getRotationFromBindToModelFrame() const;
@ -72,7 +72,6 @@ public:
private:
glm::mat4 _transformInModelFrame;
glm::quat _rotationInModelFrame;
glm::quat _combinedRotation; // rotation from joint local to world frame
glm::mat4 _transform; // rotation to world frame + translation in model frame
const FBXJoint* _fbxJoint; // JointState does NOT own its FBXJoint