mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-10 00:23:40 +02:00
add a simple UI to Oven to bake individual model
This commit is contained in:
parent
6519a9c45b
commit
8d3b854e69
7 changed files with 224 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
set(TARGET_NAME oven)
|
||||
|
||||
setup_hifi_project()
|
||||
setup_hifi_project(Widgets Gui)
|
||||
|
||||
link_hifi_libraries(model-baking)
|
||||
|
|
|
@ -9,15 +9,31 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include "ui/OvenMainWindow.h"
|
||||
#include "ui/ModelBakeWidget.h"
|
||||
|
||||
#include "Oven.h"
|
||||
|
||||
static const QString OUTPUT_FOLDER = "/Users/birarda/code/hifi/lod/test-oven/export";
|
||||
|
||||
Oven::Oven(int argc, char* argv[]) :
|
||||
QCoreApplication(argc, argv),
|
||||
_testBake(QUrl("file:///Users/birarda/code/hifi/lod/test-oven/Test-Object6.fbx"), OUTPUT_FOLDER)
|
||||
QApplication(argc, argv)
|
||||
{
|
||||
_testBake.start();
|
||||
QCoreApplication::setOrganizationName("High Fidelity");
|
||||
QCoreApplication::setApplicationName("Oven");
|
||||
|
||||
// check if we were passed any command line arguments that would tell us just to run without the GUI
|
||||
|
||||
// setup the GUI
|
||||
setupGUI();
|
||||
}
|
||||
|
||||
void Oven::setupGUI() {
|
||||
_mainWindow = new OvenMainWindow;
|
||||
|
||||
_mainWindow->setWindowTitle("High Fidelity Oven");
|
||||
|
||||
_mainWindow->setCentralWidget(new ModelBakeWidget);
|
||||
_mainWindow->show();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,18 +12,20 @@
|
|||
#ifndef hifi_Oven_h
|
||||
#define hifi_Oven_h
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
#include <FBXBaker.h>
|
||||
class OvenMainWindow;
|
||||
|
||||
class Oven : public QCoreApplication {
|
||||
class Oven : public QApplication {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Oven(int argc, char* argv[]);
|
||||
|
||||
private:
|
||||
FBXBaker _testBake;
|
||||
void setupGUI();
|
||||
|
||||
OvenMainWindow* _mainWindow;
|
||||
};
|
||||
|
||||
|
||||
|
|
121
tools/oven/src/ui/ModelBakeWidget.cpp
Normal file
121
tools/oven/src/ui/ModelBakeWidget.cpp
Normal file
|
@ -0,0 +1,121 @@
|
|||
//
|
||||
// ModelBakeWidget.cpp
|
||||
// tools/oven/src/ui
|
||||
//
|
||||
// Created by Stephen Birarda on 4/6/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QPushButton>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include "ModelBakeWidget.h"
|
||||
|
||||
ModelBakeWidget::ModelBakeWidget(QWidget* parent, Qt::WindowFlags flags) :
|
||||
QWidget(parent, flags)
|
||||
{
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void ModelBakeWidget::setupUI() {
|
||||
// setup a grid layout to hold everything
|
||||
QGridLayout* gridLayout = new QGridLayout;
|
||||
|
||||
int rowIndex = 0;
|
||||
|
||||
// setup a section to choose the file being baked
|
||||
QLabel* modelFileLabel = new QLabel("Model File");
|
||||
|
||||
_modelLineEdit = new QLineEdit;
|
||||
|
||||
QPushButton* chooseFileButton = new QPushButton("Browse...");
|
||||
connect(chooseFileButton, &QPushButton::clicked, this, &ModelBakeWidget::chooseFileButtonClicked);
|
||||
|
||||
// add the components for the model file picker to the layout
|
||||
gridLayout->addWidget(modelFileLabel, rowIndex, 0);
|
||||
gridLayout->addWidget(_modelLineEdit, rowIndex, 1, 1, 3);
|
||||
gridLayout->addWidget(chooseFileButton, rowIndex, 4);
|
||||
|
||||
// start a new row for next component
|
||||
++rowIndex;
|
||||
|
||||
// setup a section to choose the output directory
|
||||
QLabel* outputDirectoryLabel = new QLabel("Output Directory");
|
||||
|
||||
_outputDirLineEdit = new QLineEdit;
|
||||
|
||||
QPushButton* chooseOutputDirectoryButton = new QPushButton("Browse...");
|
||||
connect(chooseOutputDirectoryButton, &QPushButton::clicked, this, &ModelBakeWidget::chooseOutputDirButtonClicked);
|
||||
|
||||
// add the components for the output directory picker to the layout
|
||||
gridLayout->addWidget(outputDirectoryLabel, rowIndex, 0);
|
||||
gridLayout->addWidget(_outputDirLineEdit, rowIndex, 1, 1, 3);
|
||||
gridLayout->addWidget(chooseOutputDirectoryButton, rowIndex, 4);
|
||||
|
||||
// start a new row for the next component
|
||||
++rowIndex;
|
||||
|
||||
// add a button that will kickoff the bake
|
||||
QPushButton* bakeButton = new QPushButton("Bake Model");
|
||||
connect(bakeButton, &QPushButton::clicked, this, &ModelBakeWidget::bakeButtonClicked);
|
||||
|
||||
// add the bake button to the grid
|
||||
gridLayout->addWidget(bakeButton, rowIndex, 0, -1, -1);
|
||||
|
||||
setLayout(gridLayout);
|
||||
}
|
||||
|
||||
void ModelBakeWidget::chooseFileButtonClicked() {
|
||||
// pop a file dialog so the user can select the model file
|
||||
auto selectedFile = QFileDialog::getOpenFileName(this, "Choose Model", QDir::homePath());
|
||||
|
||||
if (!selectedFile.isEmpty()) {
|
||||
// set the contents of the model file text box to be the path to the selected file
|
||||
_modelLineEdit->setText(selectedFile);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBakeWidget::chooseOutputDirButtonClicked() {
|
||||
// pop a file dialog so the user can select the output directory
|
||||
auto selectedDir = QFileDialog::getExistingDirectory(this, "Choose Output Directory", QDir::homePath());
|
||||
|
||||
if (!selectedDir.isEmpty()) {
|
||||
// set the contents of the output directory text box to be the path to the directory
|
||||
_outputDirLineEdit->setText(selectedDir);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBakeWidget::bakeButtonClicked() {
|
||||
// make sure we have a valid output directory
|
||||
QDir outputDirectory(_outputDirLineEdit->text());
|
||||
|
||||
if (!outputDirectory.exists()) {
|
||||
|
||||
}
|
||||
|
||||
// make sure we have a non empty URL to a model to bake
|
||||
if (_modelLineEdit->text().isEmpty()) {
|
||||
|
||||
}
|
||||
|
||||
// construct a URL from the path in the model file text box
|
||||
QUrl modelToBakeURL(_modelLineEdit->text());
|
||||
|
||||
// if the URL doesn't have a scheme, assume it is a local file
|
||||
if (modelToBakeURL.scheme().isEmpty()) {
|
||||
modelToBakeURL.setScheme("file");
|
||||
}
|
||||
|
||||
// everything seems to be in place, kick off a bake now
|
||||
_baker.reset(new FBXBaker(modelToBakeURL, outputDirectory.absolutePath()));
|
||||
_baker->start();
|
||||
}
|
43
tools/oven/src/ui/ModelBakeWidget.h
Normal file
43
tools/oven/src/ui/ModelBakeWidget.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// ModelBakeWidget.h
|
||||
// tools/oven/src/ui
|
||||
//
|
||||
// Created by Stephen Birarda on 4/6/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_ModelBakeWidget_h
|
||||
#define hifi_ModelBakeWidget_h
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
#include <FBXBaker.h>
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
class ModelBakeWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModelBakeWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
|
||||
private slots:
|
||||
void chooseFileButtonClicked();
|
||||
void chooseOutputDirButtonClicked();
|
||||
void bakeButtonClicked();
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
|
||||
std::unique_ptr<FBXBaker> _baker;
|
||||
|
||||
QLineEdit* _modelLineEdit;
|
||||
QLineEdit* _outputDirLineEdit;
|
||||
|
||||
QUrl modelToBakeURL;
|
||||
};
|
||||
|
||||
#endif // hifi_ModelBakeWidget_h
|
12
tools/oven/src/ui/OvenMainWindow.cpp
Normal file
12
tools/oven/src/ui/OvenMainWindow.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// OvenMainWindow.cpp
|
||||
// tools/oven/src/ui
|
||||
//
|
||||
// Created by Stephen Birarda on 4/6/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "OvenMainWindow.h"
|
21
tools/oven/src/ui/OvenMainWindow.h
Normal file
21
tools/oven/src/ui/OvenMainWindow.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// OvenMainWindow.h
|
||||
// tools/oven/src/ui
|
||||
//
|
||||
// Created by Stephen Birarda on 4/6/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_OvenMainWindow_h
|
||||
#define hifi_OvenMainWindow_h
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
class OvenMainWindow : public QMainWindow {
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_OvenMainWindow_h
|
Loading…
Reference in a new issue