📚 Encyclopedia

Games & Graphics · updated 2026-10-26

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

  1. 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]).
  2. Write the map in C# with GBX.NET (Gbx.Parse<CGameCtnChallenge>): remove blocks, baked blocks and anchored objects, PlaceBlock / PlaceAnchoredObject for every row, clear the medal times and MediaTracker clips, set a fresh 27-character MapUid, MapName, map type TM_Race, and copy author fields from a map you own if the template is Nadeo's.
  3. Install by copying the file to Documents/Trackmania/Maps/My Maps/ (under Proton that is inside steamapps/compatdata/2225070/pfx/drive_c/users/steamuser/).
  4. 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

Checking without a human

See also

Linked from

Sources: tm-maps memory, tm-maps README and gen/Program.cs, tldr posts #1776 and #1777