On this page
Assets and file formats
Every asset the three games ship is read by a bf2-rs crate that mirrors the original loader. This page is the map: which crate reads which file, and where its layout is written down. The three games share the formats; where a later game changed one, the crate handles both.
What goes into a game asset#
A jeep in Battlefield Heroes is not one file. It is a CON template tree that names a mesh, a collision mesh, textures, sounds and child objects, each read by its own loader. These pages take one real example of each kind from the Heroes 1.126 install and show what the engine reads, with pictures our own readers drew:
_b / _de / _w conventions, alpha, the hero atlas and colour tables.MaterialsEffect, technique and texture slots of each draw batch, and how the renderer picks its shader.SoundsSound templates, WAV and Ogg samples, envelopes and the 3D distances.ObjectsThe template tree of the village jeep spawner: geometry, collision, components, children and the files behind each line.LevelsA level on one screen, and where the level formats are documented in full.AnimationsSkeletons and bone animations: run-length tracks, the 24 fps sampler, layer blending, a hero's cheer emote.ArchivesZip archives, mount points, the _server / _client split, loose files, and the overlay and packs bf2-rs adds.Flash menusThe SWF / .dfm menu movies, their natives, and a Heroes main menu frame drawn by our player.TerrainHeightmaps, the patch grid of terraindata.raw, colour, detail, low-detail and light maps, compiled roads.EffectsEffect bundles and particle systems from the .tweak, the emitter tree and an animated sprite atlas.Where the files come from#
The games read their content through a virtual file system: the .zip archives of the install (and of a mod), mounted in a fixed order, plus loose files on disk. crates/bf2-fs reimplements that file manager (FileManager, ZipArchive, Win32FileSystem), so a path resolves to the same archive entry as in the original. The browser build reads the same tree from published content-addressed objects through crates/bf2-webfs (WebVfs), mounted into bf2-fs through its platform hook.
Formats and their readers#
| Files | What they hold | Reader | Notes |
|---|---|---|---|
*.zip, loose files | the archives and the mount order | crates/bf2-fs | notes/subsystems/filesystem.md, archives |
.staticmesh, .bundledmesh, .skinnedmesh | render meshes: buildings, vehicles, soldiers | crates/bf2-mesh (MeshFile) | notes/formats/meshes.md, meshes |
road .mesh | compiled road meshes | crates/bf2-mesh (RoadMesh) | notes/formats/road-splines.md |
.collisionmesh | collision geometry per LOD | crates/bf2-collision | notes/formats/collisionmesh.md |
.occ, Roads/Splines/*_compiled.dat | occluder planes, road template data | crates/bf2-geomdata | notes/formats/occluders.md |
.dds | textures (3D, HUD, fonts) | crates/bf2-texture | notes/formats/textures.md, textures |
.ske, .baf | skeletons and bone animations | crates/bf2-anim | notes/formats/animation.md, animations |
.fx | the D3D9 effect sources the renderer compiles | crates/bf2-shaders | materials |
.wav, .ogg, .eax | sounds, music, reverb presets | crates/bf2-audio, crates/bf2-vorbis | notes/formats/audio.md, sounds |
.dif, .font | bitmap fonts of the HUD, menus and console | crates/bf2-font | notes/formats/fonts.md |
.bik | intro and menu movies | crates/bf2-bink | notes/formats/bink.md |
.swf, .dfm | Flash menus (SWF 7, ActionScript 2) | crates/bf2-ui, Heroes natives in crates/bfh-ui | notes/subsystems/menu-flash.md, Flash menus |
.con, .tweak, .inc | object templates and settings | crates/bf2-con, crates/bf2-objects | The CON system, objects |
effect .tweak, particle textures | effect bundles and particle systems | crates/bf2-effects, crates/bf2-render | notes/subsystems/effects.md, effects |
heightmaps, terraindata.raw, .tai | terrain and level data | crates/bf2-terrain, crates/bf2-world | notes/formats/terrain.md, terrain, Level authoring, editor plan, levels |
How the pictures are made#
Every picture on the asset pages is generated by tools/devwiki/asset_examples.py from the retail Heroes archives (read-only) through the bf2-rs readers the game itself uses, run as small cargo examples:
| Asset | Reader (crate / file / function) | Example tool |
|---|---|---|
.staticmesh .bundledmesh .skinnedmesh | bf2-mesh template.rs MeshFile::parse | crates/bf2-mesh/examples/mesh_json.rs |
.collisionmesh | bf2-collision lib.rs CollisionMesh::parse | crates/bf2-collision/examples/collision_json.rs |
.dds .tga | bf2-texture dds.rs Dds::parse, decode.rs decode_rgba8, lib.rs decode_d3dx | crates/bf2-texture/examples/texture_mips.rs |
.wav .ogg, envelopes | bf2-audio soundfile.rs load (Ogg through bf2-vorbis), envelope.rs Envelope::eval | crates/bf2-audio/examples/sound_pcm.rs |
| templates, placed objects | bf2-editor level.rs LevelData::object_json / template_json | bf2_editor --object / --template |
.ske .baf | bf2-anim ske.rs Skeleton::parse, baf.rs BoneAnimation::decode, sample.rs Clip::sample, pose.rs SkeletonPose::update_world | crates/bf2-anim/examples/anim_json.rs |
| archives, mount order | bf2-fs startup.rs mount_mod / load_level_archives / mount_level_init_archives, manager.rs FileManager::open | crates/bf2-fs/examples/mount_json.rs |
.dfm .swf menus | bf2-ui swf.rs decode_dfm, the Ruffle-based player walkthrough.rs Session::screenshot | crates/bf2-ui/player/examples/menu_frame.rs |
heightmaps, terraindata.raw, patch textures, roads | bf2-terrain heightdata.rs apply, terraindata.rs parse, terrain_con.rs naming; bf2-mesh road.rs RoadMesh::parse | crates/bf2-terrain/examples/terrain_layers.rs, mesh_json.rs |
| effect templates, sprite atlases | bf2-editor LevelData::template_json, bf2-texture decode_rgba8 | bf2_editor --template, texture_mips.rs |
Python only lays the results out (numpy and matplotlib). The script has no clock and writes PNGs without a date, so a re-run produces the same bytes; --check proves it:
python tools\devwiki\asset_examples.py # writes docs\dev\assets\img\*
python tools\devwiki\asset_examples.py --check # re-runs into a temp folder and compares
python tools\devwiki\build.py # the wiki, with the pictures copied next to the pagesThe examples: the village house townhousemedium_e_03, the Heroes jeep bri_jeep_willys, a royal hero's default items (BRI_M_Head001, BRI_M_Body001, ...), the hero skeleton with the cheer emote, the mount table of village_snow, the main menu mainMenu_west.dfm, the terrain of village and the explosion e_exp_medium. The menu frame needs the player's own cargo workspace (crates/bf2-ui/player, Ruffle in third_party/ruffle-bf2). How the renderer draws them frame by frame is the subject of the render pipeline page; the scripts that create them are the CON system.
How it is tested#
This page explains; it holds no code of its own. Each format's page says how its reader is tested: archives, meshes, textures, terrain, animation, sound. The common pattern: every shipped file of the kind is read and must be consumed exactly, and where the port also writes the format, writing a parsed file gives the file back byte for byte. The wiki's test checks that every link and anchor on it leads to a page of the build and that its diagrams are the ones the script draws.
In the code#
The crates this page names, each with its line of docs/release/LAYOUT.md (the list is gathered by the wiki's build from the page itself):
| Crate | What it is |
|---|---|
crates/bf2-fs | the engine's file system: file manager, archives |
crates/bf2-mesh | render mesh files (static, bundled, skinned, roads) |
crates/bf2-ui | the Flash front-end menus: native interface and host model |
crates/bf2-anim | skeletons, bone animations and the animation system |
crates/bf2-audio | the sound system: decoders, sound templates, mixing rules |
crates/bf2-collision | collision mesh files |
crates/bf2-terrain | terrain and level data formats |
crates/bf2-texture | texture files and texture atlases |
Files this page names: crates/bf2-mesh/examples/mesh_json.rs, crates/bf2-collision/examples/collision_json.rs, crates/bf2-texture/examples/texture_mips.rs, crates/bf2-audio/examples/sound_pcm.rs, crates/bf2-anim/examples/anim_json.rs, crates/bf2-fs/examples/mount_json.rs, crates/bf2-ui/player/examples/menu_frame.rs, crates/bf2-terrain/examples/terrain_layers.rs.
docs/dev/assets/index.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.