Generating Trackmania 2020 maps with GBX.NET
trackmaniagbxgbx-netdotnetprocedural-generationmap-editorterrain
Trackmania 2020 maps (.Map.Gbx) can be written by a program instead of placed by hand in the
editor. The working recipe is: take a real map as a template, load it with the .NET library
GBX.NET, wipe its track, place blocks and items from a generated list, and save it under a new
UID. A Python "turtle" describes the route, a small C# program writes the file, and the game's own
editor does the last steps (shadows, validation). Five maps were built this way in October 2026,
from a flat stadium sprint to a fully sculpted island; this page records the file-format facts and
the mistakes that cost an in-game round trip each.
Pipeline
- Describe the track in Python as a turtle: "straight 6, curve right radius 3, ramp, ..." The
turtle tracks position, heading and height, emits one row per block
(
name x y z dir [isGround] [variant] [subvariant]), checks overlaps and map bounds, and can print an ASCII or PIL top-down preview. A separate pass writes scenery items (model x y z yaw [collection] [author]). - Write the map in C# with GBX.NET (
Gbx.Parse<CGameCtnChallenge>): remove blocks, baked blocks and anchored objects,PlaceBlock/PlaceAnchoredObjectfor every row, clear the medal times and MediaTracker clips, set a fresh 27-characterMapUid,MapName, map typeTM_Race, and copy author fields from a map you own if the template is Nadeo's. - Install by copying the file to
Documents/Trackmania/Maps/My Maps/(under Proton that is insidesteamapps/compatdata/2225070/pfx/drive_c/users/steamuser/). - Finish in the game: open it in the editor, Compute Shadows (sun icon), drive it to validate (sets the author time), save. Only validated, saved maps show under Play → Local → Against the Clock → My Maps.
GBX.NET 2.4.5 needs the LZO package (Gbx.LZO = new Lzo()) and the .NET 8 SDK. A user-level
install in ~/.dotnet works without root; add it to PATH.
Learn the conventions from real maps
Block names, directions and footprints are not documented. The reliable source is the game's own
map cache (ProgramData/Trackmania/Cache inside the Proton prefix), which holds dozens of
Nadeo campaign maps. A "miner" that dumps every cached map's blocks and items to TSV answers most
questions; strings inside the .pak files confirm that a block exists even when no cached map
uses it. Facts mined this way:
- Direction: N=0 is +z, E=1 is -x, S=2 is -z, W=3 is +x. Start, finish, straights, turbos and
ramps point along the driving heading.
- A CurveK block with direction d connects sides d and d+1, occupies K x K cells anchored at
the minimum corner, and each connection cell sits at the corner of its edge farthest from the
other side.
- Transitions AToB point toward B (RoadTechToRoadDirt, RoadTechToRoadIce faces the heading
when entering ice and the opposite heading when leaving).
- Slopes: SlopeStart2x1 + SlopeStraight x n + SlopeEnd2x1 climbs n+2 levels; direction is
uphill, the coordinate is the footprint's minimum corner at the lower level. Elevated road needs
StructurePillar stacks down to the ground (bottom one isGround).
- Stadium item coordinates: world X = bx32+16, Z = bz32+16, ground Y = 8 for block y = 9.
On island maps flat ground at level h has item Y = 8h-118. Nadeo free-places island trees with
BlockUnitCoord 255,255,255; do the same.
- Items on hills need the ground height between cells: take each cell corner as the max block level
of its four neighbors and interpolate bilinearly. Checked against 760 Nadeo trees: exact on flat
land, median error 0 m on hills.
Island environments and terrain
The 64x64 islands (White Shore, Red Island, Green Coast, Blue Bay) have no stadium. Terrain is
made of ordinary per-cell blocks (Land, LandHillN, water and shore blocks on White Shore;
DirtHill2, DirtCliff4/8/16 and friends on Red Island), so it can be either kept or written.
- Keep the terrain of a cached Nadeo map (drop everything except terrain blocks) and lay a road
over it: quick, and the mountain is already good-looking.
- Sculpt the terrain around the road: design heights on a lattice of supported levels
(for Red Island 14 sea, 15 beach, 17, 19, 23, 27, 35; even levels are water), lock the cells under
the road, legalize the rest so neighbors differ by supported steps, and pick each cell's block
from its four corner levels. Rules mined from five Nadeo maps reproduced four of them at
99.6 to 99.9 percent. Ground roads then sit on the terrain (isGround, hill road blocks like
Road*OnDirtHill2SlopeBase2 climb 2 levels per cell) with no pillars.
- Custom items (community volcanoes, pyramids and so on) can be embedded: zip each
.Item.Gbx into the map as Items/<path> and reference it with collection 26 and the creator's
login, which must equal the author stored inside the item file. Cached maps' embedded zips are a
source of such items.
Gotchas
- Never build an Ident's collection from a string. Items and decoration placed with collection
"Stadium2020"made the game refuse the map: "Couldn't load map! Missing Resources ... (in Unknown Collection)", with every item listed as missing. Real maps store the numeric id (26 for Stadium). Copy the collection from the template's decoration. - Templates carry their time of day. Every map built on a White Shore template came out
pitch dark because Nadeo's map had
DayTime02:24:01, which is night. Set it explicitly (12:06:00 noon, 14:33:50 afternoon, both Nadeo presets) and turn off dynamic daylight. - Templates carry their zone genealogy. Each map stores a per-cell terrain history
(
ZoneGenealogy, chunk 0x03043043, indexed x*64+z: base zone, then each raise, current zone, variant, direction). After replacing terrain, a stale genealogy made the game draw terrain and bushes over ground roads, so the car drove "under" the road. Deleting the chunk made terrain slabs float over the sea. The fix is to regenerate it from the new terrain; the derivation matched all 22,892 terrain cells of five Nadeo maps. - Lightmaps go stale. A generated map keeps the template's lightmap, and the game says you must compute shadows before playing. That is expected; compute them in the editor.
- GBX.NET 2.4.5 cannot parse the 2026 lightmap chunk 0x0304305B. Skip it with
GbxReadSettings.SkipChunkIds; it is kept raw and written back unchanged. - Clear baked blocks after removing blocks; the editor regenerates them.
- Jumps are the riskiest part of a blind build: keep 7 or more straight cells of runway after a ramp, keep the landing zone at landing height, and keep scenery out of the gap.
- Item yaw sign and model facing are easy to get wrong; place facing-critical items at yaw 0 or pi until checked.
- Editor keyboard shortcuts are not in the Proton config files (
Default.json, profile Gbx), and guessing them is worse than telling the player to read the tooltip.
Checking without a human
- Render a top-down preview (terrain, road, items) from the TSVs with PIL, and for a real look, rebuild the scene in headless Blender (EEVEE renders aerial and driver's-eye shots in seconds).
- The game itself can be driven over X11: launch with
steam steam://rungameid/2225070on the rightDISPLAY, click through menus with python-xlib's XTEST extension, and take screenshots. The game's map list caches file names, so overwriting an already-listed file is the quickest way to retest. - A second agent reviewing the design found real problems (a jump crossing a ridge, plants growing in jump gaps, a landmark floating at the coast) before any in-game test.
See also
- Trackmania (2020) on Linux via Steam and Proton, plus the TICK TAS tool
- Road-graph map pipeline (author roads, generate the rest)
- Blender Python scripting, safety audit and gotchas
- Deterministic seeds for procedural worlds