You can now add/remove animation clips.
This commit is contained in:
@@ -17,6 +17,8 @@ Menu::Menu(QDialog* dialog)
|
|||||||
m_BrowseButton = new QPushButton("&...", this);
|
m_BrowseButton = new QPushButton("&...", this);
|
||||||
m_ExportAllButton = new QPushButton("&Export All", this);
|
m_ExportAllButton = new QPushButton("&Export All", this);
|
||||||
m_CancelButton = new QPushButton("&Cancel", 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
|
// Option box and checkboxes
|
||||||
QGroupBox *optionsBox = new QGroupBox(tr("Options"));
|
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_BrowseButton, SIGNAL(clicked(bool)), this, SLOT(ExportPathClicked(bool)));
|
||||||
connect(m_ExportAllButton, SIGNAL(clicked(bool)), this, SLOT(ExportAll(bool)));
|
connect(m_ExportAllButton, SIGNAL(clicked(bool)), this, SLOT(ExportAll(bool)));
|
||||||
connect(m_CancelButton, SIGNAL(clicked(bool)), this, SLOT(CancelClicked(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_ExportAnimationsButton, SIGNAL(clicked(bool)), this, SLOT(Button1Clicked(bool)));
|
||||||
connect(m_CopyTexturesButton, SIGNAL(clicked(bool)), this, SLOT(Button2Clicked(bool)));
|
connect(m_CopyTexturesButton, SIGNAL(clicked(bool)), this, SLOT(Button2Clicked(bool)));
|
||||||
@@ -49,12 +53,25 @@ Menu::Menu(QDialog* dialog)
|
|||||||
QVBoxLayout* midLayout = new QVBoxLayout;
|
QVBoxLayout* midLayout = new QVBoxLayout;
|
||||||
QHBoxLayout* botLayout = new QHBoxLayout;
|
QHBoxLayout* botLayout = new QHBoxLayout;
|
||||||
QVBoxLayout* baseLayout = new QVBoxLayout;
|
QVBoxLayout* baseLayout = new QVBoxLayout;
|
||||||
|
QHBoxLayout* clipButtonLayout = new QHBoxLayout;
|
||||||
|
QHBoxLayout* startEndLabelLayout = new QHBoxLayout;
|
||||||
|
m_ClipLayout = new QVBoxLayout;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_ExportPath = new QLineEdit;
|
m_ExportPath = new QLineEdit;
|
||||||
m_FileDialog = new QFileDialog;
|
m_FileDialog = new QFileDialog;
|
||||||
|
|
||||||
QLabel* exportLabel = new QLabel;
|
QLabel* exportLabel = new QLabel;
|
||||||
exportLabel->setText("Export Path:");
|
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);
|
midLayout->addWidget(optionsBox);
|
||||||
|
|
||||||
@@ -66,19 +83,35 @@ Menu::Menu(QDialog* dialog)
|
|||||||
botLayout->addWidget(m_ExportAllButton);
|
botLayout->addWidget(m_ExportAllButton);
|
||||||
botLayout->addWidget(m_CancelButton);
|
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(topLayout);
|
||||||
baseLayout->addLayout(midLayout);
|
baseLayout->addLayout(midLayout);
|
||||||
|
|
||||||
baseLayout->addSpacing(10);
|
baseLayout->addSpacing(10);
|
||||||
|
|
||||||
baseLayout->addLayout(botLayout);
|
baseLayout->addLayout(botLayout);
|
||||||
|
|
||||||
|
baseLayout->addSpacing(10);
|
||||||
|
baseLayout->addLayout(clipButtonLayout);
|
||||||
|
baseLayout->addLayout(startEndLabelLayout);
|
||||||
|
baseLayout->addLayout(m_ClipLayout);
|
||||||
baseLayout->addStretch();
|
baseLayout->addStretch();
|
||||||
|
|
||||||
// Set the layout for our window
|
// Set the layout for our window
|
||||||
dialog->setLayout(baseLayout);
|
dialog->setLayout(baseLayout);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < 3; i++) {
|
||||||
|
this->AddClipClicked(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Menu::ExportSelected(bool checked)
|
void Menu::ExportSelected(bool checked)
|
||||||
{
|
{
|
||||||
// Retrieving the objects we currently have selected
|
// Retrieving the objects we currently have selected
|
||||||
@@ -101,6 +134,11 @@ void Menu::ExportSelected(bool checked)
|
|||||||
else {
|
else {
|
||||||
cout << m_ExportPath->text().toLocal8Bit().constData() << endl;
|
cout << m_ExportPath->text().toLocal8Bit().constData() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_ExportAnimationsButton->isChecked()) {
|
||||||
|
GetSkeletonData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::ExportPathClicked(bool)
|
void Menu::ExportPathClicked(bool)
|
||||||
@@ -112,6 +150,48 @@ void Menu::ExportPathClicked(bool)
|
|||||||
m_ExportPath->setText(fileName);
|
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)
|
void Menu::ExportAll(bool)
|
||||||
{
|
{
|
||||||
MDagPath path;
|
MDagPath path;
|
||||||
@@ -134,6 +214,9 @@ void Menu::ExportAll(bool)
|
|||||||
else {
|
else {
|
||||||
cout << m_ExportPath->text().toLocal8Bit().constData() << endl;
|
cout << m_ExportPath->text().toLocal8Bit().constData() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_ExportAnimationsButton->isChecked())
|
||||||
|
GetSkeletonData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::CancelClicked(bool)
|
void Menu::CancelClicked(bool)
|
||||||
@@ -145,7 +228,6 @@ 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!");
|
||||||
@@ -186,31 +268,46 @@ void Menu::GetMaterialData()
|
|||||||
|
|
||||||
void Menu::GetSkeletonData()
|
void Menu::GetSkeletonData()
|
||||||
{
|
{
|
||||||
this->m_SkeletonHandler = new Skeleton();
|
if (MAnimControl::currentTime().unit() != MTime::kNTSCField) {
|
||||||
MTime startFrame = MAnimControl::animationStartTime();
|
|
||||||
MTime endFrame = MAnimControl::animationEndTime();
|
|
||||||
|
|
||||||
|
MGlobal::displayError(MString() + "Please change to 60 FPS under Preferences/Settings!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_SkeletonHandler = new Skeleton();
|
||||||
std::vector<std::vector<SkeletonNode>*> AllSkeletons;
|
std::vector<std::vector<SkeletonNode>*> AllSkeletons;
|
||||||
|
|
||||||
for (int i = startFrame.value(); i < endFrame.value();i++)
|
for (unsigned int j = 0; j < m_StartFrameLines.size(); j++) {
|
||||||
{
|
if (m_StartFrameLines[j]->text().isEmpty() == true || m_StartFrameLines[j]->text().isEmpty() == true) {
|
||||||
MAnimControl::setCurrentTime(MTime(i, MTime::kNTSCField));
|
MGlobal::displayError(MString() + "Empty Animation Clip(s)");
|
||||||
// Traverse scene and return vector with all materials
|
return;
|
||||||
AllSkeletons.push_back(m_SkeletonHandler->DoIt());
|
|
||||||
}
|
|
||||||
|
|
||||||
MGlobal::displayInfo(MString() + AllSkeletons.size());
|
|
||||||
|
|
||||||
for (int i = 0; i < AllSkeletons.size(); i++)
|
|
||||||
{
|
|
||||||
std::vector<SkeletonNode>*& 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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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<SkeletonNode>*& 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 exportPath;
|
||||||
//delete fileDialog;
|
//delete fileDialog;
|
||||||
m_FileDialog->~QFileDialog();
|
m_FileDialog->~QFileDialog();
|
||||||
|
|
||||||
//delete MaterialHandler;
|
//delete MaterialHandler;
|
||||||
}
|
}
|
||||||
@@ -29,6 +29,9 @@
|
|||||||
#include <QtGui/qfiledialog.h>
|
#include <QtGui/qfiledialog.h>
|
||||||
#include <QtGui/qlineedit.h>
|
#include <QtGui/qlineedit.h>
|
||||||
#include <QtGui/qgroupbox.h>
|
#include <QtGui/qgroupbox.h>
|
||||||
|
#include <QtGui/qlayoutitem.h>
|
||||||
|
#include <QtGui/qtabwidget.h>
|
||||||
|
|
||||||
|
|
||||||
#include "MayaIncludes.h"
|
#include "MayaIncludes.h"
|
||||||
#include "Material.h"
|
#include "Material.h"
|
||||||
@@ -48,6 +51,8 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void ExportSelected(bool checked);
|
void ExportSelected(bool checked);
|
||||||
void ExportPathClicked(bool);
|
void ExportPathClicked(bool);
|
||||||
|
void AddClipClicked(bool);
|
||||||
|
void RemoveClipClicked(bool);
|
||||||
void ExportAll(bool);
|
void ExportAll(bool);
|
||||||
void CancelClicked(bool);
|
void CancelClicked(bool);
|
||||||
|
|
||||||
@@ -58,10 +63,18 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Menu();
|
Menu();
|
||||||
|
std::vector<QLineEdit*> m_AnimationClipName;
|
||||||
|
std:: vector<QLineEdit*> m_StartFrameLines;
|
||||||
|
std::vector<QLineEdit*> m_EndFrameLines;
|
||||||
|
std::vector<QHBoxLayout*> layouts;
|
||||||
|
QVBoxLayout* m_ClipLayout;
|
||||||
|
|
||||||
QPushButton* m_ExportSelectedButton = nullptr;
|
QPushButton* m_ExportSelectedButton = nullptr;
|
||||||
QPushButton* m_BrowseButton = nullptr;
|
QPushButton* m_BrowseButton = nullptr;
|
||||||
QPushButton* m_ExportAllButton = nullptr;
|
QPushButton* m_ExportAllButton = nullptr;
|
||||||
QPushButton* m_CancelButton = nullptr;
|
QPushButton* m_CancelButton = nullptr;
|
||||||
|
QPushButton* m_AddClipsButton = nullptr;
|
||||||
|
QPushButton* m_RemoveClipsButton = nullptr;
|
||||||
|
|
||||||
QCheckBox* m_ExportAnimationsButton = nullptr;
|
QCheckBox* m_ExportAnimationsButton = nullptr;
|
||||||
QCheckBox* m_CopyTexturesButton = nullptr;
|
QCheckBox* m_CopyTexturesButton = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user