4
\$\begingroup\$

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

\$\endgroup\$
5
  • 1
    \$\begingroup\$ it could be defined quads. - an index of triangles that are attached together or something. other than that, I can't think of a reason to relate two random triangles on a mesh. \$\endgroup\$ – Nicholas Hylands Jan 7 '18 at 15:52
  • \$\begingroup\$ Would it be useful to you to see a dump of some sample data? For example, I could find a very simple mesh, then include a picture of the mesh and do a text dump of the associated vertexRefs / triangles / unknowns. \$\endgroup\$ – user111284 Jan 7 '18 at 23:10
  • \$\begingroup\$ Can you post an example file or how you load the data into these? \$\endgroup\$ – Bálint Jan 18 '18 at 9:13
  • \$\begingroup\$ @Bálint, I have attached an example file and code to load it. I hope this helps. Thanks for the interest. \$\endgroup\$ – user111284 Jan 18 '18 at 12:17
  • \$\begingroup\$ the 0xffff I have seen where it defines the end of a triangle strip. That's my previous experience. That would be inline with API standards I have seen or similar. \$\endgroup\$ – ErnieDingo Jan 22 '18 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy