API ReferenceGE ExtensionseditortechroadArchitect
Road Architect - Road Mesh
Generates procedural meshes for roads including sidewalks, curbs, and bridges using the Road Architect system.
Generates procedural meshes for roads including sidewalks, curbs, and bridges using the Road Architect system.
Module Overview
editor/tech/roadArchitect/roadMesh creates ProceduralMesh objects for road surfaces, sidewalk/curb pairs, and bridges. It handles vertex generation, UV mapping, face construction, normals, and end caps.
Public API
| Function | Signature | Description |
|---|---|---|
M.createRoad | (r, roadMeshIdx, folder) | Creates all procedural meshes for a road (sidewalks+curbs per section) |
M.tryRemove | (roadName) | Removes all meshes for the given road name from the scene |
M.updateBridge | (r, folder) | Creates/updates a bridge procedural mesh for the given road |
M.tryRemoveBridge | (roadName) | Removes the bridge mesh for the given road name |
M.clearBridges | () | Clears the internal bridges structure |
Key Internals
| Item | Description |
|---|---|
computeSections(r) | Identifies lateral sections of road by lane type (road_lane, sidewalk) |
createLeftSidewalkKerb | Builds left-facing sidewalk + curb procedural mesh with end caps |
createRightSidewalkKerb | Builds right-facing sidewalk + curb procedural mesh with end caps |
materials | Default material table: m_asphalt_new_01, slabs_large, m_sidewalk_curb_trim_01 |
Code Example
local roadMeshMgr = require('editor/tech/roadArchitect/roadMesh')
-- Create procedural meshes for a road inside a scene folder
local folder = createObject("SimGroup")
folder:registerObject("Road Architect - Road 1")
scenetree.MissionGroup:addObject(folder)
roadMeshMgr.createRoad(road, 1, folder)
-- Create a bridge mesh
roadMeshMgr.updateBridge(bridgeRoad, folder)
-- Remove all meshes for a road
roadMeshMgr.tryRemove(road.name)
-- Remove a bridge
roadMeshMgr.tryRemoveBridge(road.name)
-- Clear all bridges
roadMeshMgr.clearBridges()
-- Mesh structure internals:
-- Each ProceduralMesh is created with:
-- surfaceMesh = { verts, faces, normals, uvs, material }
-- endCaps = { verts, faces, normals, uvs, material }
-- The mesh is registered, placed at origin, with scale = vec3(1,1,1)
-- Bridge mesh uses ring topology:
-- 1. Compute ring of points around cross-section (top + bottom face vertices)
-- 2. Extrude along road length with parabolic arch: dZ = -4*(h+d)*q^2 + 4*(h+d)*q - d
-- 3. Add end caps for each lane pair
-- UV mapping for sidewalks uses kerb-specific v-ranges:
-- kVStart is based on profile vStart, scaled by 0.2
-- Each curb sub-section uses v offsets of 0.1 with a small gap (kerbVGap = 0.00332)
-- Ray casting is used to snap sidewalk vertices to terrain:
-- p.z = p.z - castRayStatic(p, downVec, 1000)
-- A "raised" offset of vec3(0,0,4.5) is applied before castingDependencies
| Module | Purpose |
|---|---|
editor/tech/roadArchitect/utilities | slerp, misc utilities |
See Also
- Road Architect - Clothoid - Related reference
- Road Architect - Decals - Related reference
- Road Architect - Export - Related reference
- World Editor Guide - Guide