feat(extract): emit WOM and WOB side-files (M2/WMO → open formats)

Extends asset_extract with two more open-format emitters:
  --emit-wom  foo.m2 (+ foo00.skin) → foo.wom
  --emit-wob  foo.wmo (+ foo_NNN.wmo groups) → foo.wob
  --emit-open now also turns these on

Originals are preserved so private servers still load .m2/.wmo
through the manifest path; the wowee runtime/editor pick up the
.wom/.wob next to them via the existing open-format search rules.

Implementation:
- New WoweeModelLoader::fromM2Bytes(m2Data, skinData) shares the
  conversion body with fromM2(path, am) via a static helper
  (convertM2ToWom). Lets the extractor convert without standing
  up an AssetManager.
- fromM2(path, am) moved to a separate translation unit
  (wowee_model_fromm2.cpp) so asset_extract doesn't have to
  link the AssetManager dependency.
- WoweeBuildingLoader::fromWMO already takes a WMOModel directly,
  so emitWobFromWmo just needs to read root + group files and
  call save().
- Group sub-files (<base>_NNN.wmo) are skipped during the walk
  since they're merged into the root WMO.
This commit is contained in:
Kelsi 2026-05-06 10:32:17 -07:00
parent 5ed2008621
commit e6ace7cce5
9 changed files with 167 additions and 26 deletions

View file

@ -438,30 +438,28 @@ bool WoweeModelLoader::save(const WoweeModel& model, const std::string& basePath
return true;
}
WoweeModel WoweeModelLoader::fromM2(const std::string& m2Path, AssetManager* am) {
// Internal helper: convert a parsed M2Model (already merged with skin if
// applicable) into a WoweeModel. Shared by fromM2 (AssetManager path)
// and fromM2Bytes (extractor path).
static WoweeModel convertM2ToWom(const M2Model& m2);
// fromM2(path, am) lives in wowee_model_fromm2.cpp so the asset extractor
// can link wowee_model.cpp without pulling in the AssetManager dependency.
// convertM2ToWom() (defined below) is the shared conversion body.
WoweeModel convertM2ToWomShared(const M2Model& m2) { return convertM2ToWom(m2); }
WoweeModel WoweeModelLoader::fromM2Bytes(const std::vector<uint8_t>& m2Data,
const std::vector<uint8_t>& skinData) {
WoweeModel model;
if (!am) return model;
auto data = am->readFile(m2Path);
if (data.empty()) return model;
auto m2 = M2Loader::load(data);
// WotLK+ M2s store header in .m2 but geometry in .skin — always merge the
// skin file when present so we get vertices/indices/batches even for M2s
// that already report isValid() (older expansions).
{
std::string skinPath = m2Path;
auto dotPos = skinPath.rfind('.');
if (dotPos != std::string::npos)
skinPath = skinPath.substr(0, dotPos) + "00.skin";
auto skinData = am->readFile(skinPath);
if (!skinData.empty())
M2Loader::loadSkin(skinData, m2);
}
if (m2Data.empty()) return model;
auto m2 = M2Loader::load(m2Data);
if (!skinData.empty()) M2Loader::loadSkin(skinData, m2);
if (!m2.isValid()) return model;
return convertM2ToWom(m2);
}
static WoweeModel convertM2ToWom(const M2Model& m2) {
WoweeModel model;
model.name = m2.name;
model.boundRadius = m2.boundRadius;

View file

@ -0,0 +1,42 @@
// AssetManager-bound implementation of WoweeModelLoader::fromM2(path, am).
// Split out from wowee_model.cpp so the asset extractor can link the core
// model loader/saver without dragging the AssetManager dependency in.
#include "pipeline/wowee_model.hpp"
#include "pipeline/asset_manager.hpp"
#include "pipeline/m2_loader.hpp"
namespace wowee {
namespace pipeline {
// Friend bridge to the conversion helper defined in wowee_model.cpp.
WoweeModel convertM2ToWomShared(const M2Model& m2);
WoweeModel WoweeModelLoader::fromM2(const std::string& m2Path, AssetManager* am) {
WoweeModel model;
if (!am) return model;
auto data = am->readFile(m2Path);
if (data.empty()) return model;
auto m2 = M2Loader::load(data);
// WotLK+ M2s store header in .m2 but geometry in .skin — always merge
// the skin file when present so we get vertices/indices/batches even
// for M2s that already report isValid() (older expansions).
{
std::string skinPath = m2Path;
auto dotPos = skinPath.rfind('.');
if (dotPos != std::string::npos)
skinPath = skinPath.substr(0, dotPos) + "00.skin";
auto skinData = am->readFile(skinPath);
if (!skinData.empty())
M2Loader::loadSkin(skinData, m2);
}
if (!m2.isValid()) return model;
return convertM2ToWomShared(m2);
}
} // namespace pipeline
} // namespace wowee