Road Architect - Import
Handles deserialization and import of Road Architect road data from JSON files. Reconstructs road structures (nodes, profiles, layers, groups, junctions) and initializes render state.
Handles deserialization and import of Road Architect road data from JSON files. Reconstructs road structures (nodes, profiles, layers, groups, junctions) and initializes render state.
Public Functions
| Function | Signature | Description |
|---|---|---|
M.import | (...) | Imports road data from JSON |
Example: Importing Road Data
local import = require('editor/tech/roadArchitect/import')
-- Import all roads from file
local data = import.importRoads('/levels/myLevel/roads.roadArchitect.json')
-- Returns: { roads, groups, junctions, prefabs }
local roads = data.roads
local groups = data.groups
-- Import a single road template
local road = import.importSingleRoad('/templates/highway.json')
-- Data migration handles version differences
local migrated = import.migrateData(oldFormatData)
-- After import, each road needs geometry computation:
for i = 1, #roads do
import.initRoadDefaults(roads[i])
geometry.computeRoadRenderData(roads[i])
geometry.createRoadMesh(roads[i])
end
-- Deserialization converts:
-- - Array [x, y, z] → vec3 positions
-- - Raw numbers → ImGui pointer wrappers
-- - Flat layer data → nested profile/layer structures
-- - String references → index lookupsNotes
- Paired with
export.luafor saving - Version migration ensures backward compatibility
- ImGui pointer values (booleans, ints, floats) are re-wrapped on load
See Also
- Road Architect - Clothoid - Related reference
- Road Architect - Decals - Related reference
- Road Architect - Export - Related reference
- World Editor Guide - Guide
Road Architect - Groups
Manages road groups in the Road Architect. Groups allow batch operations (terraforming, visibility, profiles) across multiple roads defined by a perimeter polygon or manual selection.
Road Architect - Junctions
Manages road junctions (intersections) in the Road Architect. Handles junction creation from road endpoints/midpoints, topology computation, lane connection mapping, and junction road generation.