mirror of
https://github.com/TheGameratorT/NitroModel_ConverterGUI.git
synced 2025-06-19 06:05:40 -04:00
Add textures to NSBTX support and update a bunch of stuff.
This commit is contained in:
parent
d96a093486
commit
4efa211c39
@ -32,18 +32,21 @@ SOURCES += \
|
||||
mainwindow.cpp \
|
||||
modeltonsbmd.cpp \
|
||||
texturednsbmdtonsbtx.cpp \
|
||||
textureentry.cpp \
|
||||
texturetonsbtx.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
modeltonsbmd.h \
|
||||
texturednsbmdtonsbtx.h \
|
||||
textureentry.h \
|
||||
texturetonsbtx.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
modeltonsbmd.ui \
|
||||
texturednsbmdtonsbtx.ui \
|
||||
textureentry.ui \
|
||||
texturetonsbtx.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
|
@ -15,9 +15,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui->ModelToNSBMD_mdiArea->addSubWindow(ModelToNSBMD_Window, Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
ModelToNSBMD_Window->showMaximized();
|
||||
|
||||
/*TextureToNSBTX *TextureToNSBTX_Window = new TextureToNSBTX;
|
||||
TextureToNSBTX *TextureToNSBTX_Window = new TextureToNSBTX;
|
||||
ui->TextureToNSBTX_mdiArea->addSubWindow(TextureToNSBTX_Window, Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
TextureToNSBTX_Window->showMaximized();*/
|
||||
TextureToNSBTX_Window->showMaximized();
|
||||
|
||||
TexturedNSBMDToNSBTX *TexturedNSBMDToNSBTX_Window = new TexturedNSBMDToNSBTX;
|
||||
ui->TexturedNSBMDToNSBTX_mdiArea->addSubWindow(TexturedNSBMDToNSBTX_Window, Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
|
@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>430</height>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>470</width>
|
||||
<height>430</height>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -24,7 +24,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@ -38,7 +38,7 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Texture to NSBTX</string>
|
||||
<string>Textures to NSBTX</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
|
@ -55,6 +55,8 @@ void ModelToNSBMD::printToConsole(const QString &text)
|
||||
ui->console_tb->setTextColor(QColor("yellow"));
|
||||
|
||||
ui->console_tb->append(text);
|
||||
|
||||
QApplication::processEvents(); //Force UI update
|
||||
}
|
||||
|
||||
void ModelToNSBMD::printAppOutputToConsole(QProcess* process)
|
||||
@ -63,13 +65,9 @@ void ModelToNSBMD::printAppOutputToConsole(QProcess* process)
|
||||
do
|
||||
{
|
||||
line = process->readLine();
|
||||
if (line.toLower().contains("error:") || line.toLower().contains("warning:")) {
|
||||
if(!(line.endsWith('.') or line.endsWith('!'))) {
|
||||
printToConsole(line.trimmed() + '!');
|
||||
}
|
||||
else {
|
||||
printToConsole(line.trimmed());
|
||||
}
|
||||
if (line.toLower().contains("error:") || line.toLower().contains("warning:"))
|
||||
{
|
||||
printToConsole(line.trimmed());
|
||||
}
|
||||
}
|
||||
while (!line.isNull());
|
||||
@ -82,18 +80,11 @@ void ModelToNSBMD::on_convert_pb_clicked()
|
||||
QString sourcePath = ui->path1_le->text();
|
||||
QString destinationPath = ui->path2_le->text();
|
||||
|
||||
bool AtLeast1PathWasNotSpecified = false;
|
||||
if(sourcePath == "")
|
||||
{
|
||||
AtLeast1PathWasNotSpecified = true;
|
||||
printToConsole("Error: No source model file was specified!");
|
||||
}
|
||||
if(destinationPath == "")
|
||||
{
|
||||
AtLeast1PathWasNotSpecified = true;
|
||||
printToConsole("Error: No destination NSBMD path was specified!");
|
||||
}
|
||||
if(AtLeast1PathWasNotSpecified)
|
||||
if(sourcePath == "" || destinationPath == "")
|
||||
return;
|
||||
|
||||
bool IsSourceFileIMD = false;
|
||||
@ -122,6 +113,8 @@ void ModelToNSBMD::on_convert_pb_clicked()
|
||||
}
|
||||
connect(ass2imd, &QProcess::readyRead, [=](){ printAppOutputToConsole(ass2imd); });
|
||||
ass2imd->waitForFinished(-1);
|
||||
delete ass2imd;
|
||||
ass2imd = nullptr;
|
||||
|
||||
if(QFile::exists(tempDir.path() + "/temp.imd"))
|
||||
printToConsole("Success: IMD generated successfully!");
|
||||
@ -139,16 +132,18 @@ void ModelToNSBMD::on_convert_pb_clicked()
|
||||
printToConsole("Starting conversion to NSBMD...");
|
||||
|
||||
QProcess* imd2nsbmd = new QProcess();
|
||||
imd2nsbmd->setProgram(exeDir + "/bin/imd2nsbmd/imd2nsbmd");
|
||||
imd2nsbmd->setProgram(exeDir + "/bin/imd2bin/imd2bin");
|
||||
imd2nsbmd->setArguments({sourcePath2, "-o", destinationPath});
|
||||
imd2nsbmd->start();
|
||||
if(imd2nsbmd->state() == QProcess::NotRunning)
|
||||
{
|
||||
printToConsole("Error: imd2nsbmd failed to start or could not be found!");
|
||||
printToConsole("Error: imd2bin failed to start or could not be found!");
|
||||
return;
|
||||
}
|
||||
connect(imd2nsbmd, &QProcess::readyRead, [=](){ printAppOutputToConsole(imd2nsbmd); });
|
||||
imd2nsbmd->waitForFinished(-1);
|
||||
delete imd2nsbmd;
|
||||
imd2nsbmd = nullptr;
|
||||
|
||||
if(QFile::exists(destinationPath))
|
||||
{
|
||||
|
@ -52,6 +52,8 @@ void TexturedNSBMDToNSBTX::printToConsole(const QString &text)
|
||||
ui->console_tb->setTextColor(QColor("yellow"));
|
||||
|
||||
ui->console_tb->append(text);
|
||||
|
||||
QApplication::processEvents(); //Force UI update
|
||||
}
|
||||
|
||||
void TexturedNSBMDToNSBTX::on_convert_pb_clicked()
|
||||
|
67
textureentry.cpp
Normal file
67
textureentry.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
#include "textureentry.h"
|
||||
#include "ui_textureentry.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
TextureEntry::TextureEntry(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::TextureEntry)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
TextureEntry::~TextureEntry()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TextureEntry::SetID(int ID) { ui->id_le->setText(QString::number(ID)); }
|
||||
QString TextureEntry::GetName() { return ui->name_le->text(); }
|
||||
QString TextureEntry::GetPath() { return ui->path_le->text(); }
|
||||
QFileInfo TextureEntry::GetFileInfo()
|
||||
{
|
||||
QFileInfo fileInfo(ui->path_le->text());
|
||||
return fileInfo;
|
||||
}
|
||||
QString TextureEntry::GetNewFileNameWithExtension()
|
||||
{
|
||||
if(ui->name_le->text() == "")
|
||||
ui->name_le->setText(GetFileInfo().completeBaseName());
|
||||
return ui->name_le->text() + "." + GetFileInfo().suffix();
|
||||
}
|
||||
|
||||
void TextureEntry::on_search_pb_clicked()
|
||||
{
|
||||
static QString lastDirSelected = QDir::homePath();
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Texture File"), lastDirSelected, tr("Image Files (*.png *.tga);;"
|
||||
"PNG Files (*.png);;"
|
||||
"Nitro TGA Files (*.tga)"));
|
||||
if(fileName == "")
|
||||
return;
|
||||
lastDirSelected = fileName;
|
||||
ui->path_le->setText(fileName);
|
||||
ui->name_le->setText(GetFileInfo().completeBaseName());
|
||||
}
|
||||
|
||||
void TextureEntry::on_name_le_textChanged()
|
||||
{
|
||||
QLineEdit* sender = qobject_cast<QLineEdit*>(QObject::sender());
|
||||
|
||||
int cursorPos = sender->cursorPosition();
|
||||
QString newText;
|
||||
|
||||
for(QChar character : sender->text())
|
||||
{
|
||||
if(!((character >= 'A' && character <= 'Z') ||
|
||||
(character >= 'a' && character <= 'z') ||
|
||||
(character >= '0' && character <= '9')))
|
||||
{
|
||||
character = '_';
|
||||
}
|
||||
newText.append(character);
|
||||
}
|
||||
|
||||
sender->setText(newText);
|
||||
sender->setCursorPosition(cursorPos);
|
||||
}
|
34
textureentry.h
Normal file
34
textureentry.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef TEXTUREENTRY_H
|
||||
#define TEXTUREENTRY_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace Ui {
|
||||
class TextureEntry;
|
||||
}
|
||||
|
||||
class TextureEntry : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TextureEntry(QWidget *parent = nullptr);
|
||||
~TextureEntry();
|
||||
|
||||
void SetID(int ID);
|
||||
QString GetName();
|
||||
QString GetPath();
|
||||
QFileInfo GetFileInfo();
|
||||
QString GetNewFileNameWithExtension();
|
||||
|
||||
private slots:
|
||||
void on_search_pb_clicked();
|
||||
|
||||
void on_name_le_textChanged();
|
||||
|
||||
private:
|
||||
Ui::TextureEntry *ui;
|
||||
};
|
||||
|
||||
#endif // TEXTUREENTRY_H
|
108
textureentry.ui
Normal file
108
textureentry.ui
Normal file
@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TextureEntry</class>
|
||||
<widget class="QWidget" name="TextureEntry">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>464</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="id_le">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="name_label">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="name_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>13</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="path_label">
|
||||
<property name="text">
|
||||
<string>Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="path_le"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="search_pb">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,13 +1,43 @@
|
||||
#include "texturetonsbtx.h"
|
||||
#include "ui_texturetonsbtx.h"
|
||||
|
||||
#include "textureentry.h"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QFileDialog>
|
||||
|
||||
static QString exeDir;
|
||||
static QVector<TextureEntry*> texEntries;
|
||||
|
||||
TextureToNSBTX::TextureToNSBTX(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::TextureToNSBTX)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
exeDir = QApplication::applicationDirPath();
|
||||
|
||||
QVBoxLayout* scrollarea_layout = new QVBoxLayout();
|
||||
scrollarea_layout->setMargin(0);
|
||||
scrollarea_layout->setSpacing(0);
|
||||
|
||||
TextureEntry* texEntry = new TextureEntry();
|
||||
texEntries.append(texEntry);
|
||||
|
||||
scrollarea_layout->addWidget(texEntry);
|
||||
ui->textures_sa_widget->setLayout(scrollarea_layout);
|
||||
}
|
||||
|
||||
void TextureToNSBTX::on_selectNsbtxPath_pb_clicked()
|
||||
{
|
||||
static QString lastDirSelected = QDir::homePath();
|
||||
if(lastDirSelected == QDir::homePath() && ui->nsbtxPath_le->text() != "")
|
||||
lastDirSelected = ui->nsbtxPath_le->text().split('.')[0];
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save NSBTX File"), lastDirSelected, tr("NSBTX File (*.nsbtx)"));
|
||||
if(fileName == "")
|
||||
return;
|
||||
lastDirSelected = fileName;
|
||||
ui->nsbtxPath_le->setText(fileName);
|
||||
}
|
||||
|
||||
TextureToNSBTX::~TextureToNSBTX()
|
||||
@ -15,28 +45,30 @@ TextureToNSBTX::~TextureToNSBTX()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TextureToNSBTX::on_searchPath1_pb_clicked()
|
||||
void TextureToNSBTX::on_addTexture_pb_clicked()
|
||||
{
|
||||
static QString lastDirSelected = QDir::homePath();
|
||||
TextureEntry* texEntry = new TextureEntry();
|
||||
texEntries.append(texEntry);
|
||||
texEntry->SetID(texEntries.size());
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Texture File"), lastDirSelected, ""/*tr("Model Files (*.png *.jpg *.bmp)")*/);
|
||||
if(fileName == "")
|
||||
return;
|
||||
lastDirSelected = fileName;
|
||||
ui->path1_le->setText(fileName);
|
||||
ui->textures_sa_widget->layout()->addWidget(texEntry);
|
||||
}
|
||||
|
||||
void TextureToNSBTX::on_seachPath2_pb_clicked()
|
||||
void TextureToNSBTX::on_removeTexture_pb_clicked()
|
||||
{
|
||||
static QString lastDirSelected = QDir::homePath();
|
||||
if(lastDirSelected == QDir::homePath() && ui->path1_le->text() != "")
|
||||
lastDirSelected = ui->path1_le->text().split('.')[0];
|
||||
TextureEntry* texEntry = texEntries.last();
|
||||
ui->textures_sa_widget->layout()->removeWidget(texEntry);
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save NSBTX File"), lastDirSelected, tr("NSBTX File (*.nsbtx)"));
|
||||
if(fileName == "")
|
||||
return;
|
||||
lastDirSelected = fileName;
|
||||
ui->path2_le->setText(fileName);
|
||||
delete texEntry;
|
||||
texEntry = nullptr;
|
||||
|
||||
texEntries.removeLast();
|
||||
|
||||
//If all got removed add 1 back
|
||||
if(texEntries.size() == 0)
|
||||
{
|
||||
on_addTexture_pb_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
//CONVERSION STUFF AHEAD
|
||||
@ -52,6 +84,8 @@ void TextureToNSBTX::printToConsole(const QString &text)
|
||||
ui->console_tb->setTextColor(QColor("yellow"));
|
||||
|
||||
ui->console_tb->append(text);
|
||||
|
||||
QApplication::processEvents(); //Force UI update
|
||||
}
|
||||
|
||||
void TextureToNSBTX::printAppOutputToConsole(QProcess* process)
|
||||
@ -60,21 +94,159 @@ void TextureToNSBTX::printAppOutputToConsole(QProcess* process)
|
||||
do
|
||||
{
|
||||
line = process->readLine();
|
||||
if (line.toLower().contains("error:") || line.toLower().contains("warning:")) {
|
||||
if(!(line.endsWith('.') or line.endsWith('!'))) {
|
||||
printToConsole(line.trimmed() + '!');
|
||||
}
|
||||
else {
|
||||
printToConsole(line.trimmed());
|
||||
}
|
||||
if (line.toLower().contains("error:") || line.toLower().contains("warning:"))
|
||||
{
|
||||
printToConsole(line.trimmed());
|
||||
}
|
||||
}
|
||||
while (!line.isNull());
|
||||
}
|
||||
|
||||
void TextureToNSBTX::WriteOBJFile(QFile* file)
|
||||
{
|
||||
QTextStream stream(file);
|
||||
|
||||
stream << R"(mtllib temp.mtl
|
||||
o MaterialArray
|
||||
v -1.000000 0.000000 1.000000
|
||||
v 1.000000 0.000000 1.000000
|
||||
v -1.000000 0.000000 -1.000000
|
||||
v 1.000000 0.000000 -1.000000
|
||||
vt 0.000000 0.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 1.000000 1.000000
|
||||
vt 0.000000 1.000000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
)";
|
||||
|
||||
for(int i = 0; i < texEntries.size(); i++)
|
||||
{
|
||||
stream << "usemtl Material" << i+1 << "\n";
|
||||
stream << "f 1/1/1 2/2/1 4/3/1 3/4/1" << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void TextureToNSBTX::WriteMTLFile(QFile* file)
|
||||
{
|
||||
QTextStream stream(file);
|
||||
|
||||
QDir tempDir(exeDir + "/temp");
|
||||
for(int i = 0; i < texEntries.size(); i++)
|
||||
{
|
||||
QString tempTexPath = tempDir.path() + "/" + texEntries[i]->GetNewFileNameWithExtension();
|
||||
QFile::copy(texEntries[i]->GetPath(), tempTexPath);
|
||||
|
||||
stream << "newmtl Material" << i+1 << "\n";
|
||||
stream << "map_Kd " << tempTexPath << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void TextureToNSBTX::on_convert_pb_clicked()
|
||||
{
|
||||
ui->console_tb->clear();
|
||||
|
||||
QString destinationPath = ui->nsbtxPath_le->text();
|
||||
if(destinationPath == "")
|
||||
{
|
||||
printToConsole("Error: No destination NSBTX path was specified!");
|
||||
return;
|
||||
}
|
||||
|
||||
// CHECK ALL PATHS -----------------------------------------------------------
|
||||
|
||||
for(int i = 0; i < texEntries.size(); i++)
|
||||
{
|
||||
if(texEntries[i]->GetPath() == "")
|
||||
{
|
||||
printToConsole("Error: At least one of the texture paths specified was empty!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TEMP CLEANUP --------------------------------------------------------------
|
||||
|
||||
QDir tempDir(exeDir + "/temp");
|
||||
printToConsole("Cleaning temp folder...");
|
||||
tempDir.removeRecursively(); //Remove temp folder
|
||||
while(tempDir.exists()) {} //Wait for temp folder to be deleted
|
||||
QDir().mkdir(tempDir.path()); //Add temp folder back but empty
|
||||
|
||||
// OBJ GENERATION ------------------------------------------------------------
|
||||
|
||||
printToConsole("Generating temporary OBJ file...");
|
||||
QFile tempObjFile(tempDir.path() + "/temp.obj");
|
||||
if(!tempObjFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return;
|
||||
WriteOBJFile(&tempObjFile);
|
||||
tempObjFile.close();
|
||||
|
||||
// MTL GENERATION ------------------------------------------------------------
|
||||
|
||||
printToConsole("Generating temporary MTL file...");
|
||||
QFile tempMtlFile(tempDir.path() + "/temp.mtl");
|
||||
if(!tempMtlFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return;
|
||||
WriteMTLFile(&tempMtlFile);
|
||||
tempMtlFile.close();
|
||||
|
||||
// IMD CONVERSION ------------------------------------------------------------
|
||||
|
||||
printToConsole("Starting conversion to IMD...");
|
||||
|
||||
QProcess* ass2imd = new QProcess();
|
||||
ass2imd->setProgram(exeDir + "/bin/ass2imd/AssToImd");
|
||||
ass2imd->setArguments({tempDir.path() + "/temp.obj", "-o", tempDir.path() + "/temp.imd"});
|
||||
ass2imd->start();
|
||||
if(ass2imd->state() == QProcess::NotRunning)
|
||||
{
|
||||
printToConsole("Error: AssToImd failed to start or could not be found!");
|
||||
return;
|
||||
}
|
||||
connect(ass2imd, &QProcess::readyRead, [=](){ printAppOutputToConsole(ass2imd); });
|
||||
ass2imd->waitForFinished(-1);
|
||||
delete ass2imd;
|
||||
ass2imd = nullptr;
|
||||
|
||||
if(QFile::exists(tempDir.path() + "/temp.imd"))
|
||||
printToConsole("Success: IMD generated successfully!");
|
||||
else
|
||||
{
|
||||
printToConsole("Error: IMD failed to generate!");
|
||||
return;
|
||||
}
|
||||
|
||||
// NSBTX CONVERSION ----------------------------------------------------------
|
||||
|
||||
printToConsole("Starting conversion to NSBTX...");
|
||||
|
||||
if(QFile::exists(destinationPath))
|
||||
{
|
||||
printToConsole("Deleting existing destination NSBTX...");
|
||||
QFile::remove(destinationPath);
|
||||
}
|
||||
while(QFile::exists(destinationPath)) {} //Wait for removal
|
||||
|
||||
QProcess* imd2nsbmd = new QProcess();
|
||||
imd2nsbmd->setProgram(exeDir + "/bin/imd2bin/imd2bin");
|
||||
imd2nsbmd->setArguments({tempDir.path() + "/temp.imd", "-etex", "-o", destinationPath});
|
||||
imd2nsbmd->start();
|
||||
if(imd2nsbmd->state() == QProcess::NotRunning)
|
||||
{
|
||||
printToConsole("Error: imd2bin failed to start or could not be found!");
|
||||
return;
|
||||
}
|
||||
connect(imd2nsbmd, &QProcess::readyRead, [=](){ printAppOutputToConsole(imd2nsbmd); });
|
||||
imd2nsbmd->waitForFinished(-1);
|
||||
delete imd2nsbmd;
|
||||
imd2nsbmd = nullptr;
|
||||
|
||||
if(QFile::exists(destinationPath))
|
||||
{
|
||||
printToConsole("Success: NSBTX generated successfully!");
|
||||
}
|
||||
else
|
||||
{
|
||||
printToConsole("Error: NSBTX failed to generate!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QProcess>
|
||||
#include <QFile>
|
||||
|
||||
namespace Ui {
|
||||
class TextureToNSBTX;
|
||||
@ -17,9 +18,11 @@ public:
|
||||
~TextureToNSBTX();
|
||||
|
||||
private slots:
|
||||
void on_searchPath1_pb_clicked();
|
||||
void on_addTexture_pb_clicked();
|
||||
|
||||
void on_seachPath2_pb_clicked();
|
||||
void on_removeTexture_pb_clicked();
|
||||
|
||||
void on_selectNsbtxPath_pb_clicked();
|
||||
|
||||
void on_convert_pb_clicked();
|
||||
|
||||
@ -28,6 +31,9 @@ private:
|
||||
|
||||
void printToConsole(const QString &text);
|
||||
void printAppOutputToConsole(QProcess* process);
|
||||
|
||||
void WriteOBJFile(QFile* file);
|
||||
void WriteMTLFile(QFile* file);
|
||||
};
|
||||
|
||||
#endif // TEXTURETONSBTX_H
|
||||
|
@ -21,133 +21,136 @@ background-color: rgb(255, 255, 255);
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>63</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>63</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="path1_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="scrollarea_verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QPushButton" name="addTexture_pb">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="text1_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">padding-top:-4px;
|
||||
color: rgb(0, 192, 0);
|
||||
font: 16pt "MS Shell Dlg 2";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Source Texture File:</string>
|
||||
<string>+</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="path2_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QPushButton" name="removeTexture_pb">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>0</y>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="text2_label">
|
||||
<property name="text">
|
||||
<string>Destination NSBTX File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="seachPath2_pb">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">padding-top:-4px;
|
||||
color: rgb(255, 0, 0);
|
||||
font: 16pt "MS Shell Dlg 2";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="searchPath1_pb">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="textures_sa">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="textures_sa_widget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>579</width>
|
||||
<height>85</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="console_tb">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(0, 0, 0);</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="convert_pb">
|
||||
<property name="text">
|
||||
<string>Convert And Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||
<layout class="QVBoxLayout" name="console_verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="nsbtxPath_le"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="selectNsbtxPath_pb">
|
||||
<property name="text">
|
||||
<string>Select</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Destination NSBTX File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="console_tb">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(0, 0, 0);</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="convert_pb">
|
||||
<property name="text">
|
||||
<string>Convert And Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>path1_le</tabstop>
|
||||
<tabstop>searchPath1_pb</tabstop>
|
||||
<tabstop>path2_le</tabstop>
|
||||
<tabstop>seachPath2_pb</tabstop>
|
||||
<tabstop>console_tb</tabstop>
|
||||
<tabstop>convert_pb</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user