Fixed Animation Export

This commit is contained in:
antc13
2016-01-27 18:37:56 +01:00
parent 57a5cb58e1
commit 8834d5f7a0
3 changed files with 35 additions and 24 deletions
+1 -3
View File
@@ -85,9 +85,6 @@ bool Material::findColorTexture(MaterialNode& material_node, MFnDependencyNode&
material_node.ColorMapFile = FullPath.erase(FullPath.find_last_of("."), FullPath.find_last_of(".") - FullPath.size()); material_node.ColorMapFile = FullPath.erase(FullPath.find_last_of("."), FullPath.find_last_of(".") - FullPath.size());
material_node.ColorMapFileLength = material_node.ColorMapFile.length() + 1; material_node.ColorMapFileLength = material_node.ColorMapFile.length() + 1;
// Test
MGlobal::displayInfo(MString() + "getAbsolutePathToResources: " + workspace);
MGlobal::displayInfo(MString() + "Texture file: " + FullPath.c_str());
return true; return true;
} }
} }
@@ -209,6 +206,7 @@ std::vector<MaterialNode>* Material::DoIt(Mesh mesh)
meshHasMaterial = true; meshHasMaterial = true;
MaterialStorage.IndexStart = totalIndices; MaterialStorage.IndexStart = totalIndices;
MaterialStorage.IndexEnd = totalIndices + aMeshMaterial.second.size() - 1; MaterialStorage.IndexEnd = totalIndices + aMeshMaterial.second.size() - 1;
MGlobal::displayInfo("Oh noes, breaking in material");
break; break;
} }
totalIndices += aMeshMaterial.second.size(); totalIndices += aMeshMaterial.second.size();
+1 -8
View File
@@ -87,10 +87,6 @@ std::map<int, MeshClass::WeightInfo> MeshClass::GetWeightData()
} }
weightMap[geomIter.index()] = weightInfo; weightMap[geomIter.index()] = weightInfo;
for (unsigned int k = 0; k!=nrOfWeights; k++) {
MGlobal::displayInfo(MString() + "influence: " + weightInfo.BoneIndices[k] + " weight: " + weightInfo.BoneWeights[k]);
}
geomIter.next(); geomIter.next();
} }
it.next(); it.next();
@@ -112,7 +108,6 @@ Mesh MeshClass::GetMeshData(MObjectArray object)
MFnDependencyNode thisNode(node); MFnDependencyNode thisNode(node);
MPlugArray connections; MPlugArray connections;
thisNode.findPlug("inMesh").connectedTo(connections, true, true); thisNode.findPlug("inMesh").connectedTo(connections, true, true);
MGlobal::displayInfo(MString() + "inMesh");
bool hasSkin = false; bool hasSkin = false;
MPlug weightList, weights; MPlug weightList, weights;
MObject weightListObject; MObject weightListObject;
@@ -138,7 +133,6 @@ Mesh MeshClass::GetMeshData(MObjectArray object)
} }
for (int pathID = 0; pathID < dagPaths.length(); pathID++) { for (int pathID = 0; pathID < dagPaths.length(); pathID++) {
MGlobal::displayInfo(dagPaths[pathID].fullPathName());
MDagPath thisMeshPath(dagPaths[pathID]); MDagPath thisMeshPath(dagPaths[pathID]);
MMatrix transformMatrix = thisMeshPath.inclusiveMatrix(&status); MMatrix transformMatrix = thisMeshPath.inclusiveMatrix(&status);
@@ -173,8 +167,7 @@ Mesh MeshClass::GetMeshData(MObjectArray object)
break; break;
} }
map<string, vector<int>> materialFaceIDs; map<string, vector<int>> materialFaceIDs;
MGlobal::displayInfo(MString() + "shaderIndexList: " + shaderIndexList.length());
MGlobal::displayInfo(MString() + "shaderList: " + shaderList.length());
MPlugArray plugArray; MPlugArray plugArray;
for (int i = 0; i < shaderIndexList.length(); i++) { for (int i = 0; i < shaderIndexList.length(); i++) {
MFnDependencyNode shader(shaderList[shaderIndexList[i]]); MFnDependencyNode shader(shaderList[shaderIndexList[i]]);
+33 -13
View File
@@ -60,7 +60,7 @@
// //
// return m_AllSkeletons; // return m_AllSkeletons;
//} //}
std::string attr[9] = { "scaleX", "scaleY", "scaleZ", "translateX", "translateY", "translateZ", "rotateX", "rotateY", "rotateZ" }; static std::string attr[9] = { "scaleX", "scaleY", "scaleZ", "translateX", "translateY", "translateZ", "rotateX", "rotateY", "rotateZ" };
Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int endFrame) Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int endFrame)
{ {
@@ -80,6 +80,9 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
m_Hierarchy.push_back(jointIt.item()); m_Hierarchy.push_back(jointIt.item());
MFnDependencyNode depNode(jointIt.item()); MFnDependencyNode depNode(jointIt.item());
MGlobal::displayInfo("-------- INFO ---------");
MGlobal::displayInfo("Joint name: " + depNode.name());
//Loop toght the attr Array to find keyframes;
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
MStatus tmp; MStatus tmp;
@@ -94,21 +97,38 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
MFnAnimCurve jointAnim(connected); MFnAnimCurve jointAnim(connected);
//MGlobal::displayInfo(MString() + "curve : " + jointAnim.name());
//MGlobal::displayInfo(MString() + "curve keys : " + jointAnim.numKeys());
//MGlobal::displayInfo(MString() + "curve keyframes : " + jointAnim.numKeyframes());
//MGlobal::displayInfo(MString() + "startFrame : " + startFrame);
//MGlobal::displayInfo(MString() + "endFrame : " + endFrame);
unsigned int startKeyFrameIndex = jointAnim.findClosest(MTime(startFrame, MTime::kNTSCField), &tmp); unsigned int startKeyFrameIndex = jointAnim.findClosest(MTime(startFrame, MTime::kNTSCField), &tmp);
if (tmp == MStatus::kFailure) if (tmp == MStatus::kFailure)
MGlobal::displayInfo(MString() + "Fail :c"); MGlobal::displayInfo(MString() + "Fail :c");
if (startFrame * oneDivSixty <= jointAnim.time(startKeyFrameIndex).value() && jointAnim.time(startKeyFrameIndex).value() <= endFrame * oneDivSixty) { //MGlobal::displayInfo(MString() + "Start key index : " + startKeyFrameIndex);
//MGlobal::displayInfo(MString() + "Start key time : " + jointAnim.time(startKeyFrameIndex).value());
if (startFrame <= jointAnim.time(startKeyFrameIndex).value() && jointAnim.time(startKeyFrameIndex).value() <= endFrame ) {
animatedJoints.push_back(jointIt.item()); animatedJoints.push_back(jointIt.item());
i = 9; i = 9;
break; break;
} }
unsigned int endKeyFrameIndex = jointAnim.findClosest(MTime(endFrame, MTime::kNTSCField)); unsigned int endKeyFrameIndex = jointAnim.findClosest(MTime(endFrame, MTime::kNTSCField), &tmp);
MGlobal::displayInfo(MString() + startKeyFrameIndex + " " + endKeyFrameIndex); if (tmp == MStatus::kFailure)
MGlobal::displayInfo(MString() + "Fail!!!!!!!!!!!!!!!!!!!!!!!!!");
if (startFrame * oneDivSixty <= jointAnim.time(endKeyFrameIndex).value() && jointAnim.time(endKeyFrameIndex).value() <= endFrame * oneDivSixty || endKeyFrameIndex - startKeyFrameIndex > 0) {
//MGlobal::displayInfo(MString() + "End key index : " + endKeyFrameIndex);
//MGlobal::displayInfo(MString() + "end key time : " + jointAnim.time(endKeyFrameIndex).value());
/*MGlobal::displayInfo(MString() + "start keyfram index: " + startKeyFrameIndex + ". End keyfram index: " + endKeyFrameIndex + ".");*/
if (startFrame <= jointAnim.time(endKeyFrameIndex).value() && jointAnim.time(endKeyFrameIndex).value() <= endFrame || endKeyFrameIndex - startKeyFrameIndex > 0) {
animatedJoints.push_back(jointIt.item()); animatedJoints.push_back(jointIt.item());
i = 9; i = 9;
break; break;
@@ -122,16 +142,19 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
MFnMatrixData MartixFn(DataHandle.data()); MFnMatrixData MartixFn(DataHandle.data());
MMatrix BindPoseMatrix = MartixFn.matrix(); MMatrix BindPoseMatrix = MartixFn.matrix();
if (!BindPoseMatrix.isEquivalent(MayaJoint.transformationMatrix())) if (!BindPoseMatrix.isEquivalent(MayaJoint.transformationMatrix(), 0.0000001f))
{ {
MGlobal::displayError(MString() + animationName.c_str() + " is using " + MayaJoint.name() + " that is not in bind pose nor is it key framed in the animation, the exported animation will NOT correspond to the animation in Maya"); MGlobal::displayError(MString() + animationName.c_str() + " is using " + MayaJoint.name() + " that is not in bind pose nor is it key framed in the animation, the exported animation will NOT correspond to the animation in Maya");
} }
} }
} }//end of connections.length() loop
}
} // end of int i loop
jointIt.next(); jointIt.next();
} } // enf of while (!jointIt.isDone())
int currentFrame = startFrame; int currentFrame = startFrame;
while (currentFrame != endFrame + 1) { // ANDREAS while (currentFrame != endFrame + 1) { // ANDREAS
@@ -251,18 +274,15 @@ std::vector<BindPoseSkeletonNode> Skeleton::GetBindPoses()
MVector tmp = MayaJoint.transformation().getTranslation(MSpace::kObject); MVector tmp = MayaJoint.transformation().getTranslation(MSpace::kObject);
MGlobal::displayError(MString() + "translation befor: " + tmp[0] + " " + tmp[1] + " " + tmp[2]);
//Matrix[3][0] *= -1; //Matrix[3][0] *= -1;
//Matrix[3][2] *= -1; //Matrix[3][2] *= -1;
//Matrix[3][1] *= -1; //Matrix[3][1] *= -1;
double test[3]; double test[3];
MayaJoint.transformation().getScale(test, MSpace::kObject); MayaJoint.transformation().getScale(test, MSpace::kObject);
MGlobal::displayError(MString() + "scale: " + test[0] + " " + test[1] + " " + test[2]);
MTransformationMatrix::RotationOrder order = MTransformationMatrix::RotationOrder::kXYZ; MTransformationMatrix::RotationOrder order = MTransformationMatrix::RotationOrder::kXYZ;
MayaJoint.transformation().getRotation(test, order); MayaJoint.transformation().getRotation(test, order);
MGlobal::displayError(MString() + "rotation: " + test[0] + " " + test[1] + " " + test[2]);
//----- test //----- test