diff --git a/src/Magnum/Trade/sceneconverter.cpp b/src/Magnum/Trade/sceneconverter.cpp index afb18ddfd1..74b7b42c97 100644 --- a/src/Magnum/Trade/sceneconverter.cpp +++ b/src/Magnum/Trade/sceneconverter.cpp @@ -103,6 +103,7 @@ 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 */ @@ -110,6 +111,10 @@ int main(int argc, char** argv) { 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; @@ -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 converterManager{ args.value("plugin-dir").empty() ? std::string{} :