Fixed the exported animation matrices
This commit is contained in:
+1
-1
Submodule assets updated: 9b2fa74a6d...c4898d8281
@@ -216,7 +216,7 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
|
|
||||||
|
|
||||||
int currentFrame = startFrame;
|
int currentFrame = startFrame;
|
||||||
while (currentFrame <= endFrame) { // ANDREAS
|
while (currentFrame < endFrame) { // ANDREAS
|
||||||
Animation::Keyframe thisKeyFrame;
|
Animation::Keyframe thisKeyFrame;
|
||||||
thisKeyFrame.Index = currentFrame - startFrame;
|
thisKeyFrame.Index = currentFrame - startFrame;
|
||||||
thisKeyFrame.Time = thisKeyFrame.Index * oneDivSixty;
|
thisKeyFrame.Time = thisKeyFrame.Index * oneDivSixty;
|
||||||
@@ -280,13 +280,32 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
joinCheckMap[thisJoint.name().asChar()][3][2] = doubleMat[3][2];
|
joinCheckMap[thisJoint.name().asChar()][3][2] = doubleMat[3][2];
|
||||||
joinCheckMap[thisJoint.name().asChar()][3][3] = doubleMat[3][3];
|
joinCheckMap[thisJoint.name().asChar()][3][3] = doubleMat[3][3];
|
||||||
|
|
||||||
MTransformationMatrix Matrix = thisJoint.transformation();
|
MPlug thisJointBindPose = thisJoint.findPlug("bindPose");
|
||||||
MPlug BindPose = thisJoint.findPlug("bindPose");
|
|
||||||
MDataHandle DataHandle;
|
MDataHandle DataHandle;
|
||||||
BindPose.getValue(DataHandle);
|
thisJointBindPose.getValue(DataHandle);
|
||||||
MFnMatrixData MartixFn(DataHandle.data());
|
MFnMatrixData MartixFn(DataHandle.data());
|
||||||
MMatrix BindPoseMatrix = MartixFn.matrix();
|
MMatrix thisJointBindPoseMatrix = MartixFn.matrix();
|
||||||
Matrix = Matrix.asMatrix();
|
|
||||||
|
MFnTransform Parent(thisJoint.parent(0), &status);
|
||||||
|
if (status == MS::kSuccess && thisJoint.parent(0).apiType() == MFn::kJoint) {
|
||||||
|
MTransformationMatrix Matrix = Parent.transformation();
|
||||||
|
MPlug parentBindPose = Parent.findPlug("bindPose");
|
||||||
|
MDataHandle DataHandle;
|
||||||
|
parentBindPose.getValue(DataHandle);
|
||||||
|
MFnMatrixData MartixFn(DataHandle.data());
|
||||||
|
MMatrix parentBindPoseMatrix = MartixFn.matrix();
|
||||||
|
|
||||||
|
thisJointBindPoseMatrix = thisJointBindPoseMatrix * parentBindPoseMatrix.inverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
MTransformationMatrix TransformationMatrix = thisJoint.transformation();
|
||||||
|
|
||||||
|
if (thisJointBindPoseMatrix.isEquivalent(TransformationMatrix.asMatrix())) {
|
||||||
|
jointID++;
|
||||||
|
jointIt.next();
|
||||||
|
MGlobal::displayError(MString() + thisJoint.name() + " is in bindPose");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
MObject jointOrientObj = thisJoint.attribute("jointOrient");
|
MObject jointOrientObj = thisJoint.attribute("jointOrient");
|
||||||
MFnNumericAttribute jointOrient(jointOrientObj);
|
MFnNumericAttribute jointOrient(jointOrientObj);
|
||||||
@@ -302,7 +321,7 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
MQuaternion jo = joEuler.asQuaternion();
|
MQuaternion jo = joEuler.asQuaternion();
|
||||||
|
|
||||||
double tmp[4];
|
double tmp[4];
|
||||||
Matrix.getRotationQuaternion(tmp[0], tmp[1], tmp[2], tmp[3]);
|
TransformationMatrix.getRotationQuaternion(tmp[0], tmp[1], tmp[2], tmp[3]);
|
||||||
MQuaternion rotation(tmp);
|
MQuaternion rotation(tmp);
|
||||||
|
|
||||||
rotation = rotation * jo;
|
rotation = rotation * jo;
|
||||||
@@ -315,11 +334,11 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
joint.Rotation[1] = tmp[1];
|
joint.Rotation[1] = tmp[1];
|
||||||
joint.Rotation[2] = tmp[2];
|
joint.Rotation[2] = tmp[2];
|
||||||
joint.Rotation[3] = tmp[3];
|
joint.Rotation[3] = tmp[3];
|
||||||
Matrix.getTranslation(MSpace::kTransform).get(tmp);
|
TransformationMatrix.getTranslation(MSpace::kTransform).get(tmp);
|
||||||
joint.Position[0] = tmp[0];
|
joint.Position[0] = tmp[0];
|
||||||
joint.Position[1] = tmp[1];
|
joint.Position[1] = tmp[1];
|
||||||
joint.Position[2] = tmp[2];
|
joint.Position[2] = tmp[2];
|
||||||
Matrix.getScale(tmp, MSpace::kTransform);
|
TransformationMatrix.getScale(tmp, MSpace::kTransform);
|
||||||
joint.Scale[0] = tmp[0];
|
joint.Scale[0] = tmp[0];
|
||||||
joint.Scale[1] = tmp[1];
|
joint.Scale[1] = tmp[1];
|
||||||
joint.Scale[2] = tmp[2];
|
joint.Scale[2] = tmp[2];
|
||||||
|
|||||||
Reference in New Issue
Block a user