From 4b94640caecb625fc6817f90c431628d55f16171 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 5 May 2026 10:50:36 -0700 Subject: [PATCH] =?UTF-8?q?feat(editor):=20CLI=20batch=20convert=20mode=20?= =?UTF-8?q?(--convert-m2)=20for=20M2=E2=86=92WOM=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - wowee_editor --convert-m2 --data 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 --- tools/editor/main.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/editor/main.cpp b/tools/editor/main.cpp index a76b550f..eded9ff8 100644 --- a/tools/editor/main.cpp +++ b/tools/editor/main.cpp @@ -1,4 +1,6 @@ #include "editor_app.hpp" +#include "pipeline/wowee_model.hpp" +#include "pipeline/asset_manager.hpp" #include "core/logger.hpp" #include #include @@ -27,6 +29,31 @@ int main(int argc, char* argv[]) { } } + // Batch convert mode: --convert 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);