Skip to content

Conversation

@Duude92
Copy link
Contributor

@Duude92 Duude92 commented Aug 30, 2025

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
Copy link
Contributor Author

Duude92 commented Nov 15, 2025

Hey @LogicAndTrick, can you review PR?

@LogicAndTrick
Copy link
Owner

Thanks for the implementation, but to be honest, I cannot review this - there's 1400 lines of code and no tests. I think its worth having this branch available to compare with another implementation though, since based on your screenshot it looks like it works well.

Doing a quick scan through the code, its doing things that I specifically avoid in other parts of the lib - unmanaged memory/memory pinning, PtrToStructure, code copied directly from the Source SDK (license issues).

So unfortunately I won't be merging this, sorry :(

@Duude92
Copy link
Contributor Author

Duude92 commented Nov 16, 2025

I've used Marshaling just because it's faster to implement, so, maybe, someday, I may rewrite it for parser.
About licensing, I thought format specifications are not copyrightable, even quick search leads to answers that specifications (not implementations) cannot be licensed. I think there shouldn't be any legal issues.
Anyway, thanks for the reply, no - means no, you can close this if you wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants