API ReferenceGE ExtensionseditortechroadArchitect
Road Architect - Tunnel Mesh
Creates procedural auto-tunnel meshes and manages terrain hole maps for tunnels in the Road Architect system.
Creates procedural auto-tunnel meshes and manages terrain hole maps for tunnels in the Road Architect system.
Public API
| Function | Signature | Description |
|---|---|---|
M.createTunnel | (roadIdx, name, rData, tunnel, folder) | Creates a procedural tunnel mesh and pierces terrain holes |
M.tryRemove | (roadIdx, name) | Removes tunnel mesh and recovers terrain holes |
Code Example
local tMesh = require('editor/tech/roadArchitect/tunnelMesh')
-- Create a tunnel for road 1
local tunnel = road.tunnels[1]
tMesh.createTunnel(1, tunnel.name, road.renderData, tunnel, folder)
-- Remove the tunnel and recover holes
tMesh.tryRemove(1, tunnel.name)
-- Tunnel parameters (from road):
-- tunnel.s, tunnel.e - start/end div point indices
-- tunnel.radGran - radial granularity (cross-section segments)
-- tunnel.radOffset - radius offset beyond road width
-- tunnel.thickness - wall thickness
-- tunnel.zOffsetFromRoad - vertical offset of road inside tunnel
-- tunnel.protrudeS/E - protrusion at start/end along tangent
-- Mesh generation algorithm:
-- 1. Compute pipe center, radius, tangent at each longitudinal point
-- 2. Generate inner and outer ring points using Rodrigues rotation
-- 3. Build inner/outer face arrays with proper winding
-- 4. Add start and end cap geometry
-- 5. Create ProceduralMesh with {outer, inner, startCap, endCap}
-- Hole map management:
-- editHolemap: Sets terrain material index to 255 for grid cells inside pipe
-- recoverHolemap: Restores original material indices when tunnel removed
-- Uses squared-distance-to-line-segment test for pipe intersection
-- Plane clipping at tunnel ends prevents over-extension
-- Material: 'm_asphalt_new_01' for all tunnel surfacesDependencies
| Module | Purpose |
|---|---|
editor/tech/roadArchitect/utilities | rotateVecAroundAxis |
See Also
- Road Architect - Clothoid - Related reference
- Road Architect - Decals - Related reference
- Road Architect - Export - Related reference
- World Editor Guide - Guide