I have a large number of old mesh files in a custom, undocumented binary format. I have managed to parse almost everything but am left with one group of structures, described below, that I don't understand. I hope an experienced graphics programmer can explain what is happening.
Here are the structures concerned:
// These types are defined below. We're trying to understand what
// these three arrays are used to achieve.
VertexRef vertexRefs[];
Triangle triangles[];
Unknown unknowns[];
struct VertexRef {
// Earlier in the file, there are several vertex buffers.
// The file can contain multiple meshes, either as components
// of a larger mesh, or as multiple LODs.
// This value _group_ picks out one of these buffers.
uint8_t group;
// Index into the vertex buffer picked out by _group_.
uint16_t vertexIndex;
};
struct TriangleVertex {
// Index into the array _vertexRefs_
uint16_t vertexRef;
// Index into the array _unknowns_
uint16_t unknownIndex;
};
struct Triangle {
TriangleVertex verts[3];
};
struct Unknown {
// Index into the array _vertexRefs_
uint16_t vertexRef1;
// Index into the array _triangles_
uint16_t triangleIndex1;
// Another index into the array _vertexRefs_
uint16_t vertexRef2;
// triangleIndex2 can be 0xffff, while triangleIndex1 never is
uint16_t triangleIndex2;
};
The array of VertexRef is straightforward. It picks vertices, potentially from multiple meshes, to form a composite mesh.
The array of Triangle is formed by vertices from the array of VertexRef. Each vertex is also associated with an Unknown.
I am out of my depth in understanding what Unknown is doing. Member triangleIndex2 sometimes being 0xffff (or invalid, or nonexistent?) might indicate it is a leaf node of a tree? Perhaps the structure comprising the arrays vertexRefs, triangles and unknowns is some kind of collision detection tree?
I'd be very grateful for any hints. Please ask questions if I've failed to be clear enough about something.
Edit: In answer to a request in comments, I am attaching a sample file and code to load it. The code should run on any likely system. The file is a mesh of a pair of boots. The file is hosted at uploadfiles.io: https://ufile.io/w66mh