API ReferenceGE Extensionseditorgen
Gen Region Module
Region-based procedural urban generation system for buildings, blocks, and road layouts.
Region-based procedural urban generation system for buildings, blocks, and road layouts.
Overview
The region module implements procedural generation of urban regions including building placement, block subdivision, road-side structures, and region boundary logic. It works with the decal road system to generate buildings along road networks with configurable dimensions and spacing.
Module Table: R
| Field | Type | Description |
|---|---|---|
ui.spacing | number | UI spacing constant (3) |
out.apath | table | Output path array |
Generation Parameters
| Parameter | Default | Description |
|---|---|---|
mm_len | {10, 20} | Front wall length interval (min, max) |
mm_depth | {6, 16} | Building depth interval |
mm_space | {1.5, 4} | Space between buildings |
margin | 2 | Edge margin |
Key Functions
| Function | Description |
|---|---|
forMedian(sfr, sto) | Computes median direction vector between two road sides at a junction |
toStem(p, side, tip) | Projects a point onto a road side's stem direction from a corner |
Data Structures
| Variable | Description |
|---|---|
adec | Road decal array |
abase | Base geometry for buildings |
abound | Boundary polygons |
across | Road crossing points |
aswitch | Direction switch points |
anobj | Generated objects |
dn2d | Side index to node-to-depth map |
Dependencies
| Module | Path |
|---|---|
| Utils | /lua/ge/extensions/editor/gen/utils |
Usage Example
local R = require('/lua/ge/extensions/editor/gen/region')
-- The region module works with the decal road system
-- to place buildings along road sides.
-- Junction medians are computed for proper corner geometry:
local dir = forMedian(sideFrom, sideTo)
-- Project a point onto a road side:
local dist = toStem(point, side, 0) -- 0=start, 1=endExported Fields
| Field | Type | Description |
|---|---|---|
R.out | table | Output data including apath |
R.ui | table | UI state with spacing field |
Exported Functions
R.forRoads(p, odec)
Initializes road-side building generation from a position.
p(vec3) - Reference positionodec(table) - Decal module reference
R.populate(acrs, adecal, odec, oworld, cancel, pt)
Populates buildings along road sides within region boundaries.
acrs(table) - Road crossing dataadecal(table) - Decal arrayodec(table) - Decal moduleoworld(table) - World modulecancel(any) - Cancellation flagpt(vec3?) - Optional reference point
R.onUpdate(inj)
Per-frame update callback with injection data.
inj(table?) - Optional injection data
R.onSpacing(v)
Adjusts building spacing parameter.
v(number) - Spacing value
See Also
- Gen Decal - Road/decal generation
- Gen Network - Road network topology
- Gen Terrain - Terrain manipulation