Made requested changed to Oven CLI

This commit is contained in:
seefo 2017-06-06 16:13:18 -07:00
parent 46400f4122
commit a3d2fa2630
3 changed files with 20 additions and 10 deletions

View file

@ -9,16 +9,20 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <QObject>
#include <QImageReader> #include <QImageReader>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include "ModelBakingLoggingCategory.h"
#include "ModelBakingLoggingCategory.h"
#include "Oven.h" #include "Oven.h"
#include "BakerCLI.h" #include "BakerCLI.h"
#include "FBXBaker.h" #include "FBXBaker.h"
#include "TextureBaker.h" #include "TextureBaker.h"
void BakerCLI::bakeFile(const QString inputFilename, const QString outputFilename) { BakerCLI::BakerCLI(Oven* parent) : QObject() {
}
void BakerCLI::bakeFile(const QString inputFilename, const QString outputPath) {
QUrl inputUrl(inputFilename); QUrl inputUrl(inputFilename);
// if the URL doesn't have a scheme, assume it is a local file // if the URL doesn't have a scheme, assume it is a local file
@ -40,12 +44,12 @@ void BakerCLI::bakeFile(const QString inputFilename, const QString outputFilenam
Baker* baker; Baker* baker;
if (isFBX) { if (isFBX) {
baker = new FBXBaker(inputUrl, outputFilename, []() -> QThread* { baker = new FBXBaker(inputUrl, outputPath, []() -> QThread* {
return qApp->getNextWorkerThread(); return qApp->getNextWorkerThread();
}); });
baker->moveToThread(qApp->getFBXBakerThread()); baker->moveToThread(qApp->getFBXBakerThread());
} else if (isSupportedImage) { } else if (isSupportedImage) {
baker = new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputFilename); baker = new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath);
baker->moveToThread(qApp->getNextWorkerThread()); baker->moveToThread(qApp->getNextWorkerThread());
} else { } else {
qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl; qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl;

View file

@ -14,11 +14,14 @@
#include <QtCore/QObject> #include <QtCore/QObject>
#include "Oven.h"
class BakerCLI : public QObject { class BakerCLI : public QObject {
Q_OBJECT Q_OBJECT
public: public:
void bakeFile(const QString inputFilename, const QString outputFilename); BakerCLI(Oven* parent);
void bakeFile(const QString inputFilename, const QString outputPath);
private slots: private slots:
void handleFinishedBaker(); void handleFinishedBaker();

View file

@ -22,6 +22,9 @@
static const QString OUTPUT_FOLDER = "/Users/birarda/code/hifi/lod/test-oven/export"; static const QString OUTPUT_FOLDER = "/Users/birarda/code/hifi/lod/test-oven/export";
static const QString CLI_INPUT_PARAMETER = "i";
static const QString CLI_OUTPUT_PARAMETER = "o";
Oven::Oven(int argc, char* argv[]) : Oven::Oven(int argc, char* argv[]) :
QApplication(argc, argv) QApplication(argc, argv)
{ {
@ -35,8 +38,8 @@ Oven::Oven(int argc, char* argv[]) :
QCommandLineParser parser; QCommandLineParser parser;
parser.addOptions({ parser.addOptions({
{ "i", "Path to file that you would like to bake.", "input" }, { CLI_INPUT_PARAMETER, "Path to file that you would like to bake.", "input" },
{ "o", "Path to folder that will be used as output.", "output" } { CLI_OUTPUT_PARAMETER, "Path to folder that will be used as output.", "output" }
}); });
parser.addHelpOption(); parser.addHelpOption();
parser.process(*this); parser.process(*this);
@ -55,9 +58,9 @@ Oven::Oven(int argc, char* argv[]) :
setupFBXBakerThread(); setupFBXBakerThread();
// check if we were passed any command line arguments that would tell us just to run without the GUI // check if we were passed any command line arguments that would tell us just to run without the GUI
if (parser.isSet("i") && parser.isSet("o")) { if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) {
BakerCLI* cli = new BakerCLI(); BakerCLI* cli = new BakerCLI(this);
cli->bakeFile(parser.value("i"), parser.value("o")); cli->bakeFile(parser.value(CLI_INPUT_PARAMETER), parser.value(CLI_OUTPUT_PARAMETER));
} else { } else {
// setup the GUI // setup the GUI
_mainWindow = new OvenMainWindow; _mainWindow = new OvenMainWindow;