On this page
What goes into a mesh
A render mesh is one binary file per object: a vertex buffer, an index buffer and a tree of geometries, LODs and materials that slice them into draw batches. Which of the three kinds a file is decides how the engine moves it: not at all, in rigid parts, or by bones.
The three kinds#
| Kind | File | Moves by | Used for | Node record per LOD |
|---|---|---|---|---|
| static | .staticmesh | never moves | buildings, props, walls, trees | node matrices (skipped by the loader) |
| bundled | .bundledmesh | rigid parts, each with its own matrix | vehicles, weapons, flags' poles, particles | part count; BLENDINDICES byte 0 of a vertex = its part |
| skinned | .skinnedmesh | skeleton bones, two bones per vertex | soldiers, hero items, animated flags | rigs: per material the bone ids and inverse bind matrices |
All three are read by bf2-mesh template.rs MeshFile::parse, which mirrors the RendDX9.dll readers line by line: the header (MeshTemplate::readHeader), the vertex declaration (D3D9 D3DVERTEXELEMENT9 entries), the vertex and 16-bit index arrays, then per geometry and LOD the bounds, the kind's node record and the materials (Material: alpha mode, effect file, technique, texture maps, vertex and index ranges). A geometry is a variant of the whole object (a vehicle's first-person, third-person and wreck), a LOD a cheaper copy for distance, a material one draw call.
Static v11: POSITION 0, NORMAL 0, BLENDINDICES 0, TEXCOORD 0, TEXCOORD 1, TANGENT 0
Bundled v10: POSITION 0, NORMAL 0, BLENDINDICES 0, TEXCOORD 0, TANGENT 0
Skinned v11: POSITION 0, NORMAL 0, BLENDWEIGHT 0, BLENDINDICES 0, TEXCOORD 0, TANGENT 0Static: the village house#
townhousemedium_e_03 stands nine times in Heroes' village. Its CON pairs the render mesh and the collision mesh under one name, and its tweak sets the LOD distances:
GeometryTemplate.create StaticMesh townhousemedium_e_03
CollisionManager.createTemplate townhousemedium_e_03
ObjectTemplate.create SimpleObject townhousemedium_e_03
ObjectTemplate.collisionMesh townhousemedium_e_03
ObjectTemplate.geometry townhousemedium_e_03
GeometryTemplate.setSubGeometryLodDistance 0 0 15
GeometryTemplate.setSubGeometryLodDistance 0 1 30
GeometryTemplate.setSubGeometryLodDistance 0 2 70
LOD selection (bf2-render objlod.rs): the distance to the object minus its radius is compared with the switch distances times the quality option (0.5 / 0.8 / 1.0) and renderer.globalStaticMeshLodDistanceScale; distances the tweak does not set default to steps of 25 m (bundled: 50 m).

- Collision mesh. A second file,
meshes/<name>.collisionmesh, read by bf2-collisionCollisionMesh::parse: geometries, sub-geometries and LODs again, but each LOD is a collision type (0-2 projectile / vehicle / soldier by community naming, 3 the AI navigation mesh), with per-face materials thatObjectTemplate.mapMaterialmaps to the game's material ids, and an optional BSP for fast ray tests. The house has two: type 0 with 1551 faces and a coarse type 1. - Lightmap UVs. Static meshes carry one more
TEXCOORDset than their textures need; the last set places the triangle in the level's lightmap atlas (bf2-meshMeshFile::texcoordsdoc, bf2-renderstaticmesh.rs). The tweak'sdoNotGenerateLightmaps 0keeps the house in the editor's lightmap bake (the bake itself: level editor plan).
Bundled: the Heroes jeep#

A bundled mesh moves in rigid parts: the vertex's first BLENDINDICES byte names its part, and the engine passes one matrix per part (setPartTransform; bf2-render bundledmesh.rs module doc). The jeep's steering wheel, wheels and suspension are parts of geometry 1; the CON's RotationalBundle and Spring children turn and move them. With more than one geometry the renderer's default is geometry 1 (bf2-render bundledmesh.rs, "Default geom").

Skinned: a hero body#

A Heroes hero has no body mesh of its own: the customization manager builds one from the player's items, each a skinned mesh under Objects/Items/<British|German>/<item>/Meshes/ (bfh-client hero_mesh.rs, notes/bfheroes client.md "Tints and mesh rules"). Each vertex has two bone indices and one weight (BLENDWEIGHT x for the first bone, 1 - x for the second; bf2-mesh MeshFile::blend_weights). A material's rig lists the skeleton bone ids its indices refer to and the inverse bind pose per bone; the renderer draws bone id with rig matrix * skeleton[id] (bf2-mesh RigBone, bf2-render skinned.rs). The skeleton itself is the soldier's .ske (british_male_soldier.ske), shared by every item, which is why items made separately fit together; how it is posed is on animations.
How it is tested#
- Every shipped mesh parses (
crates/bf2-mesh/tests/retail.rs): every render mesh in every archive is read, the parse must consume all bytes and its ranges must be consistent. - Written back identical (
write_heroes.rs): for every static, bundled and skinned mesh of the Heroes install, writing the parsed mesh gives the file back byte for byte. - Without an install (
synthetic.rs): hand-built files exercise every version branch of the readers. - The viewer's mesh on this wiki is a shape of the wiki's own, decoded by the collision crate's decoder; the wiki's test compares the committed JSON with the script's shape.
Where it is read and drawn#
| Step | bf2-rs |
|---|---|
| parse the three kinds | bf2-mesh template.rs MeshFile::parse, decl.rs vertex elements |
| collision | bf2-collision lib.rs CollisionMesh::parse |
| LOD choice | bf2-render objlod.rs, skinned.rs select_lod |
| draw | bf2-render staticmesh.rs, bundledmesh.rs, skinned.rs (shader choice: materials) |
| hero bodies | bfh-client hero_mesh.rs |
The draw order and passes are on the render pipeline page; the textures the materials name are on textures; the archives the files come from on archives.
docs/dev/assets/mesh.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.