diff --git a/tools/MayaExporter/MayaExporter/Menu.cpp b/tools/MayaExporter/MayaExporter/Menu.cpp index 06c115c8..591c15fa 100644 --- a/tools/MayaExporter/MayaExporter/Menu.cpp +++ b/tools/MayaExporter/MayaExporter/Menu.cpp @@ -17,6 +17,8 @@ Menu::Menu(QDialog* dialog) m_BrowseButton = new QPushButton("&...", this); m_ExportAllButton = new QPushButton("&Export All", this); m_CancelButton = new QPushButton("&Cancel", this); + m_AddClipsButton = new QPushButton("&Add Clips", this); + m_RemoveClipsButton = new QPushButton("&Remove Latest Clip", this); // Option box and checkboxes QGroupBox *optionsBox = new QGroupBox(tr("Options")); @@ -39,6 +41,8 @@ Menu::Menu(QDialog* dialog) connect(m_BrowseButton, SIGNAL(clicked(bool)), this, SLOT(ExportPathClicked(bool))); connect(m_ExportAllButton, SIGNAL(clicked(bool)), this, SLOT(ExportAll(bool))); connect(m_CancelButton, SIGNAL(clicked(bool)), this, SLOT(CancelClicked(bool))); + connect(m_AddClipsButton, SIGNAL(clicked(bool)), this, SLOT(AddClipClicked(bool))); + connect(m_RemoveClipsButton, SIGNAL(clicked(bool)), this, SLOT(RemoveClipClicked(bool))); connect(m_ExportAnimationsButton, SIGNAL(clicked(bool)), this, SLOT(Button1Clicked(bool))); connect(m_CopyTexturesButton, SIGNAL(clicked(bool)), this, SLOT(Button2Clicked(bool))); @@ -49,12 +53,25 @@ Menu::Menu(QDialog* dialog) QVBoxLayout* midLayout = new QVBoxLayout; QHBoxLayout* botLayout = new QHBoxLayout; QVBoxLayout* baseLayout = new QVBoxLayout; + QHBoxLayout* clipButtonLayout = new QHBoxLayout; + QHBoxLayout* startEndLabelLayout = new QHBoxLayout; + m_ClipLayout = new QVBoxLayout; + + m_ExportPath = new QLineEdit; m_FileDialog = new QFileDialog; QLabel* exportLabel = new QLabel; exportLabel->setText("Export Path:"); + QLabel* nameLabel = new QLabel; + nameLabel->setText("Name:"); + QLabel* startLabel = new QLabel; + startLabel->setText("Start:"); + QLabel* endLabel = new QLabel; + endLabel->setText("End:"); + + //exportLabel->setText("Export Path:"); midLayout->addWidget(optionsBox); @@ -66,19 +83,35 @@ Menu::Menu(QDialog* dialog) botLayout->addWidget(m_ExportAllButton); botLayout->addWidget(m_CancelButton); + startEndLabelLayout->addWidget(nameLabel); + startEndLabelLayout->addWidget(startLabel); + startEndLabelLayout->addWidget(endLabel); + + clipButtonLayout->addWidget(m_AddClipsButton); + clipButtonLayout->addWidget(m_RemoveClipsButton); + baseLayout->addLayout(topLayout); baseLayout->addLayout(midLayout); baseLayout->addSpacing(10); - baseLayout->addLayout(botLayout); + + baseLayout->addSpacing(10); + baseLayout->addLayout(clipButtonLayout); + baseLayout->addLayout(startEndLabelLayout); + baseLayout->addLayout(m_ClipLayout); baseLayout->addStretch(); // Set the layout for our window dialog->setLayout(baseLayout); + for (unsigned int i = 0; i < 3; i++) { + this->AddClipClicked(true); + } + } + void Menu::ExportSelected(bool checked) { // Retrieving the objects we currently have selected @@ -101,6 +134,11 @@ void Menu::ExportSelected(bool checked) else { cout << m_ExportPath->text().toLocal8Bit().constData() << endl; } + + if (m_ExportAnimationsButton->isChecked()) { + GetSkeletonData(); + } + } void Menu::ExportPathClicked(bool) @@ -112,6 +150,48 @@ void Menu::ExportPathClicked(bool) m_ExportPath->setText(fileName); } +void Menu::AddClipClicked(bool) +{ + QHBoxLayout* tempLayout = new QHBoxLayout; + + QLineEdit* nameLineEdit = new QLineEdit; + QLineEdit* startLineEdit = new QLineEdit; + QLineEdit* endLineEdit = new QLineEdit; + + m_AnimationClipName.push_back(nameLineEdit); + m_StartFrameLines.push_back(startLineEdit); + m_EndFrameLines.push_back(endLineEdit); + + tempLayout->addWidget(nameLineEdit); + tempLayout->addWidget(startLineEdit); + tempLayout->addWidget(endLineEdit); + + m_ClipLayout->addLayout(tempLayout); + //m_ClipLayout->update(); + layouts.push_back(tempLayout); +} + +void Menu::RemoveClipClicked(bool) +{ + if (m_StartFrameLines.size() > 0) { + QLayoutItem* tempWidget;// = m_ClipLayout->itemAt(0); + + for (unsigned int i = 0; i < layouts.size(); i++) { + while ((tempWidget = layouts[layouts.size()-1]->takeAt(0)) != 0) { + delete tempWidget->widget(); + delete tempWidget; + } + } + + m_ClipLayout->removeItem(tempWidget); + m_ClipLayout->update(); + + layouts.pop_back(); + m_StartFrameLines.pop_back(); + m_EndFrameLines.pop_back(); + } +} + void Menu::ExportAll(bool) { MDagPath path; @@ -134,6 +214,9 @@ void Menu::ExportAll(bool) else { cout << m_ExportPath->text().toLocal8Bit().constData() << endl; } + + if(m_ExportAnimationsButton->isChecked()) + GetSkeletonData(); } void Menu::CancelClicked(bool) @@ -145,7 +228,6 @@ void Menu::Button1Clicked(bool) { if (m_ExportAnimationsButton->isChecked()) { MGlobal::displayInfo("1 checked!"); - this->GetSkeletonData(); } else { MGlobal::displayInfo("1 unchecked!"); @@ -186,31 +268,46 @@ void Menu::GetMaterialData() void Menu::GetSkeletonData() { - this->m_SkeletonHandler = new Skeleton(); - MTime startFrame = MAnimControl::animationStartTime(); - MTime endFrame = MAnimControl::animationEndTime(); + if (MAnimControl::currentTime().unit() != MTime::kNTSCField) { + MGlobal::displayError(MString() + "Please change to 60 FPS under Preferences/Settings!"); + return; + } + + this->m_SkeletonHandler = new Skeleton(); std::vector*> AllSkeletons; - for (int i = startFrame.value(); i < endFrame.value();i++) - { - MAnimControl::setCurrentTime(MTime(i, MTime::kNTSCField)); - // Traverse scene and return vector with all materials - AllSkeletons.push_back(m_SkeletonHandler->DoIt()); - } - - MGlobal::displayInfo(MString() + AllSkeletons.size()); - - for (int i = 0; i < AllSkeletons.size(); i++) - { - std::vector*& thisSkeleton = AllSkeletons.at(i); - for (int k = 0; k < thisSkeleton->size(); k++) - { - for (int j = 0; j < thisSkeleton->at(k).Joints.size(); j++) - { - MGlobal::displayInfo(MString() + thisSkeleton->at(k).Joints.at(j).Name.c_str()); - } + for (unsigned int j = 0; j < m_StartFrameLines.size(); j++) { + if (m_StartFrameLines[j]->text().isEmpty() == true || m_StartFrameLines[j]->text().isEmpty() == true) { + MGlobal::displayError(MString() + "Empty Animation Clip(s)"); + return; } + + int startFrame = m_StartFrameLines[j]->text().toInt(); + int endFrame = m_EndFrameLines[j]->text().toInt(); + + for (int i = startFrame; i < endFrame;++i) + { + MAnimControl::setCurrentTime(MTime(i, MTime::kNTSCField)); + MTime time = MAnimControl::currentTime(); + + // Traverse scene and return vector with all materials + AllSkeletons.push_back(m_SkeletonHandler->DoIt()); + } + + //MGlobal::displayInfo(MString() + AllSkeletons.size()); + + /*for (int i = 0; i < AllSkeletons.size(); i++) + { + std::vector*& thisSkeleton = AllSkeletons.at(i); + for (int k = 0; k < thisSkeleton->size(); k++) + { + for (int j = 0; j < thisSkeleton->at(k).Joints.size(); j++) + { + MGlobal::displayInfo(MString() + thisSkeleton->at(k).Joints.at(j).Name.c_str()); + } + } + }*/ } } @@ -221,5 +318,6 @@ Menu::~Menu() //delete exportPath; //delete fileDialog; m_FileDialog->~QFileDialog(); + //delete MaterialHandler; } \ No newline at end of file diff --git a/tools/MayaExporter/MayaExporter/Menu.h b/tools/MayaExporter/MayaExporter/Menu.h index a0fe93f6..81ec2834 100644 --- a/tools/MayaExporter/MayaExporter/Menu.h +++ b/tools/MayaExporter/MayaExporter/Menu.h @@ -29,6 +29,9 @@ #include #include #include +#include +#include + #include "MayaIncludes.h" #include "Material.h" @@ -48,6 +51,8 @@ public: private slots: void ExportSelected(bool checked); void ExportPathClicked(bool); + void AddClipClicked(bool); + void RemoveClipClicked(bool); void ExportAll(bool); void CancelClicked(bool); @@ -58,10 +63,18 @@ private slots: private: Menu(); + std::vector m_AnimationClipName; + std:: vector m_StartFrameLines; + std::vector m_EndFrameLines; + std::vector layouts; + QVBoxLayout* m_ClipLayout; + QPushButton* m_ExportSelectedButton = nullptr; QPushButton* m_BrowseButton = nullptr; QPushButton* m_ExportAllButton = nullptr; QPushButton* m_CancelButton = nullptr; + QPushButton* m_AddClipsButton = nullptr; + QPushButton* m_RemoveClipsButton = nullptr; QCheckBox* m_ExportAnimationsButton = nullptr; QCheckBox* m_CopyTexturesButton = nullptr;