sledge-formats
sledge-formats copied to clipboard
Add support of Source engine v44 mdl format (.mdl, .vvd, .vtx)
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:
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_countLodCount => VtxFile.Header.numLODsGetModelCount(int bodypart) => Bodyparts[bodypart].Header.nummodelsGetMeshCount(int bodypart, int model) => Bodyparts[bodypart].Models[model].Data.nummeshesMeshVertex[] GetVertices() -> this precomputes vertex data with vvd fixupsGetIndices(int meshIndex = 0, int lodIndex = 0, int modelIndex = 0, int bodyPart = 0) -> returns precomputed array of indices per meshGetMaterialIndex(int meshIndex = 0, int modelIndex = 0, int bodyPart = 0) => Bodyparts[bodyPart].Models[modelIndex].Meshes[meshIndex].Data.material -> material is bound to mesh