mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-08 01:53:52 +00:00
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.
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// 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
|