Sources: src/public/studio.h (for the .vvd) and src/public/optimize.h (for
the .vtx), both in ValveSoftware/source-sdk-2013 and read on 13 November 2026. The
.mdl, .vvd and .vtx of one model carry the same checksum; the header
says the checksum has to match in the .phy too. Sizes are the sums of the declared field types.
The animation block and collision files are described from src/utils/common/studiobyteswap.cpp,
src/public/phyfile.h and src/public/vcollide_parse.h in the same repository.
The vertex file (.vvd)
vertexFileHeader_t, 64 bytes, little-endian. Offsets in it are from the start of the file.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | char[4] | id | IDSV (MODEL_VERTEX_FILE_ID). IDCV (MODEL_VERTEX_FILE_THIN_ID) is used once the vertex data has been compressed in memory |
| 4 | 4 | int32 | version | 4 (MODEL_VERTEX_FILE_VERSION) |
| 8 | 4 | int32 | checksum | Same as in the .mdl, “ensures sync” |
| 12 | 4 | int32 | numLODs | Number of valid levels of detail |
| 16 | 32 | int32[8] | numLODVertexes | Number of vertices for each desired root LOD |
| 48 | 4 | int32 | numFixups | Number of vertexFileFixup_t records |
| 52 | 4 | int32 | fixupTableStart | Offset of the fixup table |
| 56 | 4 | int32 | vertexDataStart | Offset of the vertex block |
| 60 | 4 | int32 | tangentDataStart | Offset of the tangent block |
The header’s accessors return the vertices only when id is IDSV and
vertexDataStart is not 0, the tangents only when id is IDSV and
tangentDataStart is not 0. Tangents are not stored in the compressed form.
Vertex
mstudiovertex_t, exactly 48 bytes.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 12 | float[3] | m_BoneWeights.weight | Bone weights (MAX_NUM_BONES_PER_VERT is 3) |
| 12 | 3 | char[3] | m_BoneWeights.bone | Bone indexes (signed bytes) |
| 15 | 1 | byte | m_BoneWeights.numbones | Number of bones |
| 16 | 12 | Vector | m_vecPosition | Position |
| 28 | 12 | Vector | m_vecNormal | Normal |
| 40 | 8 | float[2] | m_vecTexCoord | Texture coordinate |
A tangent is a Vector4D, four floats (16 bytes). A model’s vertexindex and
tangentsindex are byte offsets into these arrays, and the header asserts that they are
multiples of 48 and 16.
Fixup record
vertexFileFixup_t, 12 bytes. The header comment says to apply the records sequentially to the
vertex and tangent pools, which are sorted by level of detail, to re-establish mesh order. The loader in
studio.h takes a chosen highest level of detail and copies, record by record in table order,
numVertexes vertices and tangents from sourceVertexID to the end of a new array,
skipping every record whose lod is lower than the chosen level. It copies up to
numLODVertexes of that level; without fixup records those first vertices are used as they
stand.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | int32 | lod | Used to skip a culled root LOD |
| 4 | 4 | int32 | sourceVertexID | Absolute index from the start of the vertex and tangent blocks |
| 8 | 4 | int32 | numVertexes | Number of vertices |
The strip file (.vtx)
Defined in optimize.h, in the OptimizedModel namespace with
#pragma pack(1): there is no padding between fields. The version is
OPTIMIZED_MODEL_FILE_VERSION 7. Every offset in the records is a byte offset from the start
of the record that holds it. The file is a tree: file header, body parts, models, LODs, meshes, strip
groups, strips.
The header notes that MAX_NUM_BONES_PER_VERT (3, from studio.h) changes this
format if it is changed, while MAX_NUM_BONES_PER_TRI (that value times 3) and
MAX_NUM_BONES_PER_STRIP (512) do not.
File header
FileHeader_t, 36 bytes.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | int32 | version | 7 |
| 4 | 4 | int32 | vertCacheSize | Hardware parameter that affects how the model is optimised |
| 8 | 2 | uint16 | maxBonesPerStrip | Hardware parameter |
| 10 | 2 | uint16 | maxBonesPerTri | Hardware parameter |
| 12 | 4 | int32 | maxBonesPerVert | Hardware parameter |
| 16 | 4 | int32 | checkSum | Must match the checksum in the .mdl |
| 20 | 4 | int32 | numLODs | Number of LODs (also in each model header; they should match) |
| 24 | 4 | int32 | materialReplacementListOffset | Offset of one MaterialReplacementListHeader_t for each LOD |
| 28 | 4 | int32 | numBodyParts | Body parts |
| 32 | 4 | int32 | bodyPartOffset | Offset of the BodyPartHeader_t array |
Records
| Record | Size | Fields, in order |
|---|---|---|
BodyPartHeader_t | 8 | numModels, modelOffset (int each). One per body part; this maps one to one with the body parts of the .mdl |
ModelHeader_t | 8 | numLODs, lodOffset (int each). One per model of the .mdl; the LODs are those of the QC $lod command |
ModelLODHeader_t | 12 | numMeshes (int), meshOffset (int), switchPoint (float) |
MeshHeader_t | 9 | numStripGroups (int), stripGroupHeaderOffset (int), flags (byte). A mesh has one material |
StripGroupHeader_t | 25 | numVerts, vertOffset, numIndices, indexOffset, numStrips, stripOffset (int each), flags (byte). A strip group is a locking group with one vertex buffer and one index buffer; a mesh has up to four (non-flexed or flexed, hardware or software skinned) |
StripHeader_t | 27 | numIndices, indexOffset (into the mesh’s index array), numVerts, vertOffset (into the mesh’s vertex array) (int each), numBones (short; enables or disables skinning), flags (byte), numBoneStateChanges, boneStateChangeOffset (int each). A strip is a piece of a strip group divided by bones |
Vertex_t | 9 | boneWeightIndex[3] (bytes, index into the bone list of the mesh’s vertex), numBones (byte), origMeshVertID (uint16), boneID[3] (chars; global bone indexes for software skinning, hardware bone indexes for hardware skinning) |
| Index | 2 | An unsigned short, in the array at the strip group’s indexOffset |
BoneStateChangeHeader_t | 8 | hardwareID, newBoneID (int each) |
MaterialReplacementListHeader_t | 8 | numReplacements, replacementOffset (int each) |
MaterialReplacementHeader_t | 6 | materialID (short), replacementMaterialNameOffset (int, to a string, from the start of this record) |
Flags
| Where | Values |
|---|---|
Strip flags | 0x01 STRIP_IS_TRILIST; 0x02 STRIP_IS_TRISTRIP |
Strip group flags | 0x01 STRIPGROUP_IS_FLEXED; 0x02 STRIPGROUP_IS_HWSKINNED; 0x04 STRIPGROUP_IS_DELTA_FLEXED; 0x08 STRIPGROUP_SUPPRESS_HW_MORPH, a temporary flag used at run time |
Mesh flags | 0x01 MESH_IS_TEETH; 0x02 MESH_IS_EYES; both are material properties |
The animation block file (.ani)
Layout as the SDK’s byte swapper (utils/common/studiobyteswap.cpp,
ByteswapANIFile) walks it. The file begins with a studiohdr_t, the same
structure as the header of the .mdl. The
descriptions of the animations and the table of blocks stay in the .mdl
(numanimblocks, animblockindex). Each record of that table,
mstudioanimblock_t, holds datastart and dataend, positions in the
.ani file. Block 0 stands for data held in the .mdl itself.
| Data of | Where it begins in the .ani |
|---|---|
An animation with sectionframes 0 and animblock above 0 | datastart of that block + animindex |
A section of an animation (numframes / sectionframes + 2 sections), animblock of the section not 0 | datastart of the section’s block + the section’s animindex |
IK rules, when animblockikruleindex is not 0 | datastart of the animation’s block + animblockikruleindex |
Local hierarchy records, when localhierarchyindex is not 0 | datastart of the animation’s block + localhierarchyindex |
The records inside a block are those of animation
data held in the .mdl; offsets that in the .mdl count from the animation
description count here from the start of the block. An animblock of −1 marks an out of
date model. The swapper handles a .ani only together with a .mdl whose
numanimblocks is not 0. In its console form the blocks are compressed.
The collision file (.phy)
From public/phyfile.h and ByteswapPHY in
utils/common/studiobyteswap.cpp. The file is a header, then solidCount solids,
then text.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | int32 | size | Size of this header, 16; the first solid begins there |
| 4 | 4 | int32 | id | |
| 8 | 4 | int32 | solidCount | Number of solids |
| 12 | 4 | int32 | checkSum | Checksum of the source .mdl |
Each solid is an int32 length followed by that many bytes of collision data, which the
physics library writes. The swapper knows two headers at the start of a solid, the length being their
first field:
| Form | Fields after the length |
|---|---|
Current (swapcompactsurfaceheader_t, 32 bytes with the length) | vphysicsID (the characters VPHY), version (int16), modelType (int16), surfaceSize (int32), dragAxisAreas (3 floats), axisMapSize (int32). The swapper steps to the next solid by surfaceSize + 32 |
Old (legacysurfaceheader_t, 52 bytes with the length) | mass_center (3 floats), rotation_inertia (3 floats), upper_limit_radius (float), max_deviation (low 8 bits) and byte_size (high 24 bits), offset_ledgetree_root (int32), dummy (3 int32). Taken to be this form when there is no VPHY and dummy[2] is the characters IVPS or 0; the next solid is byte_size + 4 further |
The rest of the file is text: blocks of a name followed by keys and values in braces. The key
parser of the physics interface (public/vcollide_parse.h) has handlers for blocks of the
kinds solid, fluid, ragdoll constraint, surface table, custom and vehicle. A solid’s record there is
an index, a name, a parent, a surface property, a mass centre override and the object’s parameters.
The tree of convex pieces inside a solid is read and written by the physics library, which the SDK
does not contain.
Structures built in memory
studio.h also declares structures that the running program builds from these files. They hold
pointers that mean nothing in a file, so they have no byte offsets here; the two accessors at the end sit
inside model and mesh records, where their places are
given.
Compressed (“thin”) vertex data
Once a .vvd in memory carries the id IDCV, its vertexDataStart leads
to a thinModelVertices_t instead of the array of 48-byte vertices; the header comment names its
use as model decals. With N bone influences a vertex (0 to 3) it holds:
| Member | Type | Contents |
|---|---|---|
m_numBoneInfluences | int | N |
m_boneWeights | float pointer | N − 1 weights a vertex; none needed when N is 0 or 1 |
m_boneIndices | char pointer | N bone indexes a vertex; none when N is 0 |
m_vecPositions | Vector pointer | One position a vertex |
m_vecNormals | unsigned short pointer | One normal a vertex, the low 16 bits of the value PackNormal_UBYTE4 makes |
Read back, a vertex has the stored N − 1 weights, then 1 minus their sum, then 0; its bone indexes past N are 0; its bone count is N, or 1 when N is 0, which binds it wholly to bone 0. Texture coordinates and tangents have no member.
Joined models
virtualmodel_t is the joined view of a model and the
models it includes. It holds a lock and these lists:
| List | Records | Fields of a record |
|---|---|---|
m_seq | virtualsequence_t | flags, activity, group, index (int each; short in the Xbox build) |
m_anim, m_attachment, m_pose, m_node, m_iklock | virtualgeneric_t | group, index (int each; short in the Xbox build): which model, and the number there |
m_group | virtualgroup_t, one a model | A cache pointer that leads to that model’s header, and the integer maps boneMap (joined bone to local), masterBone (local bone to joined), masterSeq, masterAnim, masterAttachment, masterPose and masterNode (local number to joined) |
m_autoplaySequences | unsigned short | Sequence numbers |
Vertex data accessors
mstudio_modelvertexdata_t, inside each model record, is two pointers,
pVertexData and pTangentData, set from the loaded .vvd.
mstudio_meshvertexdata_t, inside each mesh record, holds the way back to its model’s accessor
and numLODVertexes, the number of the mesh’s vertices at each level of detail.
These accessors take places in the .mdl; the records below exist only in memory.
Hardware data
| Record | Members, in order |
|---|---|
studiohwdata_t | m_RootLOD, m_NumLODs, m_pLODs, m_NumStudioMeshes |
studioloddata_t, one a level of detail | m_pMeshData (one for each studio mesh), m_SwitchPoint, numMaterials, ppMaterials and pMaterialFlags (one for each of the model’s textures), m_pHWMorphDecalBoneRemap, m_nDecalBoneCount |
studiomeshdata_t | m_NumGroup, m_pMeshGroup |
studiomeshgroup_t | m_pMesh, m_NumStrips, m_Flags (1 MESHGROUP_IS_FLEXED, 2 MESHGROUP_IS_HWSKINNED, 4 MESHGROUP_IS_DELTA_FLEXED), m_pStripData (strip headers of the .vtx form), m_pGroupIndexToMeshIndex, m_NumVertices, m_pUniqueTris (for performance measurements), m_pIndices, m_MeshNeedsRestore, m_ColorMeshID, m_pMorph. The mesh vertex of index i is m_pGroupIndexToMeshIndex[m_pIndices[i]] |
The header chooses a level of detail from a metric, 100 divided by the size on screen of a unit sphere
(0 when that size is 0). With no levels the answer is 0. A last level whose switch point is negative is the
shadow level and is never chosen. From m_RootLOD upwards, the first level whose successor has a
switch point above the metric is taken, and otherwise the last one left.
Viewer
Each of these files also opens on its own. A .vvd shows its header, fixup records,
vertices and tangents, and its vertex positions as points, with an option for the level of detail. A
.vtx lists every record of its tree, the strip vertices, indices, bone state changes and
material replacements; it holds no positions. A .ani shows its header and, with the
.mdl of the same name beside it, the blocks and which animation, section and IK rules lie
where; animations are played by opening the .mdl. A .phy shows its header, the
headers of its solids, the text line by line and every key of every block; the shapes of the solids are
not drawn. Opened from a folder or dropped together with the .mdl, each says whether the
checksums agree. The text of a .phy is read up to 256 MB.