Export the skeletons
Not really tested though
This commit is contained in:
@@ -145,6 +145,7 @@ void Menu::Button1Clicked(bool)
|
|||||||
{
|
{
|
||||||
if (m_ExportAnimationsButton->isChecked()) {
|
if (m_ExportAnimationsButton->isChecked()) {
|
||||||
MGlobal::displayInfo("1 checked!");
|
MGlobal::displayInfo("1 checked!");
|
||||||
|
this->GetSkeletonData();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MGlobal::displayInfo("1 unchecked!");
|
MGlobal::displayInfo("1 unchecked!");
|
||||||
@@ -185,7 +186,20 @@ void Menu::GetMaterialData()
|
|||||||
|
|
||||||
void Menu::GetSkeletonData()
|
void Menu::GetSkeletonData()
|
||||||
{
|
{
|
||||||
|
this->m_SkeletonHandler = new Skeleton();
|
||||||
|
|
||||||
|
// Traverse scene and return vector with all materials
|
||||||
|
std::vector<SkeletonNode>* AllMaterials = m_SkeletonHandler->DoIt();
|
||||||
|
|
||||||
|
MGlobal::displayInfo(MString() + AllMaterials->size());
|
||||||
|
|
||||||
|
for (int i = 0; i < AllMaterials->size(); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < AllMaterials->at(i).Joints.size(); j++)
|
||||||
|
{
|
||||||
|
MGlobal::displayInfo(MString() + AllMaterials->at(i).Joints.at(j).Name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::~Menu()
|
Menu::~Menu()
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "MayaIncludes.h"
|
#include "MayaIncludes.h"
|
||||||
#include "Material.h"
|
#include "Material.h"
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
|
#include "Skeleton.h"
|
||||||
|
|
||||||
class Menu : public QWidget
|
class Menu : public QWidget
|
||||||
{
|
{
|
||||||
@@ -71,6 +72,7 @@ private:
|
|||||||
QDialog* m_DialogPointer = nullptr;
|
QDialog* m_DialogPointer = nullptr;
|
||||||
|
|
||||||
Material* m_MaterialHandler = nullptr;
|
Material* m_MaterialHandler = nullptr;
|
||||||
|
Skeleton* m_SkeletonHandler = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,11 +1,55 @@
|
|||||||
#include "Skeleton.h"
|
#include "Skeleton.h"
|
||||||
|
|
||||||
//std::vector<SkeletonNode>* Skeleton::DoIt()
|
std::vector<SkeletonNode>* Skeleton::DoIt()
|
||||||
//{
|
{
|
||||||
// MItDependencyNodes jointIt(MFn::kJoint);
|
MItDependencyNodes jointIt(MFn::kJoint);
|
||||||
//
|
SkeletonNode SkeletonStorage;
|
||||||
// for (; !jointIt.isDone(); jointIt.next())
|
|
||||||
// {
|
while (!jointIt.isDone()) {
|
||||||
// //MFnDependencyNode
|
MFnDependencyNode SkeletonFnDN(jointIt.thisNode());
|
||||||
// }
|
MFnTransform TransformNode(SkeletonFnDN.object());
|
||||||
//}
|
Joint NewJoint;
|
||||||
|
|
||||||
|
if (MFnDependencyNode(TransformNode.parent(0)).name() == "world") {
|
||||||
|
if (SkeletonStorage.Joints.size() != 0) {
|
||||||
|
m_AllSkeletons.push_back(SkeletonStorage);
|
||||||
|
|
||||||
|
SkeletonStorage.Joints.clear();
|
||||||
|
SkeletonStorage.Name.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
SkeletonStorage.Name = TransformNode.name().asChar();
|
||||||
|
|
||||||
|
NewJoint.ParentIndex = -1; // This joint is root
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto it = std::find(m_Hierarchy.begin(), m_Hierarchy.end(), TransformNode.parent(0));
|
||||||
|
if (it != m_Hierarchy.end()) {
|
||||||
|
NewJoint.ParentIndex = it - m_Hierarchy.begin();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MGlobal::displayError(MString() + "Could not find joint parent for: " + TransformNode.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Hierarchy.push_back(TransformNode.object());
|
||||||
|
|
||||||
|
NewJoint.Name = TransformNode.name().asChar();
|
||||||
|
|
||||||
|
MMatrix Matrix = TransformNode.transformationMatrix();
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
for (int j = 0; j < 4; j++) {
|
||||||
|
NewJoint.OffsetMatrix[i][j] = Matrix.matrix[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SkeletonStorage.Joints.push_back(NewJoint);
|
||||||
|
|
||||||
|
jointIt.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_AllSkeletons.push_back(SkeletonStorage);
|
||||||
|
|
||||||
|
return &m_AllSkeletons;
|
||||||
|
}
|
||||||
@@ -3,25 +3,29 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <algorithm>
|
||||||
#include "MayaIncludes.h"
|
#include "MayaIncludes.h"
|
||||||
|
|
||||||
struct Joint {
|
struct Joint {
|
||||||
int ParentIndex;
|
int ParentIndex;
|
||||||
std::array<float, 3> Rotation;
|
//std::array<float, 3> Rotation;
|
||||||
std::array<float, 3> Translation;
|
//std::array<float, 3> Translation;
|
||||||
std::array<float, 3> Scale;
|
//std::array<float, 3> Scale;
|
||||||
|
std::array<std::array<float, 4>, 4> OffsetMatrix;
|
||||||
|
std::string Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SkeletonNode {
|
struct SkeletonNode {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::vector<Joint> joints;
|
std::vector<Joint> Joints;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Skeleton {
|
class Skeleton {
|
||||||
public:
|
public:
|
||||||
//std::vector<SkeletonNode>* DoIt();
|
std::vector<SkeletonNode>* DoIt();
|
||||||
private:
|
private:
|
||||||
//std::vector<SkeletonNode> m_AllSkeletons;
|
std::vector<SkeletonNode> m_AllSkeletons;
|
||||||
|
std::vector<MObject> m_Hierarchy;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //Skeleton_Skeleton_h__
|
#endif //Skeleton_Skeleton_h__
|
||||||
Reference in New Issue
Block a user