From a3d2fa2630b713b31297e221284a1efe4184b90a Mon Sep 17 00:00:00 2001 From: seefo Date: Tue, 6 Jun 2017 16:13:18 -0700 Subject: [PATCH] Made requested changed to Oven CLI --- tools/oven/src/BakerCLI.cpp | 12 ++++++++---- tools/oven/src/BakerCLI.h | 5 ++++- tools/oven/src/Oven.cpp | 13 ++++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tools/oven/src/BakerCLI.cpp b/tools/oven/src/BakerCLI.cpp index 3a0d1eeef7..04d43853da 100644 --- a/tools/oven/src/BakerCLI.cpp +++ b/tools/oven/src/BakerCLI.cpp @@ -9,16 +9,20 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include #include -#include "ModelBakingLoggingCategory.h" +#include "ModelBakingLoggingCategory.h" #include "Oven.h" #include "BakerCLI.h" #include "FBXBaker.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); // 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; if (isFBX) { - baker = new FBXBaker(inputUrl, outputFilename, []() -> QThread* { + baker = new FBXBaker(inputUrl, outputPath, []() -> QThread* { return qApp->getNextWorkerThread(); }); baker->moveToThread(qApp->getFBXBakerThread()); } 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()); } else { qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl; diff --git a/tools/oven/src/BakerCLI.h b/tools/oven/src/BakerCLI.h index 7803aa6c86..88ea028b9f 100644 --- a/tools/oven/src/BakerCLI.h +++ b/tools/oven/src/BakerCLI.h @@ -14,11 +14,14 @@ #include +#include "Oven.h" + class BakerCLI : public QObject { Q_OBJECT public: - void bakeFile(const QString inputFilename, const QString outputFilename); + BakerCLI(Oven* parent); + void bakeFile(const QString inputFilename, const QString outputPath); private slots: void handleFinishedBaker(); diff --git a/tools/oven/src/Oven.cpp b/tools/oven/src/Oven.cpp index 3d356a5f1e..7431863ba5 100644 --- a/tools/oven/src/Oven.cpp +++ b/tools/oven/src/Oven.cpp @@ -22,6 +22,9 @@ 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[]) : QApplication(argc, argv) { @@ -35,8 +38,8 @@ Oven::Oven(int argc, char* argv[]) : QCommandLineParser parser; parser.addOptions({ - { "i", "Path to file that you would like to bake.", "input" }, - { "o", "Path to folder that will be used as output.", "output" } + { CLI_INPUT_PARAMETER, "Path to file that you would like to bake.", "input" }, + { CLI_OUTPUT_PARAMETER, "Path to folder that will be used as output.", "output" } }); parser.addHelpOption(); parser.process(*this); @@ -55,9 +58,9 @@ Oven::Oven(int argc, char* argv[]) : setupFBXBakerThread(); // 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")) { - BakerCLI* cli = new BakerCLI(); - cli->bakeFile(parser.value("i"), parser.value("o")); + if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) { + BakerCLI* cli = new BakerCLI(this); + cli->bakeFile(parser.value(CLI_INPUT_PARAMETER), parser.value(CLI_OUTPUT_PARAMETER)); } else { // setup the GUI _mainWindow = new OvenMainWindow;