computeTransformInModelFrame -> computeTransform

This commit is contained in:
Andrew Meadows 2014-06-04 13:31:31 -07:00
parent d32e14ca04
commit 4ae58153e0
4 changed files with 15 additions and 15 deletions

View file

@ -49,7 +49,7 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) {
void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) {
// get the rotation axes in joint space and use them to adjust the rotation
glm::mat3 axes = glm::mat3_cast(glm::quat());
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransformInModelFrame() * glm::translate(state.getDefaultTranslationInParentFrame()) *
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInParentFrame()) *
joint.preTransform * glm::mat4_cast(joint.preRotation)));
state._rotationInParentFrame = glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalRoll(), glm::normalize(inverse * axes[2]))
* glm::angleAxis(RADIANS_PER_DEGREE * _owningHead->getFinalYaw(), glm::normalize(inverse * axes[1]))
@ -60,7 +60,7 @@ void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBX
void FaceModel::maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) {
// likewise with the eye joints
// 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(_rotation) * parentState.getTransformInModelFrame() *
glm::mat4 inverse = glm::inverse(glm::mat4_cast(_rotation) * parentState.getTransform() *
glm::translate(state.getDefaultTranslationInParentFrame()) *
joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation));
glm::vec3 front = glm::vec3(inverse * glm::vec4(_owningHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT, 0.0f));

View file

@ -237,7 +237,7 @@ void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, const
}
// get the rotation axes in joint space and use them to adjust the rotation
glm::mat3 axes = glm::mat3_cast(glm::quat());
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransformInModelFrame() * glm::translate(state.getDefaultTranslationInParentFrame()) *
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInParentFrame()) *
joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation)));
state._rotationInParentFrame = glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(),
glm::normalize(inverse * axes[2])) * glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanForward(),

View file

@ -175,10 +175,10 @@ QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
if (parentIndex == -1) {
_rootIndex = i;
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
state.computeTransformInModelFrame(parentTransform);
state.computeTransform(parentTransform);
} else {
const JointState& parentState = jointStates.at(parentIndex);
state.computeTransformInModelFrame(parentState.getTransformInModelFrame());
state.computeTransform(parentState.getTransform());
}
}
return jointStates;
@ -726,7 +726,7 @@ bool Model::getJointPositionInModelFrame(int jointIndex, glm::vec3& position) co
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
position = extractTranslation(_jointStates[jointIndex].getTransformInModelFrame());
position = extractTranslation(_jointStates[jointIndex].getTransform());
return true;
}
@ -1218,7 +1218,7 @@ void Model::simulateInternal(float deltaTime) {
const FBXMesh& mesh = geometry.meshes.at(i);
for (int j = 0; j < mesh.clusters.size(); j++) {
const FBXCluster& cluster = mesh.clusters.at(j);
state.clusterMatrices[j] = modelToWorld * _jointStates[cluster.jointIndex].getTransformInModelFrame() * cluster.inverseBindMatrix;
state.clusterMatrices[j] = modelToWorld * _jointStates[cluster.jointIndex].getTransform() * cluster.inverseBindMatrix;
}
}
@ -1237,10 +1237,10 @@ void Model::updateJointState(int index) {
if (parentIndex == -1) {
const FBXGeometry& geometry = _geometry->getFBXGeometry();
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
state.computeTransformInModelFrame(parentTransform);
state.computeTransform(parentTransform);
} else {
const JointState& parentState = _jointStates.at(parentIndex);
state.computeTransformInModelFrame(parentState.getTransformInModelFrame());
state.computeTransform(parentState.getTransform());
}
}
@ -1275,7 +1275,7 @@ bool Model::setJointPositionInModelFrame(int jointIndex, const glm::vec3& positi
}
// then, we go from the joint upwards, rotating the end as close as possible to the target
glm::vec3 endPosition = extractTranslation(_jointStates[jointIndex].getTransformInModelFrame());
glm::vec3 endPosition = extractTranslation(_jointStates[jointIndex].getTransform());
for (int j = 1; freeLineage.at(j - 1) != lastFreeIndex; j++) {
int index = freeLineage.at(j);
JointState& state = _jointStates[index];
@ -1283,7 +1283,7 @@ bool Model::setJointPositionInModelFrame(int jointIndex, const glm::vec3& positi
if (!(joint.isFree || allIntermediatesFree)) {
continue;
}
glm::vec3 jointPosition = extractTranslation(state.getTransformInModelFrame());
glm::vec3 jointPosition = extractTranslation(state.getTransform());
glm::vec3 jointVector = endPosition - jointPosition;
glm::quat oldCombinedRotation = state.getRotationInModelFrame();
glm::quat combinedDelta;
@ -1303,7 +1303,7 @@ bool Model::setJointPositionInModelFrame(int jointIndex, const glm::vec3& positi
for (int k = j - 1; k > 0; k--) {
int index = freeLineage.at(k);
updateJointState(index);
positionSum += extractTranslation(_jointStates.at(index).getTransformInModelFrame());
positionSum += extractTranslation(_jointStates.at(index).getTransform());
}
glm::vec3 projectedCenterOfMass = glm::cross(jointVector,
glm::cross(positionSum / (j - 1.0f) - jointPosition, jointVector));
@ -1998,7 +1998,7 @@ void JointState::copyState(const JointState& state) {
// DO NOT copy _fbxJoint
}
void JointState::computeTransformInModelFrame(const glm::mat4& parentTransform) {
void JointState::computeTransform(const glm::mat4& parentTransform) {
glm::quat modifiedRotation = _fbxJoint->preRotation * _rotationInParentFrame * _fbxJoint->postRotation;
glm::mat4 modifiedTransform = _fbxJoint->preTransform * glm::mat4_cast(modifiedRotation) * _fbxJoint->postTransform;
_transform = parentTransform * glm::translate(_fbxJoint->translation) * modifiedTransform;

View file

@ -40,8 +40,8 @@ public:
void copyState(const JointState& state);
void computeTransformInModelFrame(const glm::mat4& parentTransform);
const glm::mat4& getTransformInModelFrame() const { return _transform; }
void computeTransform(const glm::mat4& parentTransform);
const glm::mat4& getTransform() const { return _transform; }
glm::quat getRotationInModelFrame() const { return _rotation; }
glm::vec3 getPositionInModelFrame() const { return extractTranslation(_transform); }