Merge branch 'MayaExporter' of https://github.com/teamfisk/TacticalZ into MayaExporter
# Conflicts: # tools/MayaExporter/MayaExporter/Menu.h
This commit is contained in:
@@ -145,6 +145,7 @@ void Menu::Button1Clicked(bool)
|
||||
{
|
||||
if (m_ExportAnimationsButton->isChecked()) {
|
||||
MGlobal::displayInfo("1 checked!");
|
||||
this->GetSkeletonData();
|
||||
}
|
||||
else {
|
||||
MGlobal::displayInfo("1 unchecked!");
|
||||
@@ -185,7 +186,20 @@ void Menu::GetMaterialData()
|
||||
|
||||
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()
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "MayaIncludes.h"
|
||||
#include "Material.h"
|
||||
#include "Mesh.h"
|
||||
#include "Var.h"
|
||||
#include "Skeleton.h"
|
||||
|
||||
class Menu : public QWidget
|
||||
{
|
||||
@@ -72,6 +72,7 @@ private:
|
||||
QDialog* m_DialogPointer = nullptr;
|
||||
|
||||
Material* m_MaterialHandler = nullptr;
|
||||
Skeleton* m_SkeletonHandler = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,55 @@
|
||||
#include "Skeleton.h"
|
||||
|
||||
//std::vector<SkeletonNode>* Skeleton::DoIt()
|
||||
//{
|
||||
// MItDependencyNodes jointIt(MFn::kJoint);
|
||||
//
|
||||
// for (; !jointIt.isDone(); jointIt.next())
|
||||
// {
|
||||
// //MFnDependencyNode
|
||||
// }
|
||||
//}
|
||||
std::vector<SkeletonNode>* Skeleton::DoIt()
|
||||
{
|
||||
MItDependencyNodes jointIt(MFn::kJoint);
|
||||
SkeletonNode SkeletonStorage;
|
||||
|
||||
while (!jointIt.isDone()) {
|
||||
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 <array>
|
||||
#include <algorithm>
|
||||
#include "MayaIncludes.h"
|
||||
|
||||
struct Joint {
|
||||
int ParentIndex;
|
||||
std::array<float, 3> Rotation;
|
||||
std::array<float, 3> Translation;
|
||||
std::array<float, 3> Scale;
|
||||
//std::array<float, 3> Rotation;
|
||||
//std::array<float, 3> Translation;
|
||||
//std::array<float, 3> Scale;
|
||||
std::array<std::array<float, 4>, 4> OffsetMatrix;
|
||||
std::string Name;
|
||||
};
|
||||
|
||||
struct SkeletonNode {
|
||||
std::string Name;
|
||||
std::vector<Joint> joints;
|
||||
std::vector<Joint> Joints;
|
||||
};
|
||||
|
||||
class Skeleton {
|
||||
public:
|
||||
//std::vector<SkeletonNode>* DoIt();
|
||||
std::vector<SkeletonNode>* DoIt();
|
||||
private:
|
||||
//std::vector<SkeletonNode> m_AllSkeletons;
|
||||
std::vector<SkeletonNode> m_AllSkeletons;
|
||||
std::vector<MObject> m_Hierarchy;
|
||||
};
|
||||
|
||||
#endif //Skeleton_Skeleton_h__
|
||||
Reference in New Issue
Block a user