OpenBF1942-Plus
Refractor 1, rebuilt from scratch
Loading...
Searching...
No Matches
SM static mesh format

Status: verified — tools/sm.py parses all 2,527 .sm files in bf1942, XPack1 and XPack2; every index is in range. Visually checked on a bunker and the Willys jeep.

Little-endian. Strings are u32 length + bytes, no terminator.

Layout

Field Notes
u32 version 9 or 10
u32 always 0
f32 bbox[6] min xyz, max xyz
u8 v10 only; 0 or 1, meaning unknown
u32 ncol collision meshes: 0, 1 or 2
ncol × { u32 size, size bytes } collision blocks, see below
u32 nlod LOD count; trailing LODs can be empty (nmat = 0)
per LOD u32 nmat, then nmat material headers, then the data of each material in header order

Material header:

Field Values seen
name <mesh>_MaterialN, matches a subshader in the .rs file
3 × u32 always 0
u32 primitive Direct3D primitive type: 4 = triangle list, 5 = triangle strip (first-person and face meshes)
u32 fvf 0x411 (stride 32) or 0x2411 (stride 40)
u32 stride 32: pos, normal, uv · 40: pos, normal, uv, lightmap uv (all f32; lightmap use verified, see terrain.md)
u32 nverts, u32 nindices
u32 alpha 0, 1, 2, 4, rarely 9, 12; meaning unknown

Material data: nverts × stride bytes, then nindices × u16.

After the last LOD: a footer, 62 bytes in most files, longer in 288 files where it seems to hold another mesh section. Not decoded.

Collision block

Verified on all 1,718 .sm blocks and the 97 .tm blocks of the three mods (tools/sm.py parse_collision).

Field Notes
u32 magic 0xEB97C2FA (bytes fa c2 97 eb)
u32 version 5
u32 nverts, nverts × 16 bytes f32 x, y, z, u16 material, 2 bytes padding (stale data)
u32 nfaces, nfaces × 8 bytes u16 a, b, c, u16 material
tree spatial index over the faces, ends with an embedded <mesh>.sgf name; not decoded

Materials are MaterialManager ids (92 distinct values in use). 473 base-game meshes have two blocks. In 220 of the 230 two-block meshes the bf1942 mod loads, the first is far coarser than the second (the suburbhouse_* AI meshes: 2 faces against about 550). The second is the one that stops soldiers and vehicles (RefractorForge's in-game test in BF1942 and BF Vietnam, references.md; not checked by us in the game), so static collision uses the last block. What the first is for is open.

Coordinates

Direct3D convention, left-handed. The OBJ export negates z and reverses the winding.

Shader file (.rs)

Text, next to the mesh (standardMesh/x.sm → standardMesh/x.rs):

subshader "<material name>" "StandardMesh/Default"
{
lighting true;
materialDiffuse 1 1 1;
texture "texture/defgun_Stuff_s";
}

texture has no extension; the file is .dds or .tga in the VFS. Other keys seen: lightingSpecular, materialSpecular, materialSpecularPower, envmap, twosided, transparent, textureFade, depthWrite, alphaTestRef, blendSrc, blendDest.