Changed the way we're exporting animations.
This commit is contained in:
@@ -89,7 +89,7 @@ private:
|
|||||||
void ReadAnimationJoint(unsigned int &offset, char* fileData, unsigned int& fileByteSize);
|
void ReadAnimationJoint(unsigned int &offset, char* fileData, unsigned int& fileByteSize);
|
||||||
void ReadAnimationClips(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfClips);
|
void ReadAnimationClips(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfClips);
|
||||||
void ReadAnimationClipSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int clipIndex);
|
void ReadAnimationClipSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int clipIndex);
|
||||||
void ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation);
|
void ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, Skeleton::Animation& animation);
|
||||||
|
|
||||||
//void CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID);
|
//void CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -327,22 +327,16 @@ void RawModelCustom::ReadAnimationClipSingle(unsigned int &offset, char* fileDat
|
|||||||
unsigned int nrOfKeyframes = *(unsigned int*)(fileData + offset);
|
unsigned int nrOfKeyframes = *(unsigned int*)(fileData + offset);
|
||||||
offset += sizeof(unsigned int);
|
offset += sizeof(unsigned int);
|
||||||
|
|
||||||
if (offset + sizeof(unsigned int) > fileByteSize) {
|
|
||||||
throw Resource::FailedLoadingException("Reading AnimationClip NrOfJoints failed");
|
|
||||||
}
|
|
||||||
unsigned int nrOfJoints = *(unsigned int*)(fileData + offset);
|
|
||||||
offset += sizeof(unsigned int);
|
|
||||||
|
|
||||||
newAnimation.Keyframes.reserve(nrOfKeyframes);
|
newAnimation.Keyframes.reserve(nrOfKeyframes);
|
||||||
for (unsigned int i = 0; i < nrOfKeyframes; i++) {
|
for (unsigned int i = 0; i < nrOfKeyframes; i++) {
|
||||||
ReadAnimationKeyFrame(offset, fileData, fileByteSize, nrOfJoints, newAnimation);
|
ReadAnimationKeyFrame(offset, fileData, fileByteSize, newAnimation);
|
||||||
}
|
}
|
||||||
m_Skeleton->Animations[newAnimation.Name] = newAnimation;
|
m_Skeleton->Animations[newAnimation.Name] = newAnimation;
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawModelCustom::ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int nrOfJoints, Skeleton::Animation& animation)
|
void RawModelCustom::ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, Skeleton::Animation& animation)
|
||||||
{
|
{
|
||||||
Skeleton::Animation::Keyframe newKeyFrame;
|
Skeleton::Animation::Keyframe newKeyFrame;
|
||||||
|
|
||||||
@@ -358,6 +352,12 @@ void RawModelCustom::ReadAnimationKeyFrame(unsigned int &offset, char* fileData,
|
|||||||
newKeyFrame.Time = *(float*)(fileData + offset);
|
newKeyFrame.Time = *(float*)(fileData + offset);
|
||||||
offset += sizeof(float);
|
offset += sizeof(float);
|
||||||
|
|
||||||
|
if (offset + sizeof(unsigned int) > fileByteSize) {
|
||||||
|
throw Resource::FailedLoadingException("Reading AnimationKeyFrame NrOfJoints failed");
|
||||||
|
}
|
||||||
|
unsigned int nrOfJoints = *(unsigned int*)(fileData + offset);
|
||||||
|
offset += sizeof(unsigned int);
|
||||||
|
|
||||||
if (offset + sizeof(Skeleton::Animation::Keyframe::BoneProperty) * nrOfJoints> fileByteSize) {
|
if (offset + sizeof(Skeleton::Animation::Keyframe::BoneProperty) * nrOfJoints> fileByteSize) {
|
||||||
throw Resource::FailedLoadingException("Reading AnimationKeyFrame joints failed");
|
throw Resource::FailedLoadingException("Reading AnimationKeyFrame joints failed");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,69 +77,69 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
std::map<std::string, std::array<std::array<double, 4>, 4>> joinCheckMap;
|
std::map<std::string, std::array<std::array<double, 4>, 4>> joinCheckMap;
|
||||||
std::map<std::string, bool> exportJoint;
|
std::map<std::string, bool> exportJoint;
|
||||||
|
|
||||||
MItDag jointIt(MItDag::TraversalType::kDepthFirst, MFn::kJoint);
|
//MItDag jointIt(MItDag::TraversalType::kDepthFirst, MFn::kJoint);
|
||||||
for (unsigned int i = startFrame; i <= endFrame; i++)
|
//for (unsigned int i = startFrame; i <= endFrame; i++)
|
||||||
{
|
//{
|
||||||
MAnimControl::setCurrentTime(MTime(i, MTime::kNTSCField));
|
// MAnimControl::setCurrentTime(MTime(i, MTime::kNTSCField));
|
||||||
while (!jointIt.isDone())
|
// while (!jointIt.isDone())
|
||||||
{
|
// {
|
||||||
m_Hierarchy.push_back(jointIt.item());
|
// m_Hierarchy.push_back(jointIt.item());
|
||||||
|
|
||||||
MFnTransform MayaJoint(jointIt.item());
|
// MFnTransform MayaJoint(jointIt.item());
|
||||||
MMatrix transformationMatrix = MayaJoint.transformationMatrix();
|
// MMatrix transformationMatrix = MayaJoint.transformationMatrix();
|
||||||
|
|
||||||
if (i == startFrame)
|
// if (i == startFrame)
|
||||||
{
|
// {
|
||||||
double doubleMat[4][4];
|
// double doubleMat[4][4];
|
||||||
transformationMatrix.get(doubleMat);
|
// transformationMatrix.get(doubleMat);
|
||||||
|
|
||||||
joinCheckMap[MayaJoint.name().asChar()][0][0] = doubleMat[0][0];
|
// joinCheckMap[MayaJoint.name().asChar()][0][0] = doubleMat[0][0];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][0][1] = doubleMat[0][1];
|
// joinCheckMap[MayaJoint.name().asChar()][0][1] = doubleMat[0][1];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][0][2] = doubleMat[0][2];
|
// joinCheckMap[MayaJoint.name().asChar()][0][2] = doubleMat[0][2];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][0][3] = doubleMat[0][3];
|
// joinCheckMap[MayaJoint.name().asChar()][0][3] = doubleMat[0][3];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][1][0] = doubleMat[1][0];
|
// joinCheckMap[MayaJoint.name().asChar()][1][0] = doubleMat[1][0];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][1][1] = doubleMat[1][1];
|
// joinCheckMap[MayaJoint.name().asChar()][1][1] = doubleMat[1][1];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][1][2] = doubleMat[1][2];
|
// joinCheckMap[MayaJoint.name().asChar()][1][2] = doubleMat[1][2];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][1][3] = doubleMat[1][3];
|
// joinCheckMap[MayaJoint.name().asChar()][1][3] = doubleMat[1][3];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][2][0] = doubleMat[2][0];
|
// joinCheckMap[MayaJoint.name().asChar()][2][0] = doubleMat[2][0];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][2][1] = doubleMat[2][1];
|
// joinCheckMap[MayaJoint.name().asChar()][2][1] = doubleMat[2][1];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][2][2] = doubleMat[2][2];
|
// joinCheckMap[MayaJoint.name().asChar()][2][2] = doubleMat[2][2];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][2][3] = doubleMat[2][3];
|
// joinCheckMap[MayaJoint.name().asChar()][2][3] = doubleMat[2][3];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][3][0] = doubleMat[3][0];
|
// joinCheckMap[MayaJoint.name().asChar()][3][0] = doubleMat[3][0];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][3][1] = doubleMat[3][1];
|
// joinCheckMap[MayaJoint.name().asChar()][3][1] = doubleMat[3][1];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][3][2] = doubleMat[3][2];
|
// joinCheckMap[MayaJoint.name().asChar()][3][2] = doubleMat[3][2];
|
||||||
joinCheckMap[MayaJoint.name().asChar()][3][3] = doubleMat[3][3];
|
// joinCheckMap[MayaJoint.name().asChar()][3][3] = doubleMat[3][3];
|
||||||
|
|
||||||
exportJoint[MayaJoint.name().asChar()] = false;
|
// exportJoint[MayaJoint.name().asChar()] = false;
|
||||||
}
|
// }
|
||||||
else if(!exportJoint[MayaJoint.name().asChar()])//!exportJoint[MayaJoint.name().asChar()])
|
// else if(!exportJoint[MayaJoint.name().asChar()])//!exportJoint[MayaJoint.name().asChar()])
|
||||||
{
|
// {
|
||||||
double doubleMat[4][4];
|
// double doubleMat[4][4];
|
||||||
|
|
||||||
doubleMat[0][0] = joinCheckMap[MayaJoint.name().asChar()][0][0];
|
// doubleMat[0][0] = joinCheckMap[MayaJoint.name().asChar()][0][0];
|
||||||
doubleMat[0][1] = joinCheckMap[MayaJoint.name().asChar()][0][1];
|
// doubleMat[0][1] = joinCheckMap[MayaJoint.name().asChar()][0][1];
|
||||||
doubleMat[0][2] = joinCheckMap[MayaJoint.name().asChar()][0][2];
|
// doubleMat[0][2] = joinCheckMap[MayaJoint.name().asChar()][0][2];
|
||||||
doubleMat[0][3] = joinCheckMap[MayaJoint.name().asChar()][0][3];
|
// doubleMat[0][3] = joinCheckMap[MayaJoint.name().asChar()][0][3];
|
||||||
doubleMat[1][0] = joinCheckMap[MayaJoint.name().asChar()][1][0];
|
// doubleMat[1][0] = joinCheckMap[MayaJoint.name().asChar()][1][0];
|
||||||
doubleMat[1][1] = joinCheckMap[MayaJoint.name().asChar()][1][1];
|
// doubleMat[1][1] = joinCheckMap[MayaJoint.name().asChar()][1][1];
|
||||||
doubleMat[1][2] = joinCheckMap[MayaJoint.name().asChar()][1][2];
|
// doubleMat[1][2] = joinCheckMap[MayaJoint.name().asChar()][1][2];
|
||||||
doubleMat[1][3] = joinCheckMap[MayaJoint.name().asChar()][1][3];
|
// doubleMat[1][3] = joinCheckMap[MayaJoint.name().asChar()][1][3];
|
||||||
doubleMat[2][0] = joinCheckMap[MayaJoint.name().asChar()][2][0];
|
// doubleMat[2][0] = joinCheckMap[MayaJoint.name().asChar()][2][0];
|
||||||
doubleMat[2][1] = joinCheckMap[MayaJoint.name().asChar()][2][1];
|
// doubleMat[2][1] = joinCheckMap[MayaJoint.name().asChar()][2][1];
|
||||||
doubleMat[2][2] = joinCheckMap[MayaJoint.name().asChar()][2][2];
|
// doubleMat[2][2] = joinCheckMap[MayaJoint.name().asChar()][2][2];
|
||||||
doubleMat[2][3] = joinCheckMap[MayaJoint.name().asChar()][2][3];
|
// doubleMat[2][3] = joinCheckMap[MayaJoint.name().asChar()][2][3];
|
||||||
doubleMat[3][0] = joinCheckMap[MayaJoint.name().asChar()][3][0];
|
// doubleMat[3][0] = joinCheckMap[MayaJoint.name().asChar()][3][0];
|
||||||
doubleMat[3][1] = joinCheckMap[MayaJoint.name().asChar()][3][1];
|
// doubleMat[3][1] = joinCheckMap[MayaJoint.name().asChar()][3][1];
|
||||||
doubleMat[3][2] = joinCheckMap[MayaJoint.name().asChar()][3][2];
|
// doubleMat[3][2] = joinCheckMap[MayaJoint.name().asChar()][3][2];
|
||||||
doubleMat[3][3] = joinCheckMap[MayaJoint.name().asChar()][3][3];
|
// doubleMat[3][3] = joinCheckMap[MayaJoint.name().asChar()][3][3];
|
||||||
|
|
||||||
MMatrix tmp(doubleMat);
|
// MMatrix tmp(doubleMat);
|
||||||
if (!tmp.isEquivalent(transformationMatrix)) {
|
// if (!tmp.isEquivalent(transformationMatrix)) {
|
||||||
MGlobal::displayInfo(MString() + MayaJoint.name() + " is exported");
|
// MGlobal::displayInfo(MString() + MayaJoint.name() + " is exported");
|
||||||
exportJoint[MayaJoint.name().asChar()] = true;
|
// exportJoint[MayaJoint.name().asChar()] = true;
|
||||||
animatedJoints.push_back(MayaJoint.object());
|
// animatedJoints.push_back(MayaJoint.object());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/*for (int i = 0; i < 9; i++)
|
/*for (int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
@@ -186,7 +186,7 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
|
|
||||||
/*MGlobal::displayInfo(MString() + "start keyfram index: " + startKeyFrameIndex + ". End keyfram index: " + endKeyFrameIndex + ".");*/
|
/*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) {
|
/*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;
|
||||||
@@ -206,13 +206,13 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
} // end of int i loop
|
} // end of int i loop*/
|
||||||
jointIt.next();
|
/* jointIt.next();
|
||||||
}
|
}
|
||||||
jointIt.reset();
|
jointIt.reset();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
int currentFrame = startFrame;
|
int currentFrame = startFrame;
|
||||||
@@ -224,18 +224,62 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
MAnimControl::setCurrentTime(MTime(currentFrame, MTime::kNTSCField));
|
MAnimControl::setCurrentTime(MTime(currentFrame, MTime::kNTSCField));
|
||||||
MTime time = MAnimControl::currentTime();
|
MTime time = MAnimControl::currentTime();
|
||||||
|
|
||||||
for (auto aJoint : animatedJoints){
|
MItDag jointIt(MItDag::TraversalType::kDepthFirst, MFn::kJoint);
|
||||||
MFnTransform thisJoint(aJoint);
|
unsigned int jointID = 0;
|
||||||
|
while (!jointIt.isDone()) {
|
||||||
|
MFnTransform thisJoint(jointIt.currentItem());
|
||||||
|
MMatrix transformationMatrix = thisJoint.transformationMatrix();
|
||||||
|
|
||||||
|
double doubleMat[4][4];
|
||||||
|
|
||||||
|
if (currentFrame != startFrame){
|
||||||
Animation::Keyframe::JointProperty joint;
|
Animation::Keyframe::JointProperty joint;
|
||||||
|
|
||||||
auto it = std::find(m_Hierarchy.begin(), m_Hierarchy.end(), thisJoint.object());
|
doubleMat[0][0] = joinCheckMap[thisJoint.name().asChar()][0][0];
|
||||||
if (it != m_Hierarchy.end()) {
|
doubleMat[0][1] = joinCheckMap[thisJoint.name().asChar()][0][1];
|
||||||
joint.ID = it - m_Hierarchy.begin();
|
doubleMat[0][2] = joinCheckMap[thisJoint.name().asChar()][0][2];
|
||||||
|
doubleMat[0][3] = joinCheckMap[thisJoint.name().asChar()][0][3];
|
||||||
|
doubleMat[1][0] = joinCheckMap[thisJoint.name().asChar()][1][0];
|
||||||
|
doubleMat[1][1] = joinCheckMap[thisJoint.name().asChar()][1][1];
|
||||||
|
doubleMat[1][2] = joinCheckMap[thisJoint.name().asChar()][1][2];
|
||||||
|
doubleMat[1][3] = joinCheckMap[thisJoint.name().asChar()][1][3];
|
||||||
|
doubleMat[2][0] = joinCheckMap[thisJoint.name().asChar()][2][0];
|
||||||
|
doubleMat[2][1] = joinCheckMap[thisJoint.name().asChar()][2][1];
|
||||||
|
doubleMat[2][2] = joinCheckMap[thisJoint.name().asChar()][2][2];
|
||||||
|
doubleMat[2][3] = joinCheckMap[thisJoint.name().asChar()][2][3];
|
||||||
|
doubleMat[3][0] = joinCheckMap[thisJoint.name().asChar()][3][0];
|
||||||
|
doubleMat[3][1] = joinCheckMap[thisJoint.name().asChar()][3][1];
|
||||||
|
doubleMat[3][2] = joinCheckMap[thisJoint.name().asChar()][3][2];
|
||||||
|
doubleMat[3][3] = joinCheckMap[thisJoint.name().asChar()][3][3];
|
||||||
|
|
||||||
|
MMatrix LastJointMatrix(doubleMat);
|
||||||
|
//Is same as last KeyFrame
|
||||||
|
if (LastJointMatrix.isEquivalent(transformationMatrix)) {
|
||||||
|
jointID++;
|
||||||
|
jointIt.next();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
MGlobal::displayError(MString() + "Could not find joint ID for: " + thisJoint.name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transformationMatrix.get(doubleMat);
|
||||||
|
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][0][0] = doubleMat[0][0];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][0][1] = doubleMat[0][1];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][0][2] = doubleMat[0][2];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][0][3] = doubleMat[0][3];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][1][0] = doubleMat[1][0];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][1][1] = doubleMat[1][1];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][1][2] = doubleMat[1][2];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][1][3] = doubleMat[1][3];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][2][0] = doubleMat[2][0];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][2][1] = doubleMat[2][1];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][2][2] = doubleMat[2][2];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][2][3] = doubleMat[2][3];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][3][0] = doubleMat[3][0];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][3][1] = doubleMat[3][1];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][3][2] = doubleMat[3][2];
|
||||||
|
joinCheckMap[thisJoint.name().asChar()][3][3] = doubleMat[3][3];
|
||||||
|
|
||||||
MTransformationMatrix Matrix = thisJoint.transformation();
|
MTransformationMatrix Matrix = thisJoint.transformation();
|
||||||
MPlug BindPose = thisJoint.findPlug("bindPose");
|
MPlug BindPose = thisJoint.findPlug("bindPose");
|
||||||
MDataHandle DataHandle;
|
MDataHandle DataHandle;
|
||||||
@@ -264,6 +308,9 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
rotation = rotation * jo;
|
rotation = rotation * jo;
|
||||||
rotation.get(tmp);
|
rotation.get(tmp);
|
||||||
|
|
||||||
|
Animation::Keyframe::JointProperty joint;
|
||||||
|
joint.ID = jointID;
|
||||||
|
|
||||||
joint.Rotation[0] = tmp[0];
|
joint.Rotation[0] = tmp[0];
|
||||||
joint.Rotation[1] = tmp[1];
|
joint.Rotation[1] = tmp[1];
|
||||||
joint.Rotation[2] = tmp[2];
|
joint.Rotation[2] = tmp[2];
|
||||||
@@ -278,13 +325,16 @@ Animation Skeleton::GetAnimData(std::string animationName, int startFrame, int e
|
|||||||
joint.Scale[2] = tmp[2];
|
joint.Scale[2] = tmp[2];
|
||||||
|
|
||||||
thisKeyFrame.JointProperties.push_back(joint);
|
thisKeyFrame.JointProperties.push_back(joint);
|
||||||
|
|
||||||
|
jointID++;
|
||||||
|
jointIt.next();
|
||||||
}
|
}
|
||||||
|
thisKeyFrame.NumberOfJoints = thisKeyFrame.JointProperties.size();
|
||||||
returnData.Keyframes.push_back(thisKeyFrame);
|
returnData.Keyframes.push_back(thisKeyFrame);
|
||||||
currentFrame++;
|
currentFrame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData.NumKeyFrames = returnData.Keyframes.size();
|
returnData.NumKeyFrames = returnData.Keyframes.size();
|
||||||
returnData.NumberOfJoints = animatedJoints.size();
|
|
||||||
|
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
@@ -310,13 +360,11 @@ std::vector<BindPoseSkeletonNode> Skeleton::GetBindPoses()
|
|||||||
}
|
}
|
||||||
SkeletonStorage.Name = std::string(MayaJoint.name().asChar());
|
SkeletonStorage.Name = std::string(MayaJoint.name().asChar());
|
||||||
NewJoint.ParentID = -1; // This joint is root
|
NewJoint.ParentID = -1; // This joint is root
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
auto it = std::find(m_Hierarchy.begin(), m_Hierarchy.end(), MayaJoint.parent(0));
|
auto it = std::find(m_Hierarchy.begin(), m_Hierarchy.end(), MayaJoint.parent(0));
|
||||||
if (it != m_Hierarchy.end()) {
|
if (it != m_Hierarchy.end()) {
|
||||||
NewJoint.ParentID = it - m_Hierarchy.begin();
|
NewJoint.ParentID = it - m_Hierarchy.begin();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
MGlobal::displayError(MString() + "Could not find joint parent for: " + MayaJoint.name());
|
MGlobal::displayError(MString() + "Could not find joint parent for: " + MayaJoint.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public:
|
|||||||
|
|
||||||
int Index = 0;
|
int Index = 0;
|
||||||
float Time = 0;
|
float Time = 0;
|
||||||
|
int NumberOfJoints;
|
||||||
std::vector<JointProperty> JointProperties;
|
std::vector<JointProperty> JointProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,7 +30,6 @@ public:
|
|||||||
int nameLength = 0;
|
int nameLength = 0;
|
||||||
float Duration = 0;
|
float Duration = 0;
|
||||||
int NumKeyFrames = 0;
|
int NumKeyFrames = 0;
|
||||||
int NumberOfJoints = 0;
|
|
||||||
std::vector<Keyframe> Keyframes;
|
std::vector<Keyframe> Keyframes;
|
||||||
|
|
||||||
virtual void WriteBinary(std::ostream& out)
|
virtual void WriteBinary(std::ostream& out)
|
||||||
@@ -38,11 +38,11 @@ public:
|
|||||||
out.write(Name.c_str(), Name.size() + 1);
|
out.write(Name.c_str(), Name.size() + 1);
|
||||||
out.write((char*)&Duration, sizeof(float));
|
out.write((char*)&Duration, sizeof(float));
|
||||||
out.write((char*)&NumKeyFrames, sizeof(int));
|
out.write((char*)&NumKeyFrames, sizeof(int));
|
||||||
out.write((char*)&NumberOfJoints, sizeof(int));
|
|
||||||
//Här under loopas alla key frames igenom
|
//Här under loopas alla key frames igenom
|
||||||
for (auto aKeyframe : Keyframes) {
|
for (auto aKeyframe : Keyframes) {
|
||||||
out.write((char*)&aKeyframe.Index, sizeof(int));
|
out.write((char*)&aKeyframe.Index, sizeof(int));
|
||||||
out.write((char*)&aKeyframe.Time, sizeof(float));
|
out.write((char*)&aKeyframe.Time, sizeof(float));
|
||||||
|
out.write((char*)&aKeyframe.NumberOfJoints, sizeof(int));
|
||||||
for (auto aJoint : aKeyframe.JointProperties) {
|
for (auto aJoint : aKeyframe.JointProperties) {
|
||||||
out.write((char*)&aJoint.ID, sizeof(int));
|
out.write((char*)&aJoint.ID, sizeof(int));
|
||||||
out.write((char*)aJoint.Position, sizeof(float) * 3);
|
out.write((char*)aJoint.Position, sizeof(float) * 3);
|
||||||
@@ -57,10 +57,10 @@ public:
|
|||||||
out << "Animation Name: " << Name << endl;
|
out << "Animation Name: " << Name << endl;
|
||||||
out << "Duration: " << Duration << endl;
|
out << "Duration: " << Duration << endl;
|
||||||
out << "Number of KeyFrames: " << NumKeyFrames << endl;
|
out << "Number of KeyFrames: " << NumKeyFrames << endl;
|
||||||
out << "Number of Joints: " << NumberOfJoints << endl;
|
|
||||||
for (auto aKeyframe : Keyframes) {
|
for (auto aKeyframe : Keyframes) {
|
||||||
out << "Frame: " << aKeyframe.Index << endl;
|
out << "Frame: " << aKeyframe.Index << endl;
|
||||||
out << "Time: " << aKeyframe.Time << endl;
|
out << "Time: " << aKeyframe.Time << endl;
|
||||||
|
out << "Number of Joints: " << aKeyframe.NumberOfJoints << endl;
|
||||||
for (auto aJoint : aKeyframe.JointProperties) {
|
for (auto aJoint : aKeyframe.JointProperties) {
|
||||||
out << "Joint ID: " << aJoint.ID << endl;
|
out << "Joint ID: " << aJoint.ID << endl;
|
||||||
out << aJoint.Position[0] << " " << aJoint.Position[1] << " " << aJoint.Position[2] << endl;
|
out << aJoint.Position[0] << " " << aJoint.Position[1] << " " << aJoint.Position[2] << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user