Improve animations reading.

This commit is contained in:
lzwdgc 2020-12-09 18:46:37 +03:00
parent d6e290855c
commit 4158345612
2 changed files with 38 additions and 16 deletions

View file

@ -261,16 +261,20 @@ void material::load(const buffer &b)
void animation::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); READ_STRING_N(b, name, 0xC);
for (auto &s : segments) for (auto &s : segments)
s.loadHeader(b); s.loadHeader(b);
if (segments[0].n == 0)
return;
for (auto &s : segments) for (auto &s : segments)
s.loadData(b); 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) void animation::segment::loadHeader(const buffer &b)
{ {
READ(b, n); READ(b, n);
@ -288,9 +292,9 @@ void animation::segment::loadData(const buffer &b)
for (auto &t : model_polygons) for (auto &t : model_polygons)
READ(b, t); READ(b, t);
} }
unk2.resize(n); polygon_diffs.resize(n);
for (auto &unk : unk2) for (auto &pd : polygon_diffs)
READ(b, unk); pd.load(b);
} }
std::string block::printMtl() const std::string block::printMtl() const

View file

@ -209,28 +209,45 @@ struct animation
// +1 +0.5 -0.5 +1 // +1 +0.5 -0.5 +1
struct segment 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; uint32_t n;
std::vector<uint16_t> model_polygons; std::vector<uint16_t> model_polygons;
// unk // unk
uint32_t unk0; uint32_t unk0; // time or diff or something
uint32_t unk1; uint32_t unk1; // time or diff or something
std::vector<unk_float6> unk2; std::vector<vertex_diff> polygon_diffs;
void loadHeader(const buffer &b); void loadHeader(const buffer &b);
void loadData(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; std::string name;
segment segments[4]; segment segments[4];
virtual void load(const buffer &b); void load(const buffer &b);
}; };
struct damage_model struct damage_model
@ -357,9 +374,6 @@ struct block
material mat; material mat;
MaterialType mat_type; MaterialType mat_type;
//unk (anim + transform settings?)
uint32_t auto_animation;
float animation_cycle;
uint32_t triangles_mult_7; // Tri-mesh. flags? uint32_t triangles_mult_7; // Tri-mesh. flags?
// //
@ -369,7 +383,11 @@ struct block
model_data md; model_data md;
// animations // animations
uint32_t auto_animation;
float animation_cycle;
std::vector<animation> animations; std::vector<animation> animations;
//
std::vector<damage_model> damage_models; std::vector<damage_model> damage_models;
animated_texture atex; animated_texture atex;