-
Notifications
You must be signed in to change notification settings - Fork 2
fig
aspadm edited this page Oct 20, 2018
·
2 revisions
3d mesh
File starts from "magic number":
byte magic[3]; // FIG
Next to it lay block's count:
byte n;
n -= 48;
In game format used n = 8. "Block" means that vertex data is stored x8. Final model is trilinear interpolation on 3 parameters: strength, dexterity, height.
Next to it placed model information:
uint vertex_count;
uint normal_count;
uint texcoord_count;
uint index_count;
uint vertex_component_count;
uint morph_component_count;
uint unknown; // always 0
uint group;
uint texture_number;
vec3 center[n];
vec3 aabb_min[n];
vec3 aabb_max[n];
float radius[n];
Vertex data packed like this: in n blocks lay arrays of packed by 4 axis data like x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4
:
float vertices[3 * 4 * n * vertex_count];
Normals are packed with similar method: pack by 4 elements for 4 axis:
float normals[4 * 4 * normal_count];
Texture coordinates and indeces:
vec2 texcoords[texcoord_count];
ushort indices[index_count];
Model verteces are assembled using this index mapping:
typedef struct
{
uint16 vertex_index;
uint16 normal_index;
uint16 texcoord_index;
} vertex_component;
vertex_component vertex_components[vertex_component_count];
At the end of file are placed morphing data:
typedef struct
{
uint16 morph_index;
uint16 vertex_index;
} morph_component;
morph_component morph_components[morph_component_count];
We have 8 values, placed at cube's vertices. Using three proportions we can get mixed result (point inside cube):
s, d, h - parameters
0..7 - start values
t1 = 0 + (1 - 0) * s
t2 = 2 + (3 - 2) * s
v1 = t1 + (t2 - t1) * d
t1 = 4 + (5 - 4) * s
t2 = 6 + (7 - 6) * s
v2 = t1 + (t2 - t1) * d
res = v1 + (v2 - v1) * h