From 415834561282656a6429fea32cd86f49a6132b28 Mon Sep 17 00:00:00 2001 From: lzwdgc Date: Wed, 9 Dec 2020 18:46:37 +0300 Subject: [PATCH] Improve animations reading. --- src/model/model.cpp | 16 ++++++++++------ src/model/model.h | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/model/model.cpp b/src/model/model.cpp index ecfb4f1..fe2fc09 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -261,16 +261,20 @@ void material::load(const buffer &b) void animation::load(const buffer &b) { - READ(b, type); // seen: 1, 3 + READ(b, type); READ_STRING_N(b, name, 0xC); for (auto &s : segments) s.loadHeader(b); - if (segments[0].n == 0) - return; for (auto &s : segments) s.loadData(b); } +void animation::segment::vertex_diff::load(const buffer &b) +{ + translation.load(b); + READ(b, unk); +} + void animation::segment::loadHeader(const buffer &b) { READ(b, n); @@ -288,9 +292,9 @@ void animation::segment::loadData(const buffer &b) for (auto &t : model_polygons) READ(b, t); } - unk2.resize(n); - for (auto &unk : unk2) - READ(b, unk); + polygon_diffs.resize(n); + for (auto &pd : polygon_diffs) + pd.load(b); } std::string block::printMtl() const diff --git a/src/model/model.h b/src/model/model.h index 0a9ba6c..e785320 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -209,28 +209,45 @@ struct animation // +1 +0.5 -0.5 +1 struct segment { - struct unk_float6 + struct vertex_diff { - float unk[6]; + vertex_normal translation; + float unk[3]; // rotation? + + void load(const buffer &b); }; uint32_t n; std::vector model_polygons; // unk - uint32_t unk0; - uint32_t unk1; - std::vector unk2; + uint32_t unk0; // time or diff or something + uint32_t unk1; // time or diff or something + std::vector polygon_diffs; void loadHeader(const buffer &b); void loadData(const buffer &b); }; - uint32_t type; + enum animation_type : uint32_t + { + _2grad_1directions_linear, + _2grad_2directions, + _2grad_1directions, + _1grad_1directions, + b, + c,d,e,f,g,h,i,j,k,l + }; + + union + { + animation_type atype; + uint32_t itype; + } type; std::string name; segment segments[4]; - virtual void load(const buffer &b); + void load(const buffer &b); }; struct damage_model @@ -357,9 +374,6 @@ struct block material mat; MaterialType mat_type; - //unk (anim + transform settings?) - uint32_t auto_animation; - float animation_cycle; uint32_t triangles_mult_7; // Tri-mesh. flags? // @@ -369,7 +383,11 @@ struct block model_data md; // animations + uint32_t auto_animation; + float animation_cycle; std::vector animations; + + // std::vector damage_models; animated_texture atex;