Tested some of the Material Code. Seems to work. The project should now be following the code standard properly (hopefully).
This commit is contained in:
@@ -9,3 +9,6 @@ lib/
|
|||||||
*.sdf
|
*.sdf
|
||||||
tools/MayaExporter/MayaExporter/x64/Debug/
|
tools/MayaExporter/MayaExporter/x64/Debug/
|
||||||
tools/MayaExporter/x64/Debug/
|
tools/MayaExporter/x64/Debug/
|
||||||
|
|
||||||
|
tools/MayaExporter/MayaExporter/Debug/
|
||||||
|
tools/MayaExporter/MayaExporter/GeneratedFiles/
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ bool Material::findColorTexture(MaterialNode& material_node, MFnDependencyNode&
|
|||||||
|
|
||||||
material_node.ColorMapFile = FullPath.substr(FullPath.find_last_of("/"));
|
material_node.ColorMapFile = FullPath.substr(FullPath.find_last_of("/"));
|
||||||
|
|
||||||
|
// Test
|
||||||
|
MGlobal::displayInfo(MString() + "Texture file: " + FullPath.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "MayaIncludes.h"
|
#include "MayaIncludes.h"
|
||||||
|
|
||||||
struct MaterialNode
|
struct MaterialNode
|
||||||
|
|||||||
@@ -173,6 +173,7 @@
|
|||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Main.cpp" />
|
<ClCompile Include="Main.cpp" />
|
||||||
|
<ClCompile Include="Mesh.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="MayaExporter.ui">
|
<CustomBuild Include="MayaExporter.ui">
|
||||||
@@ -195,6 +196,7 @@
|
|||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Mesh.h" />
|
||||||
<CustomBuild Include="Menu.h">
|
<CustomBuild Include="Menu.h">
|
||||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing Menu.h...</Message>
|
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing Menu.h...</Message>
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
|
||||||
|
|||||||
@@ -53,6 +53,9 @@
|
|||||||
<ClCompile Include="Material.cpp">
|
<ClCompile Include="Material.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Mesh.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="leeeeel.qrc">
|
<CustomBuild Include="leeeeel.qrc">
|
||||||
@@ -75,5 +78,8 @@
|
|||||||
<ClInclude Include="Material.h">
|
<ClInclude Include="Material.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Mesh.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -10,39 +10,39 @@ Menu::Menu()
|
|||||||
Menu::Menu(QDialog* dialog)
|
Menu::Menu(QDialog* dialog)
|
||||||
{
|
{
|
||||||
// Save the dialog pointer. Needed when the application gets destroyed
|
// Save the dialog pointer. Needed when the application gets destroyed
|
||||||
dialogPointer = dialog;
|
m_DialogPointer = dialog;
|
||||||
|
|
||||||
// Create QpushButtons & give them names
|
// Create QpushButtons & give them names
|
||||||
exportSelectedButton = new QPushButton("&Export Selected", this);
|
m_ExportSelectedButton = new QPushButton("&Export Selected", this);
|
||||||
browseButton = new QPushButton("&...", this);
|
m_BrowseButton = new QPushButton("&...", this);
|
||||||
exportAllButton = new QPushButton("&Export All", this);
|
m_ExportAllButton = new QPushButton("&Export All", this);
|
||||||
cancelButton = new QPushButton("&Cancel", this);
|
m_CancelButton = new QPushButton("&Cancel", this);
|
||||||
|
|
||||||
// Option box and checkboxes
|
// Option box and checkboxes
|
||||||
QGroupBox *optionsBox = new QGroupBox(tr("Options"));
|
QGroupBox *optionsBox = new QGroupBox(tr("Options"));
|
||||||
|
|
||||||
exportAnimationsButton = new QCheckBox(tr("&Export Animations"));
|
m_ExportAnimationsButton = new QCheckBox(tr("&Export Animations"));
|
||||||
copyTexturesButton = new QCheckBox(tr("&Copy Textures"));
|
m_CopyTexturesButton = new QCheckBox(tr("&Copy Textures"));
|
||||||
button3 = new QCheckBox(tr("option3"));
|
m_Button3 = new QCheckBox(tr("Test Materials"));
|
||||||
|
|
||||||
exportAnimationsButton->setChecked(true);
|
m_ExportAnimationsButton->setChecked(true);
|
||||||
copyTexturesButton->setChecked(true);
|
m_CopyTexturesButton->setChecked(true);
|
||||||
QVBoxLayout *vbox = new QVBoxLayout;
|
QVBoxLayout *vbox = new QVBoxLayout;
|
||||||
vbox->addWidget(exportAnimationsButton);
|
vbox->addWidget(m_ExportAnimationsButton);
|
||||||
vbox->addWidget(copyTexturesButton);
|
vbox->addWidget(m_CopyTexturesButton);
|
||||||
vbox->addWidget(button3);
|
vbox->addWidget(m_Button3);
|
||||||
vbox->addStretch(1);
|
vbox->addStretch(1);
|
||||||
optionsBox->setLayout(vbox);
|
optionsBox->setLayout(vbox);
|
||||||
|
|
||||||
// Connect the buttons with signals & functions
|
// Connect the buttons with signals & functions
|
||||||
connect(exportSelectedButton, SIGNAL(clicked(bool)), this, SLOT(ExportSelected(bool)));
|
connect(m_ExportSelectedButton, SIGNAL(clicked(bool)), this, SLOT(ExportSelected(bool)));
|
||||||
connect(browseButton, SIGNAL(clicked(bool)), this, SLOT(ExportPathClicked(bool)));
|
connect(m_BrowseButton, SIGNAL(clicked(bool)), this, SLOT(ExportPathClicked(bool)));
|
||||||
connect(exportAllButton, SIGNAL(clicked(bool)), this, SLOT(ExportAll(bool)));
|
connect(m_ExportAllButton, SIGNAL(clicked(bool)), this, SLOT(ExportAll(bool)));
|
||||||
connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(CancelClicked(bool)));
|
connect(m_CancelButton, SIGNAL(clicked(bool)), this, SLOT(CancelClicked(bool)));
|
||||||
|
|
||||||
connect(exportAnimationsButton, SIGNAL(clicked(bool)), this, SLOT(Button1Clicked(bool)));
|
connect(m_ExportAnimationsButton, SIGNAL(clicked(bool)), this, SLOT(Button1Clicked(bool)));
|
||||||
connect(copyTexturesButton, SIGNAL(clicked(bool)), this, SLOT(Button2Clicked(bool)));
|
connect(m_CopyTexturesButton, SIGNAL(clicked(bool)), this, SLOT(Button2Clicked(bool)));
|
||||||
connect(button3, SIGNAL(clicked(bool)), this, SLOT(Button3Clicked(bool)));
|
connect(m_Button3, SIGNAL(clicked(bool)), this, SLOT(Button3Clicked(bool)));
|
||||||
|
|
||||||
// Creating several layouts, adding widgets & adding them to one layout in the end
|
// Creating several layouts, adding widgets & adding them to one layout in the end
|
||||||
QHBoxLayout* topLayout = new QHBoxLayout;
|
QHBoxLayout* topLayout = new QHBoxLayout;
|
||||||
@@ -50,8 +50,8 @@ Menu::Menu(QDialog* dialog)
|
|||||||
QHBoxLayout* botLayout = new QHBoxLayout;
|
QHBoxLayout* botLayout = new QHBoxLayout;
|
||||||
QVBoxLayout* baseLayout = new QVBoxLayout;
|
QVBoxLayout* baseLayout = new QVBoxLayout;
|
||||||
|
|
||||||
exportPath = new QLineEdit;
|
m_ExportPath = new QLineEdit;
|
||||||
fileDialog = new QFileDialog;
|
m_FileDialog = new QFileDialog;
|
||||||
|
|
||||||
QLabel* exportLabel = new QLabel;
|
QLabel* exportLabel = new QLabel;
|
||||||
exportLabel->setText("Export Path:");
|
exportLabel->setText("Export Path:");
|
||||||
@@ -59,12 +59,12 @@ Menu::Menu(QDialog* dialog)
|
|||||||
midLayout->addWidget(optionsBox);
|
midLayout->addWidget(optionsBox);
|
||||||
|
|
||||||
topLayout->addWidget(exportLabel);
|
topLayout->addWidget(exportLabel);
|
||||||
topLayout->addWidget(exportPath);
|
topLayout->addWidget(m_ExportPath);
|
||||||
topLayout->addWidget(browseButton);
|
topLayout->addWidget(m_BrowseButton);
|
||||||
|
|
||||||
botLayout->addWidget(exportSelectedButton);
|
botLayout->addWidget(m_ExportSelectedButton);
|
||||||
botLayout->addWidget(exportAllButton);
|
botLayout->addWidget(m_ExportAllButton);
|
||||||
botLayout->addWidget(cancelButton);
|
botLayout->addWidget(m_CancelButton);
|
||||||
|
|
||||||
baseLayout->addLayout(topLayout);
|
baseLayout->addLayout(topLayout);
|
||||||
baseLayout->addLayout(midLayout);
|
baseLayout->addLayout(midLayout);
|
||||||
@@ -86,28 +86,30 @@ void Menu::ExportSelected(bool checked)
|
|||||||
MGlobal::getActiveSelectionList(selected);
|
MGlobal::getActiveSelectionList(selected);
|
||||||
|
|
||||||
// Loop through or list of selection(s)
|
// Loop through or list of selection(s)
|
||||||
for (unsigned int i = 0; i < selected.length();i++)
|
for (unsigned int i = 0; i < selected.length();i++) {
|
||||||
{
|
|
||||||
MObject object;
|
MObject object;
|
||||||
selected.getDependNode(i, object);
|
selected.getDependNode(i, object);
|
||||||
MFnDependencyNode thisNode(object);
|
MFnDependencyNode thisNode(object);
|
||||||
|
|
||||||
cout << thisNode.name().asChar() << endl;
|
cout << thisNode.name().asChar() << endl;
|
||||||
GetMeshData(object);
|
Mesh mesh;
|
||||||
|
mesh.GetMeshData(object);
|
||||||
}
|
}
|
||||||
if (exportPath->text().isEmpty())
|
if (m_ExportPath->text().isEmpty()) {
|
||||||
cout << "Please select a folder." << endl;
|
cout << "Please select a folder." << endl;
|
||||||
else
|
}
|
||||||
cout << exportPath->text().toLocal8Bit().constData() << endl;
|
else {
|
||||||
|
cout << m_ExportPath->text().toLocal8Bit().constData() << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::ExportPathClicked(bool)
|
void Menu::ExportPathClicked(bool)
|
||||||
{
|
{
|
||||||
// Opens up a file dialog. Save/Changes the name in the exportPath
|
// Opens up a file dialog. Save/Changes the name in the exportPath
|
||||||
fileDialog->setFileMode(QFileDialog::Directory);
|
m_FileDialog->setFileMode(QFileDialog::Directory);
|
||||||
fileDialog->setOption(QFileDialog::ShowDirsOnly);
|
m_FileDialog->setOption(QFileDialog::ShowDirsOnly);
|
||||||
QString fileName = fileDialog->getExistingDirectory(this, "Select", "/home", QFileDialog::ShowDirsOnly);
|
QString fileName = m_FileDialog->getExistingDirectory(this, "Select", "/home", QFileDialog::ShowDirsOnly);
|
||||||
exportPath->setText(fileName);
|
m_ExportPath->setText(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::ExportAll(bool)
|
void Menu::ExportAll(bool)
|
||||||
@@ -116,118 +118,65 @@ void Menu::ExportAll(bool)
|
|||||||
|
|
||||||
// Loop through all nodes in the scene
|
// Loop through all nodes in the scene
|
||||||
MItDependencyNodes it(MFn::kInvalid);
|
MItDependencyNodes it(MFn::kInvalid);
|
||||||
for (;!it.isDone();it.next())
|
for (;!it.isDone();it.next()) {
|
||||||
{
|
|
||||||
MObject node = it.thisNode();
|
MObject node = it.thisNode();
|
||||||
if (node.hasFn(MFn::kMesh))
|
if (node.hasFn(MFn::kMesh)) {
|
||||||
{
|
|
||||||
MFnDependencyNode thisNode(node);
|
MFnDependencyNode thisNode(node);
|
||||||
|
|
||||||
cout << thisNode.name().asChar() << endl;
|
cout << thisNode.name().asChar() << endl;
|
||||||
GetMeshData(node);
|
Mesh mesh;
|
||||||
|
mesh.GetMeshData(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exportPath->text().isEmpty())
|
if (m_ExportPath->text().isEmpty()) {
|
||||||
cout << "Please select a folder." << endl;
|
cout << "Please select a folder." << endl;
|
||||||
else
|
}
|
||||||
cout << exportPath->text().toLocal8Bit().constData() << endl;
|
else {
|
||||||
|
cout << m_ExportPath->text().toLocal8Bit().constData() << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::CancelClicked(bool)
|
void Menu::CancelClicked(bool)
|
||||||
{
|
{
|
||||||
dialogPointer->close();
|
m_DialogPointer->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::Button1Clicked(bool)
|
void Menu::Button1Clicked(bool)
|
||||||
{
|
{
|
||||||
if(exportAnimationsButton->isChecked())
|
if (m_ExportAnimationsButton->isChecked()) {
|
||||||
MGlobal::displayInfo("1 checked!");
|
MGlobal::displayInfo("1 checked!");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
MGlobal::displayInfo("1 unchecked!");
|
MGlobal::displayInfo("1 unchecked!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::Button2Clicked(bool)
|
void Menu::Button2Clicked(bool)
|
||||||
{
|
{
|
||||||
if (copyTexturesButton->isChecked())
|
if (m_CopyTexturesButton->isChecked()) {
|
||||||
cout << "2 checked!" << endl;
|
cout << "2 checked!" << endl;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
cout << "2 unchecked!" << endl;
|
cout << "2 unchecked!" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::Button3Clicked(bool)
|
void Menu::Button3Clicked(bool)
|
||||||
{
|
{
|
||||||
if (button3->isChecked())
|
if (m_Button3->isChecked()) {
|
||||||
cout << "3 checked!" << endl;
|
cout << "3 checked!" << endl;
|
||||||
else
|
|
||||||
cout << "3 unchecked!" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::GetMeshData(MObject object)
|
|
||||||
{
|
|
||||||
// In here, we retrieve triangulated polygons from the mesh
|
|
||||||
MFnMesh mesh(object);
|
|
||||||
|
|
||||||
map<UINT, vector<UINT>> vertexToIndex;
|
|
||||||
|
|
||||||
vector<VertexLayout> verticesData;
|
|
||||||
vector<UINT>indexArray;
|
|
||||||
|
|
||||||
MIntArray intdexOffsetVertexCount, vertices, triangleList;
|
|
||||||
MPointArray dummy;
|
|
||||||
|
|
||||||
UINT vertexIndex;
|
|
||||||
MVector normal;
|
|
||||||
MPoint pos;
|
|
||||||
float2 UV;
|
|
||||||
VertexLayout thisVertex;
|
|
||||||
|
|
||||||
for (MItMeshPolygon meshPolyIter(object); !meshPolyIter.isDone(); meshPolyIter.next())
|
|
||||||
{
|
|
||||||
vector<UINT> localVertexToGlobalIndex;
|
|
||||||
meshPolyIter.getVertices(vertices);
|
|
||||||
|
|
||||||
meshPolyIter.getTriangles(dummy, triangleList);
|
|
||||||
UINT indexOffset = verticesData.size();
|
|
||||||
|
|
||||||
for (UINT i = 0; i < vertices.length(); i++)
|
|
||||||
{
|
|
||||||
vertexIndex = meshPolyIter.vertexIndex(i);
|
|
||||||
pos = meshPolyIter.point(i);
|
|
||||||
pos.get(thisVertex.pos);
|
|
||||||
|
|
||||||
meshPolyIter.getNormal(i, normal);
|
|
||||||
thisVertex.normal[0] = normal[0];
|
|
||||||
thisVertex.normal[1] = normal[1];
|
|
||||||
thisVertex.normal[2] = normal[2];
|
|
||||||
|
|
||||||
meshPolyIter.getUV(i, UV);
|
|
||||||
thisVertex.uv[0] = UV[0];
|
|
||||||
thisVertex.uv[1] = UV[1];
|
|
||||||
|
|
||||||
verticesData.push_back(thisVertex);
|
|
||||||
localVertexToGlobalIndex.push_back(vertexIndex);
|
|
||||||
|
|
||||||
cout << "Pos: " << thisVertex.pos[0] << "/" << thisVertex.pos[1] << "/" << thisVertex.pos[2] << endl;
|
|
||||||
cout << "Normals: " << thisVertex.normal[0] << "/" << thisVertex.normal[1] << "/" << thisVertex.normal[2] << endl;
|
|
||||||
cout << "UV: " << thisVertex.uv[0] << "/" << thisVertex.uv[1] << endl;
|
|
||||||
}
|
|
||||||
for (UINT i = 0; i < triangleList.length(); i++)
|
|
||||||
{
|
|
||||||
UINT k = 0;
|
|
||||||
while (localVertexToGlobalIndex[k] != triangleList[i])
|
|
||||||
k++;
|
|
||||||
indexArray.push_back(indexOffset + k);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
cout << "3 unchecked!" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::GetMaterialData()
|
void Menu::GetMaterialData()
|
||||||
{
|
{
|
||||||
this->MaterialHandler = new Material();
|
this->m_MaterialHandler = new Material();
|
||||||
|
|
||||||
// Traverse scene and return vector with all materials
|
// Traverse scene and return vector with all materials
|
||||||
std::vector<MaterialNode>* AllMaterials = MaterialHandler->DoIt();
|
std::vector<MaterialNode>* AllMaterials = m_MaterialHandler->DoIt();
|
||||||
|
|
||||||
// Access the colorR component of one material (example)
|
// Access the colorR component of one material (example)
|
||||||
cout << AllMaterials->at(0).Color[0] << endl;
|
cout << AllMaterials->at(0).Color[0] << endl;
|
||||||
@@ -240,6 +189,6 @@ Menu::~Menu()
|
|||||||
//delete browseButton;
|
//delete browseButton;
|
||||||
//delete exportPath;
|
//delete exportPath;
|
||||||
//delete fileDialog;
|
//delete fileDialog;
|
||||||
fileDialog->~QFileDialog();
|
m_FileDialog->~QFileDialog();
|
||||||
delete MaterialHandler;
|
//delete MaterialHandler;
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
#ifndef BUTTONS_H
|
#ifndef Menu_Menu_h__
|
||||||
#define BUTTONS_H
|
#define Menu_Menu_h__
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "MayaIncludes.h"
|
|
||||||
#include "Material.h"
|
|
||||||
// Qt
|
// Qt
|
||||||
#pragma comment(lib, "QtCore4")
|
#pragma comment(lib, "QtCore4")
|
||||||
#pragma comment(lib, "QtGui4")
|
#pragma comment(lib, "QtGui4")
|
||||||
@@ -32,12 +30,9 @@
|
|||||||
#include <QtGui/qlineedit.h>
|
#include <QtGui/qlineedit.h>
|
||||||
#include <QtGui/qgroupbox.h>
|
#include <QtGui/qgroupbox.h>
|
||||||
|
|
||||||
struct VertexLayout
|
#include "MayaIncludes.h"
|
||||||
{
|
#include "Material.h"
|
||||||
float pos[3];
|
#include "Mesh.h"
|
||||||
float normal[3];
|
|
||||||
float uv[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
class Menu : public QWidget
|
class Menu : public QWidget
|
||||||
{
|
{
|
||||||
@@ -46,7 +41,6 @@ public:
|
|||||||
Menu(QDialog* dialog);
|
Menu(QDialog* dialog);
|
||||||
~Menu();
|
~Menu();
|
||||||
|
|
||||||
void GetMeshData(MObject object);
|
|
||||||
void GetMaterialData();
|
void GetMaterialData();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -62,20 +56,20 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Menu();
|
Menu();
|
||||||
QPushButton* exportSelectedButton;
|
QPushButton* m_ExportSelectedButton = nullptr;
|
||||||
QPushButton* browseButton;
|
QPushButton* m_BrowseButton = nullptr;
|
||||||
QPushButton* exportAllButton;
|
QPushButton* m_ExportAllButton = nullptr;
|
||||||
QPushButton* cancelButton;
|
QPushButton* m_CancelButton = nullptr;
|
||||||
|
|
||||||
QCheckBox* exportAnimationsButton;
|
QCheckBox* m_ExportAnimationsButton = nullptr;
|
||||||
QCheckBox* copyTexturesButton;
|
QCheckBox* m_CopyTexturesButton = nullptr;
|
||||||
QCheckBox* button3;
|
QCheckBox* m_Button3 = nullptr;
|
||||||
|
|
||||||
QLineEdit* exportPath;
|
QLineEdit* m_ExportPath = nullptr;
|
||||||
QFileDialog* fileDialog;
|
QFileDialog* m_FileDialog = nullptr;
|
||||||
QDialog* dialogPointer;
|
QDialog* m_DialogPointer = nullptr;
|
||||||
|
|
||||||
Material* MaterialHandler;
|
Material* m_MaterialHandler = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Mesh.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
Mesh::Mesh()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mesh::GetMeshData(MObject object)
|
||||||
|
{
|
||||||
|
// In here, we retrieve triangulated polygons from the mesh
|
||||||
|
MFnMesh mesh(object);
|
||||||
|
|
||||||
|
map<UINT, vector<UINT>> vertexToIndex;
|
||||||
|
|
||||||
|
vector<VertexLayout> verticesData;
|
||||||
|
vector<UINT>indexArray;
|
||||||
|
|
||||||
|
MIntArray intdexOffsetVertexCount, vertices, triangleList;
|
||||||
|
MPointArray dummy;
|
||||||
|
|
||||||
|
UINT vertexIndex;
|
||||||
|
MVector normal;
|
||||||
|
MPoint pos;
|
||||||
|
float2 UV;
|
||||||
|
VertexLayout thisVertex;
|
||||||
|
|
||||||
|
for (MItMeshPolygon meshPolyIter(object); !meshPolyIter.isDone(); meshPolyIter.next()) {
|
||||||
|
vector<UINT> localVertexToGlobalIndex;
|
||||||
|
meshPolyIter.getVertices(vertices);
|
||||||
|
|
||||||
|
meshPolyIter.getTriangles(dummy, triangleList);
|
||||||
|
UINT indexOffset = verticesData.size();
|
||||||
|
|
||||||
|
for (UINT i = 0; i < vertices.length(); i++) {
|
||||||
|
vertexIndex = meshPolyIter.vertexIndex(i);
|
||||||
|
pos = meshPolyIter.point(i);
|
||||||
|
pos.get(thisVertex.Pos);
|
||||||
|
|
||||||
|
meshPolyIter.getNormal(i, normal);
|
||||||
|
thisVertex.Normal[0] = normal[0];
|
||||||
|
thisVertex.Normal[1] = normal[1];
|
||||||
|
thisVertex.Normal[2] = normal[2];
|
||||||
|
|
||||||
|
meshPolyIter.getUV(i, UV);
|
||||||
|
thisVertex.Uv[0] = UV[0];
|
||||||
|
thisVertex.Uv[1] = UV[1];
|
||||||
|
|
||||||
|
verticesData.push_back(thisVertex);
|
||||||
|
localVertexToGlobalIndex.push_back(vertexIndex);
|
||||||
|
|
||||||
|
cout << "Pos: " << thisVertex.Pos[0] << "/" << thisVertex.Pos[1] << "/" << thisVertex.Pos[2] << endl;
|
||||||
|
cout << "Normals: " << thisVertex.Normal[0] << "/" << thisVertex.Normal[1] << "/" << thisVertex.Normal[2] << endl;
|
||||||
|
cout << "UV: " << thisVertex.Uv[0] << "/" << thisVertex.Uv[1] << endl;
|
||||||
|
}
|
||||||
|
for (UINT i = 0; i < triangleList.length(); i++) {
|
||||||
|
UINT k = 0;
|
||||||
|
while (localVertexToGlobalIndex[k] != triangleList[i])
|
||||||
|
k++;
|
||||||
|
indexArray.push_back(indexOffset + k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Mesh::~Mesh()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef Mesh_Mesh_h__
|
||||||
|
#define Mesh_Mesh_h__
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "MayaIncludes.h"
|
||||||
|
|
||||||
|
struct VertexLayout
|
||||||
|
{
|
||||||
|
float Pos[3];
|
||||||
|
float Normal[3];
|
||||||
|
float Uv[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
class Mesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Mesh();
|
||||||
|
void GetMeshData(MObject Object);
|
||||||
|
~Mesh();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user