Expand description
MDL binary reader. MDL binary reader.
The reader uses a two-pass architecture:
Pass 1 (node tree): Recursive DFS traversal of the node hierarchy. Each
node’s headers and type-specific extra data are parsed, and mesh nodes
collect an MdxMeshInfo descriptor with stride, vertex count, and
per-attribute byte offsets. Vertex attribute arrays are left empty at this
stage - only structural metadata is captured.
Pass 2 (MDX vertex population): After the full tree is built, vertex data is populated from the MDX buffer (or from MDL content-blob fallback positions when no MDX is present). Meshes are visited in non-skin-first order - all non-skin meshes in DFS order, then all skin meshes in DFS order - matching the BioWare engine’s canonical MDX layout. A cumulative cursor advances through the MDX buffer, reading interleaved vertex attributes and skipping terminator/alignment padding between meshes.
This two-pass design decouples the node parse order (DFS) from the MDX data order (non-skin-first), enabling correct vertex assignment for vanilla game files where these orders differ.
Functions§
- read_
mdl - Reads an MDL file from the given reader.
- read_
mdl_ from_ bytes - Reads an MDL file from the given byte slice.