sledge-formats icon indicating copy to clipboard operation
sledge-formats copied to clipboard

Add support of Source engine v44 mdl format (.mdl, .vvd, .vtx)

Open Duude92 opened this issue 2 months ago • 0 comments
trafficstars

This PR adds Source engine v44 models support. Provide multiple structs for reading different Source engine model-related formats. Although this PR provides structs per files - it is not fully tested (e.g. I haven't looked into animation sequences and how do they work) Screenshot with some tested models: image Sorry, I haven't bother to make unit-tests. Also, probably later would test for else mdl version, and/or do fixes Also, quick reference to code: Since model data is seprated between multiple files - I've provided some properties/methods to 'easily' retrieve data from MdlFile object, e.g.:

  • BodypartCount => Header.bodypart_count
  • LodCount => VtxFile.Header.numLODs
  • GetModelCount(int bodypart) => Bodyparts[bodypart].Header.nummodels
  • GetMeshCount(int bodypart, int model) => Bodyparts[bodypart].Models[model].Data.nummeshes
  • MeshVertex[] GetVertices() -> this precomputes vertex data with vvd fixups
  • GetIndices(int meshIndex = 0, int lodIndex = 0, int modelIndex = 0, int bodyPart = 0) -> returns precomputed array of indices per mesh
  • GetMaterialIndex(int meshIndex = 0, int modelIndex = 0, int bodyPart = 0) => Bodyparts[bodyPart].Models[modelIndex].Meshes[meshIndex].Data.material -> material is bound to mesh

Duude92 avatar Aug 30 '25 13:08 Duude92