Skip to main content

A library to parse .MDL files (model files for the Source engine).

Project description

ValveMDL

License PyPI pyversions Platform PyPI version CI

A python library to read and write .mdl files, the model format of the Source engine, along with their .vvd and .vtx companions.

ValveMDL is about serialization and nothing else. It will read a model apart and put it back together; it will not transform meshes, render anything, or convert to other formats.

ValveMDL reads and writes all three files. Across a stock Team Fortress 2 install -- 9,858 models spanning format versions 44 to 48 -- a model read apart and written back is byte-for-byte identical to what studiomdl produced, with a single exception caused by orphaned data in one shipped file. See the documentation for the structure by structure detail.

Installation

pip install valvemdl

Usage

from valvemdl import Mdl

mdl = Mdl('models/props_farm/ambulance.mdl')

mdl.version         # 48
mdl.name            # 'ambulance.mdl'
mdl.header.numbones # 3

A model is really a set of files. An mdl contains no vertices and no triangles; those live in the .vvd and .vtx next to it, tied together by a checksum. Opening an mdl notices which of them are present but does not read them until you ask:

mdl.sidecar_paths   # {'.vvd': '...', '.dx90.vtx': '...', ...}
mdl.vvd             # parsed now, cached after
mdl.get_vtx('.sw.vtx')

On versions

Team Fortress 2 ships mdl versions 44, 45, 46, 47 and 48 -- five variants of the same format, in the same game. Version 48 accounts for about 91% of them. studiohdr_t is unchanged across that whole range.

ValveMDL is evidence driven: a structure is supported once it has been read out of real files and cross-checked against the Source SDK, and not before. Gaps are left as gaps rather than guessed at.

Contributing

Issues and pull requests are welcome. Be pythonic, document and test your code. That's all.

One extra rule applies here, because ValveMDL is as much a format reference as it is a library: do not guess. Every field, flag and version rule should trace back either to the Source SDK or to bytes observed in real model files. If something is unknown, say that it is unknown.

License

GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

valvemdl-0.0.2.tar.gz (66.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

valvemdl-0.0.2-py3-none-any.whl (74.4 kB view details)

Uploaded Python 3

File details

Details for the file valvemdl-0.0.2.tar.gz.

File metadata

  • Download URL: valvemdl-0.0.2.tar.gz
  • Upload date:
  • Size: 66.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for valvemdl-0.0.2.tar.gz
Algorithm Hash digest
SHA256 75554152af8628c9c498d2465bf68f3637cd60c7e2999bd65d538818257f4047
MD5 76683a6c8ffb37479bb2adf6f1a33deb
BLAKE2b-256 526068702b9d033315aed6bb04ddaa7e664fa1ebb4774dafcd762c67e2110151

See more details on using hashes here.

Provenance

The following attestation bundles were made for valvemdl-0.0.2.tar.gz:

Publisher: CI.yml on pySourceSDK/ValveMDL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file valvemdl-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: valvemdl-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 74.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for valvemdl-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 021478d1e949c4cccead0ffa3bda57d63e50787ee1edb284f1ec8fe63c4fcf4f
MD5 ab9ff7597e0c60d534ff0bae4ca61dd0
BLAKE2b-256 d335b0b20788c9278fe005bc6ea5dff02a308b2c72400bf1d041e3b8a28d17e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for valvemdl-0.0.2-py3-none-any.whl:

Publisher: CI.yml on pySourceSDK/ValveMDL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page