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);