Some clarifications.

This commit is contained in:
lzwdgc 2017-07-25 04:23:05 +03:00
parent 9213e46d2f
commit faf3226a1b
4 changed files with 54 additions and 30 deletions

View file

@ -1,4 +1,4 @@
local_settings:
dependencies:
- pvt.lzwdgc.polygon4.data_manager: master
- pvt.lzwdgc.polygon4.data_manager.data_manager: master

View file

@ -25,6 +25,8 @@
#include <buffer.h>
#include <iostream>
using namespace std;
std::string version();
@ -77,20 +79,20 @@ std::string vertex::printTex() const
void damage_model::load(const buffer &b)
{
READ(b, n_polygons);
polygons.resize(n_polygons);
model_polygons.resize(n_polygons);
READ(b, unk8);
READ(b, name);
for (auto &t : polygons)
for (auto &t : model_polygons)
READ(b, t);
READ(b, unk6);
READ(b, flags);
READ(b, n_vertex);
vertices.resize(n_vertex);
READ(b, n_triangles);
triangles.resize(n_triangles);
damage_triangles.resize(n_triangles / 3);
for (auto &v : vertices)
v.load(b, flags);
for (auto &t : triangles)
for (auto &t : damage_triangles)
READ(b, t);
}
@ -100,7 +102,7 @@ void animation::load(const buffer &b)
READ(b, name);
for (auto &s : segments)
s.loadHeader(b);
if (segments[0].n)
//if (segments[0].n)
for (auto &s : segments)
s.loadData(b);
}
@ -118,8 +120,8 @@ void animation::segment::loadData(const buffer &b)
return;
if (unk0)
{
triangles.resize(n);
for (auto &t : triangles)
model_polygons.resize(n);
for (auto &t : model_polygons)
READ(b, t);
}
unk2.resize(n);
@ -174,15 +176,17 @@ std::string block::printObj(const std::string &mtl_name) const
s += "\n";
if (n_triangles)
for (int i = 0; i <= n_triangles - 3; i += 3)
{
auto x = to_string(triangles[i] + 1);
auto y = to_string(triangles[i + 2] + 1);
auto z = to_string(triangles[i + 1] + 1);
x += "/" + x;
y += "/" + y;
z += "/" + z;
s += "f " + x + " " + y + " " + z + "\n";
for (auto &t : triangles)
{
auto x = to_string(t.x + 1);
auto y = to_string(t.y + 1);
auto z = to_string(t.z + 1);
x += "/" + x;
y += "/" + y;
z += "/" + z;
s += "f " + x + " " + y + " " + z + "\n";
}
}
s += "\n";
@ -200,7 +204,6 @@ void block::load(const buffer &b)
READ_STRING(b, tex3);
READ_STRING(b, tex4);
READ(b, LODs);
READ(b, unk1);
READ(b, unk2);
READ(b, unk3);
READ(b, size);
@ -221,7 +224,7 @@ void block::load(const buffer &b)
READ(data, material);
// unk
READ(data, unk_flags0);
READ(data, effect);
READ(data, unk7);
READ(data, unk9);
READ(data, unk10);
@ -243,7 +246,7 @@ void block::load(const buffer &b)
READ(data, n_triangles);
if (triangles_mult_7 && (flags & F_UNK0) && !unk11)
n_triangles *= 7;
triangles.resize(n_triangles);
triangles.resize(n_triangles / 3);
for (auto &v : vertices)
v.load(data, flags);
for (auto &t : triangles)
@ -255,6 +258,14 @@ void block::load(const buffer &b)
for (auto &dm : damage_models)
dm.load(data);
string s = "extraction error: block #" + std::string(name);
if (!data.eof())
{
cerr << s << "\n";
return;
}
// unknown how to proceed
if (!data.eof() && triangles_mult_7)
{
// unknown end of block
@ -264,7 +275,7 @@ void block::load(const buffer &b)
READ(data, t);
}
if (!data.eof())
throw std::logic_error("extraction error: block #" + std::string(name));
throw std::logic_error(s);
}
void model::load(const buffer &b)

View file

@ -52,6 +52,15 @@ enum class BlockType : uint32_t
ParticleEmitter
};
enum class EffectType : uint32_t
{
Texture = 0x0,
TextureWithGlareMap = 0x1,
TextureWithGlareMapAndMask = 0x32,
AlphaTextureDoubleSided = 0x6,
MaterialOnly = 0x14,
};
struct Vector4
{
float x;
@ -84,7 +93,12 @@ struct vertex
std::string printTex() const;
};
typedef uint16_t triangle;
struct triangle
{
uint16_t x;
uint16_t y;
uint16_t z;
};
struct animation
{
@ -100,7 +114,7 @@ struct animation
uint32_t unk0;
uint32_t unk1;
std::vector<triangle> triangles;
std::vector<uint16_t> model_polygons;
std::vector<unk_float6> unk2;
void loadHeader(const buffer &b);
@ -119,21 +133,21 @@ struct damage_model
uint32_t n_polygons;
float unk8[3];
char name[0x3C];
std::vector<uint16_t> polygons;
std::vector<uint16_t> model_polygons;
uint8_t unk6;
uint32_t flags;
uint32_t n_vertex;
uint32_t n_triangles;
std::vector<vertex> vertices;
std::vector<uint16_t> triangles;
std::vector<triangle> damage_triangles;
virtual void load(const buffer &b);
};
struct material
{
Vector4 ambient;
Vector4 diffuse;
Vector4 ambient;
Vector4 specular;
Vector4 emissive;
float power;
@ -176,8 +190,7 @@ struct block
} _;
uint32_t LODs;
};
uint32_t unk1;
uint32_t unk2[2];
uint32_t unk2[3];
uint32_t unk3;
uint32_t size;
uint32_t unk4[10];
@ -187,7 +200,7 @@ struct block
material material;
//unk (anim + transform settings?)
uint32_t unk_flags0;
EffectType effect;
uint32_t unk7;
float unk9;
uint32_t unk10;
@ -206,7 +219,7 @@ struct block
uint32_t n_vertex;
uint32_t n_triangles;
std::vector<vertex> vertices;
std::vector<uint16_t> triangles;
std::vector<triangle> triangles;
// animations
std::vector<animation> animations;