VOXEDIT: started with the export feature
parent
c9b7ecfa2c
commit
661e2e5857
|
@ -25,6 +25,11 @@ TBLayout: distribution: gravity, axis: y
|
|||
@include definitions>menubutton
|
||||
text Load
|
||||
id load
|
||||
TBButton
|
||||
gravity: left
|
||||
@include definitions>menubutton
|
||||
text Export
|
||||
id export
|
||||
TBLayout: gravity: left right
|
||||
TBWidget
|
||||
TBSelectDropdown: gravity: left top
|
||||
|
|
|
@ -32,6 +32,10 @@ bool VoxEdit::newFile(bool force) {
|
|||
return _mainWindow->createNew(force);
|
||||
}
|
||||
|
||||
bool VoxEdit::exportFile(std::string_view file) {
|
||||
return _mainWindow->exportFile(file);
|
||||
}
|
||||
|
||||
core::AppState VoxEdit::onCleanup() {
|
||||
const core::AppState state = Super::onCleanup();
|
||||
_meshPool->shutdown();
|
||||
|
@ -75,6 +79,16 @@ core::AppState VoxEdit::onInit() {
|
|||
}
|
||||
}).setArgumentCompleter(fileCompleter).setHelp("Save the current state to the given file");
|
||||
|
||||
core::Command::registerCommand("export", [this] (const core::CmdArgs& args) {
|
||||
if (args.empty()) {
|
||||
Log::error("Usage: export <filename>");
|
||||
return;
|
||||
}
|
||||
if (!exportFile(args[0])) {
|
||||
Log::error("Failed to export to file %s", args[0].c_str());
|
||||
}
|
||||
}).setArgumentCompleter(fileCompleter).setHelp("Export the current state to the given file");
|
||||
|
||||
core::Command::registerCommand("load", [this] (const core::CmdArgs& args) {
|
||||
if (args.empty()) {
|
||||
Log::error("Usage: load <filename>");
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
bool saveFile(std::string_view file);
|
||||
bool loadFile(std::string_view file);
|
||||
bool voxelizeFile(std::string_view file);
|
||||
bool exportFile(std::string_view file);
|
||||
bool newFile(bool force = false);
|
||||
|
||||
video::MeshPoolPtr meshPool() const;
|
||||
|
|
|
@ -183,6 +183,18 @@ bool EditorScene::voxelizeModel(const video::MeshPtr& meshPtr) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool EditorScene::exportModel(std::string_view file) {
|
||||
core_trace_scoped(EditorSceneExportModel);
|
||||
const io::FilePtr& filePtr = core::App::getInstance()->filesystem()->open(std::string(file));
|
||||
if (!(bool)filePtr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//const std::string& ext = filePtr->getExtension();
|
||||
// TODO: assimp exporters
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditorScene::loadModel(std::string_view file) {
|
||||
core_trace_scoped(EditorSceneLoadModel);
|
||||
const io::FilePtr& filePtr = core::App::getInstance()->filesystem()->open(std::string(file));
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
bool voxelizeModel(const video::MeshPtr& mesh);
|
||||
bool saveModel(std::string_view file);
|
||||
bool loadModel(std::string_view file);
|
||||
bool exportModel(std::string_view file);
|
||||
bool newModel(bool force);
|
||||
|
||||
void setActionExecutionDelay(long actionExecutionDelay);
|
||||
|
|
|
@ -71,6 +71,9 @@ bool MainWindow::handleClickEvent(const tb::TBWidgetEvent &ev) {
|
|||
} else if (ev.target->GetID() == TBIDC("load")) {
|
||||
load("");
|
||||
return true;
|
||||
} else if (ev.target->GetID() == TBIDC("export")) {
|
||||
exportFile("");
|
||||
return true;
|
||||
} else if (ev.target->GetID() == TBIDC("save")) {
|
||||
save("");
|
||||
return true;
|
||||
|
@ -166,6 +169,19 @@ bool MainWindow::voxelize(std::string_view file) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool MainWindow::exportFile(std::string_view file) {
|
||||
std::string f;
|
||||
if (file.empty()) {
|
||||
// TODO: extract extension - filter
|
||||
f = _voxedit->openDialog("vox,qbt");
|
||||
if (f.empty()) {
|
||||
return false;
|
||||
}
|
||||
file = f;
|
||||
}
|
||||
return _scene->exportModel(file);
|
||||
}
|
||||
|
||||
bool MainWindow::load(std::string_view file) {
|
||||
std::string f;
|
||||
if (file.empty()) {
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
bool voxelize(std::string_view file);
|
||||
bool save(std::string_view file);
|
||||
bool load(std::string_view file);
|
||||
bool exportFile(std::string_view file);
|
||||
bool createNew(bool force);
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue