RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
ui/ambientSound - Ambient Sound Stream PlayerUI Apps ManagerUI AudioBindings LegendCamera Distance AppConsole (consoleNG)Credits MusicExternal App (WebSocket UI Server)Fade ScreenGame BlurGameplay App ContainersGrid SelectorLivery EditorMessages DebuggerMessages/Tasks App ContainersMission InfoPolice InfoTop BarUI ModsUI Navigation / MapVehicle Paint EditorVehicle Vicinity AppUI Visibility
Generic Mission Data AppPoints Bar App
Minimap Additional InfoMinimap LayersMinimap (Main)Minimap RoadsMinimap RouteMinimap Topographic MapMinimap UtilitiesMinimap Vehicles

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsuiappsminimap

Minimap Topographic Map

Generates and renders topographic contour lines from terrain heightmap data.

Generates and renders topographic contour lines from terrain heightmap data.


Overview

ui_apps_minimap_topomap scans the terrain heightmap, generates contour lines via marching squares, and builds a spatial index for efficient rendering on the minimap background.

Extension path: lua/ge/extensions/ui/apps/minimap/topomap.lua


Exports (M)

FunctionSignatureDescription
loadTopoMap() → boolLoads terrain, generates contours. Returns false on failure.
isLoaded() → boolWhether the topo map has been generated.
getHeightmapData() → tableReturns raw heightmap grid data.
getHeightmapBounds() → tableReturns {minX, maxX, minY, maxY} bounds.
getContourSegments() → segment[]Returns array of {level, x1, y1, x2, y2} segments.
getContourQuadtree() → kdtreebox2dReturns spatial index for contour segments.
drawContours(td, w, h, scale, camPos, worldToMapXYZ)Renders visible contour lines on the minimap.

Internals

Loading Pipeline

loadTopoMap() executes three steps:

  1. Calculate bounds - Uses navgraph node positions to determine terrain area (capped at ±2000m)
  2. Scan heightmap - Samples core_terrain.getTerrainHeight() on a 5m grid
  3. Generate contours - Runs marching squares at 2.5m intervals, builds kd-tree index

Marching Squares

Classic cell-based contour extraction. For each grid cell, the four corner heights are compared against each contour level to determine edge intersections:

-- Cell corners classified as above/below contour level
local caseIndex = 0
if d00 >= zc then caseIndex = caseIndex + 1 end
if d10 >= zc then caseIndex = caseIndex + 2 end
if d11 >= zc then caseIndex = caseIndex + 4 end
if d01 >= zc then caseIndex = caseIndex + 8 end
-- Cases 0 and 15 = no intersection

Each intersection produces a line segment stored as {level, x1, y1, x2, y2}.

Rendering

drawContours queries the kd-tree for segments near the camera, transforms to minimap coords, and draws with brightness proportional to elevation:

local clr = color(128 + level*1.25, 128 + level*1.25, 128 + level*1.25, 255)
local thickness = 1 + (level%10 == 0 and 0.5 or 0)  -- major contours thicker

Rendering is capped at 5000 segments per frame for performance.

Reset

Topo data is cleared on onClientEndMission and onClientStartMission, requiring re-generation per level.


How It Works

  1. Minimap calls loadTopoMap() to generate contour data from terrain
  2. Marching squares produces thousands of line segments at 2.5m elevation intervals
  3. Segments are indexed in a kd-tree for spatial queries
  4. Each frame, drawContours renders nearby segments with elevation-based brightness
  5. Major contour lines (every 10m) are rendered slightly thicker

Additional Exports

The following exports are available but not yet documented in detail:

  • M.drawContours
  • M.getContourQuadtree
  • M.getContourSegments
  • M.getHeightmapBounds
  • M.getHeightmapData
  • M.isLoaded
  • M.loadTopoMap
  • M.onClientEndMission
  • M.onClientStartMission

Minimap Route

Renders the navigation route and off-screen route pointer on the minimap.

Minimap Utilities

Coordinate transforms, drawing helpers, color sets, and boundary clamping for the minimap.

On this page

OverviewExports (M)InternalsLoading PipelineMarching SquaresRenderingResetHow It WorksAdditional Exports