feat(editor): CLI batch convert mode (--convert-m2) for M2→WOM conversion

- wowee_editor --convert-m2 <path> --data <datadir> converts a single
  M2 model to WOM open format without launching the GUI
- Output goes to output/models/ with same path structure
- Useful for batch scripts to convert entire asset directories
- Example: wowee_editor --data Data --convert-m2 creature\\bear\\bear.m2
This commit is contained in:
Kelsi 2026-05-05 10:50:36 -07:00
parent bf83da61d2
commit 4b94640cae

View file

@ -1,4 +1,6 @@
#include "editor_app.hpp"
#include "pipeline/wowee_model.hpp"
#include "pipeline/asset_manager.hpp"
#include "core/logger.hpp"
#include <string>
#include <cstring>
@ -27,6 +29,31 @@ int main(int argc, char* argv[]) {
}
}
// Batch convert mode: --convert <m2path> converts M2 to WOM
for (int i = 1; i < argc; i++) {
if (std::strcmp(argv[i], "--convert-m2") == 0 && i + 1 < argc) {
std::string m2Path = argv[++i];
LOG_INFO("Batch convert mode: M2→WOM for ", m2Path);
// Need data path for asset loading
if (dataPath.empty()) dataPath = "Data";
wowee::pipeline::AssetManager am;
if (am.initialize(dataPath)) {
auto wom = wowee::pipeline::WoweeModelLoader::fromM2(m2Path, &am);
if (wom.isValid()) {
std::string outPath = m2Path;
auto dot = outPath.rfind('.');
if (dot != std::string::npos) outPath = outPath.substr(0, dot);
wowee::pipeline::WoweeModelLoader::save(wom, "output/models/" + outPath);
LOG_INFO("Converted: ", m2Path, " → output/models/", outPath, ".wom");
} else {
LOG_ERROR("Failed to convert: ", m2Path);
}
am.shutdown();
}
return 0;
}
}
if (dataPath.empty()) {
dataPath = "Data";
LOG_INFO("No --data path specified, using default: ", dataPath);