mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
feat(wom): add WOM3 multi-batch format for material-aware models
WOM1/WOM2 had a single mesh with one texture, which lost the multi-submesh structure of complex M2 models (body+hair+eyes+armor each need different textures and blend modes). WOM3 adds a Batch array: each batch has indexStart/indexCount + a textureIndex into texturePaths + blendMode + flags. Loader is fully backward compatible: WOM1/WOM2 files still load, and WOM3 with no batches block falls back to a single full-mesh batch. fromM2 now extracts batches with materials, and toM2 emits matching M2 batches so the renderer can draw them correctly.
This commit is contained in:
parent
00c078a9af
commit
b736c6b2e1
3 changed files with 124 additions and 30 deletions
|
|
@ -12,7 +12,7 @@ namespace pipeline {
|
|||
struct M2Model;
|
||||
|
||||
// Wowee Open Model format (.wom) — novel format, no Blizzard IP
|
||||
// WOM1: static geometry | WOM2: + bones + animations
|
||||
// WOM1: static geometry | WOM2: + bones + animations | WOM3: + multi-batch materials
|
||||
struct WoweeModel {
|
||||
struct Vertex {
|
||||
glm::vec3 position;
|
||||
|
|
@ -43,18 +43,31 @@ struct WoweeModel {
|
|||
std::vector<std::vector<AnimKeyframe>> boneKeyframes; // [boneIdx][keyframe]
|
||||
};
|
||||
|
||||
// WOM3: a contiguous slice of indices that draws with one material/texture.
|
||||
// Most M2 models have multiple submeshes (body, hair, eyes, etc.) — each
|
||||
// becomes one Batch in WOM3.
|
||||
struct Batch {
|
||||
uint32_t indexStart = 0; // first index in the global index buffer
|
||||
uint32_t indexCount = 0; // number of indices to draw
|
||||
uint32_t textureIndex = 0; // index into texturePaths
|
||||
uint16_t blendMode = 0; // 0=opaque, 1=alpha-test, 2=alpha, 3=add
|
||||
uint16_t flags = 0; // bit 0 = unlit, bit 1 = two-sided, bit 2 = no z-write
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<uint32_t> indices;
|
||||
std::vector<std::string> texturePaths;
|
||||
std::vector<Bone> bones;
|
||||
std::vector<Animation> animations;
|
||||
std::vector<Batch> batches; // empty in WOM1/WOM2, populated in WOM3
|
||||
float boundRadius = 1.0f;
|
||||
glm::vec3 boundMin{0}, boundMax{0};
|
||||
uint32_t version = 1; // 1=WOM1(static), 2=WOM2(animated)
|
||||
uint32_t version = 1; // 1=WOM1(static), 2=WOM2(animated), 3=WOM3(multi-batch)
|
||||
|
||||
bool isValid() const { return !vertices.empty() && !indices.empty(); }
|
||||
bool hasAnimation() const { return !bones.empty() && !animations.empty(); }
|
||||
bool hasBatches() const { return !batches.empty(); }
|
||||
};
|
||||
|
||||
class WoweeModelLoader {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue