Skip to content

Commit

Permalink
[wip] Trade: add serialization to magnum-sceneconverter.
Browse files Browse the repository at this point in the history
TODO: blob inpuc
  • Loading branch information
mosra committed Apr 17, 2020
1 parent d6cce9b commit 7305a2c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Magnum/Trade/sceneconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,18 @@ int main(int argc, char** argv) {
.addOption('i', "importer-options").setHelp("importer-options", "configuration options to pass to the importer", "key=val,key2=val2,…")
.addOption('c', "converter-options").setHelp("converter-options", "configuration options to pass to the converter", "key=val,key2=val2,…")
.addBooleanOption("info").setHelp("info", "print info about the input file and exit")
.addBooleanOption("serialize").setHelp("serialize", "Serialize the imported data to a blob")
.setParseErrorCallback([](const Utility::Arguments& args, Utility::Arguments::ParseError error, const std::string& key) {
/* If --info is passed, we don't need the output or --converter
argument */
/** @todo remove converter once it's optional again */
if(error == Utility::Arguments::ParseError::MissingArgument &&
(key == "output" || key == "converter") &&
args.isSet("info")) return true;
/* If --serialize is passed, we don't need the --converter */
/** @todo remove converter once it's optional again */
if(error == Utility::Arguments::ParseError::MissingArgument &&
key == "converter" && args.isSet("serialize")) return true;

/* Handle all other errors as usual */
return false;
Expand Down Expand Up @@ -269,6 +274,16 @@ key=true.)")
return 4;
}

/* Serialize to a blob, if requested */
if(args.isSet("serialize")) {
if(!Utility::Directory::write(args.value("output"), mesh->serialize())) {
Error{} << "Cannot save file" << args.value("output");
return 5;
}

return 0;
}

/* Load converter plugin */
PluginManager::Manager<Trade::AbstractSceneConverter> converterManager{
args.value("plugin-dir").empty() ? std::string{} :
Expand Down

0 comments on commit 7305a2c

Please sign in to comment.