Change name originalRotation defaultRotation.

This commit is contained in:
Howard Stearns 2015-08-06 19:45:58 -07:00
parent 42cc34cd64
commit a840a17106
5 changed files with 17 additions and 17 deletions

View file

@ -71,7 +71,7 @@ void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const Joi
glm::angleAxis(-pitchYawRoll.z, glm::normalize(inverse * axes[2]))
* glm::angleAxis(pitchYawRoll.y, glm::normalize(inverse * axes[1]))
* glm::angleAxis(-pitchYawRoll.x, glm::normalize(inverse * axes[0]))
* state.getOriginalRotation(), DEFAULT_PRIORITY);
* state.getDefaultRotation(), DEFAULT_PRIORITY);
}
void FaceModel::maybeUpdateEyeRotation(Model* model, const JointState& parentState, const JointState& state, int index) {
@ -79,7 +79,7 @@ void FaceModel::maybeUpdateEyeRotation(Model* model, const JointState& parentSta
// NOTE: at the moment we do the math in the world-frame, hence the inverse transform is more complex than usual.
glm::mat4 inverse = glm::inverse(glm::mat4_cast(model->getRotation()) * parentState.getTransform() *
glm::translate(_rig->getJointDefaultTranslationInConstrainedFrame(index)) *
state.getPreTransform() * glm::mat4_cast(state.getPreRotation() * state.getOriginalRotation()));
state.getPreTransform() * glm::mat4_cast(state.getPreRotation() * state.getDefaultRotation()));
glm::vec3 front = glm::vec3(inverse * glm::vec4(_owningHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT, 0.0f));
glm::vec3 lookAtDelta = _owningHead->getCorrectedLookAtPosition() - model->getTranslation();
glm::vec3 lookAt = glm::vec3(inverse * glm::vec4(lookAtDelta + glm::length(lookAtDelta) * _owningHead->getSaccade(), 1.0f));
@ -87,7 +87,7 @@ void FaceModel::maybeUpdateEyeRotation(Model* model, const JointState& parentSta
const float MAX_ANGLE = 30.0f * RADIANS_PER_DEGREE;
_rig->setJointRotationInConstrainedFrame(index, glm::angleAxis(glm::clamp(glm::angle(between),
-MAX_ANGLE, MAX_ANGLE), glm::axis(between)) *
state.getOriginalRotation(), DEFAULT_PRIORITY);
state.getDefaultRotation(), DEFAULT_PRIORITY);
}
void FaceModel::maybeUpdateNeckAndEyeRotation(int index) {

View file

@ -481,7 +481,7 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) {
if (parentIndex == -1) {
transforms[i] = _rig->getJointTransform(i);
} else {
glm::quat modifiedRotation = state.getPreRotation() * state.getOriginalRotation() * state.getPostRotation();
glm::quat modifiedRotation = state.getPreRotation() * state.getDefaultRotation() * state.getPostRotation();
transforms[i] = transforms[parentIndex] * glm::translate(state.getTranslation())
* state.getPreTransform() * glm::mat4_cast(modifiedRotation) * state.getPostTransform();
}

View file

@ -42,7 +42,7 @@ JointState::JointState(const JointState& other) : _constraint(NULL) {
_boneRadius = other._boneRadius;
_parentIndex = other._parentIndex;
_translation = other._translation;
_originalRotation = other._originalRotation;
_defaultRotation = other._defaultRotation;
_inverseDefaultRotation = other._inverseDefaultRotation;
_rotationMin = other._rotationMin;
_rotationMax = other._rotationMax;
@ -82,7 +82,7 @@ void JointState::setFBXJoint(const FBXJoint* joint) {
_boneRadius = joint->boneRadius;
_parentIndex = joint->parentIndex;
_translation = joint->translation;
_originalRotation = joint->rotation;
_defaultRotation = joint->rotation;
_inverseDefaultRotation = joint->inverseDefaultRotation;
_rotationMin = joint->rotationMin;
_rotationMax = joint->rotationMax;
@ -127,7 +127,7 @@ void JointState::copyState(const JointState& state) {
_isFree = state._isFree;
_boneRadius = state._boneRadius;
_parentIndex = state._parentIndex;
_originalRotation = state._originalRotation;
_defaultRotation = state._defaultRotation;
_inverseDefaultRotation = state._inverseDefaultRotation;
_translation = state._translation;
_rotationMin = state._rotationMin;
@ -182,7 +182,7 @@ glm::quat JointState::getVisibleRotationInParentFrame() const {
void JointState::restoreRotation(float fraction, float priority) {
if (priority == _animationPriority || _animationPriority == 0.0f) {
setRotationInConstrainedFrameInternal(safeMix(_rotationInConstrainedFrame, _originalRotation, fraction));
setRotationInConstrainedFrameInternal(safeMix(_rotationInConstrainedFrame, _defaultRotation, fraction));
_animationPriority = 0.0f;
}
}
@ -237,7 +237,7 @@ void JointState::mixRotationDelta(const glm::quat& delta, float mixFactor, float
_animationPriority = priority;
glm::quat targetRotation = _rotationInConstrainedFrame * glm::inverse(getRotation()) * delta * getRotation();
if (mixFactor > 0.0f && mixFactor <= 1.0f) {
targetRotation = safeMix(targetRotation, _originalRotation, mixFactor);
targetRotation = safeMix(targetRotation, _defaultRotation, mixFactor);
}
if (_constraint) {
_constraint->softClamp(targetRotation, _rotationInConstrainedFrame, 0.5f);
@ -290,7 +290,7 @@ void JointState::setVisibleRotationInConstrainedFrame(const glm::quat& targetRot
}
bool JointState::rotationIsDefault(const glm::quat& rotation, float tolerance) const {
glm::quat defaultRotation = _originalRotation;
glm::quat defaultRotation = _defaultRotation;
return glm::abs(rotation.x - defaultRotation.x) < tolerance &&
glm::abs(rotation.y - defaultRotation.y) < tolerance &&
glm::abs(rotation.z - defaultRotation.z) < tolerance &&
@ -299,7 +299,7 @@ bool JointState::rotationIsDefault(const glm::quat& rotation, float tolerance) c
glm::quat JointState::getDefaultRotationInParentFrame() const {
// NOTE: the result is constant and could be cached
return _preRotation * _originalRotation * _postRotation;
return _preRotation * _defaultRotation * _postRotation;
}
const glm::vec3& JointState::getDefaultTranslationInConstrainedFrame() const {

View file

@ -113,7 +113,7 @@ public:
const glm::mat4& getPostTransform() const { return _postTransform; }
const glm::quat& getPreRotation() const { return _preRotation; }
const glm::quat& getPostRotation() const { return _postRotation; }
const glm::quat& getOriginalRotation() const { return _originalRotation; }
const glm::quat& getDefaultRotation() const { return _defaultRotation; }
const glm::quat& getInverseDefaultRotation() const { return _inverseDefaultRotation; }
const QString& getName() const { return _name; }
float getBoneRadius() const { return _boneRadius; }
@ -136,7 +136,7 @@ private:
glm::quat _visibleRotation;
glm::quat _visibleRotationInConstrainedFrame;
glm::quat _originalRotation; // Not necessarilly bind rotation. See FBXJoint transform/bindTransform
glm::quat _defaultRotation; // Not necessarilly bind rotation. See FBXJoint transform/bindTransform
glm::quat _inverseDefaultRotation;
glm::vec3 _translation;
float _boneRadius;

View file

@ -795,7 +795,7 @@ void Rig::updateLeanJoint(int index, float leanSideways, float leanForward, floa
glm::angleAxis(- RADIANS_PER_DEGREE * leanSideways, inverse * zAxis) *
glm::angleAxis(- RADIANS_PER_DEGREE * leanForward, inverse * xAxis) *
glm::angleAxis(RADIANS_PER_DEGREE * torsoTwist, inverse * yAxis) *
getJointState(index).getOriginalRotation(), DEFAULT_PRIORITY);
getJointState(index).getDefaultRotation(), DEFAULT_PRIORITY);
}
}
@ -816,7 +816,7 @@ void Rig::updateNeckJoint(int index, const glm::quat& localHeadOrientation, floa
glm::angleAxis(-pitchYawRoll.z, glm::normalize(inverse * axes[2])) *
glm::angleAxis(pitchYawRoll.y, glm::normalize(inverse * axes[1])) *
glm::angleAxis(-pitchYawRoll.x, glm::normalize(inverse * axes[0])) *
state.getOriginalRotation(), DEFAULT_PRIORITY);
state.getDefaultRotation(), DEFAULT_PRIORITY);
}
}
@ -828,7 +828,7 @@ void Rig::updateEyeJoint(int index, const glm::quat& worldHeadOrientation, const
// NOTE: at the moment we do the math in the world-frame, hence the inverse transform is more complex than usual.
glm::mat4 inverse = glm::inverse(parentState.getTransform() *
glm::translate(getJointDefaultTranslationInConstrainedFrame(index)) *
state.getPreTransform() * glm::mat4_cast(state.getPreRotation() * state.getOriginalRotation()));
state.getPreTransform() * glm::mat4_cast(state.getPreRotation() * state.getDefaultRotation()));
glm::vec3 front = glm::vec3(inverse * glm::vec4(worldHeadOrientation * IDENTITY_FRONT, 0.0f));
glm::vec3 lookAtDelta = lookAt;
glm::vec3 lookAt = glm::vec3(inverse * glm::vec4(lookAtDelta + glm::length(lookAtDelta) * saccade, 1.0f));
@ -836,6 +836,6 @@ void Rig::updateEyeJoint(int index, const glm::quat& worldHeadOrientation, const
const float MAX_ANGLE = 30.0f * RADIANS_PER_DEGREE;
float angle = glm::clamp(glm::angle(between), -MAX_ANGLE, MAX_ANGLE);
glm::quat rot = glm::angleAxis(angle, glm::axis(between));
setJointRotationInConstrainedFrame(index, rot * state.getOriginalRotation(), DEFAULT_PRIORITY);
setJointRotationInConstrainedFrame(index, rot * state.getDefaultRotation(), DEFAULT_PRIORITY);
}
}