Editor Gen Top (Roof Geometry)
Roof geometry generation module for the Building Architect Tool. Handles polygon decomposition, parallel-pair detection, ridge/gable/flat roof construction, and triangulated paving of arbitrary polygo
Roof geometry generation module for the Building Architect Tool. Handles polygon decomposition, parallel-pair detection, ridge/gable/flat roof construction, and triangulated paving of arbitrary polygonal bases.
Module Overview
| Aspect | Detail |
|---|---|
| File | extensions/editor/gen/top.lua |
| Returns | Top table |
| Requires | editor/gen/utils, editor/gen/mesh |
| Injected | World module via Top.inject(w) |
Public Functions
| Function | Signature | Description |
|---|---|---|
Top.forRidge | (floor, base, ichild, ishift, ischeck) | Generates ridge roof geometry - finds parallel edge pairs, builds sloped planes, splits non-ridge areas into flat children. Returns success, {av, af, apair} |
Top.forGable | (base, apair, dbg) | Creates gable (triangular end-cap) roof meshes from base polygon and parallel pairs. Returns array of {av, af, an, auv} mesh data |
Top.pave | (base, uvscale, uvini) | Triangulates an arbitrary convex/concave polygon into renderable mesh. Returns av, auv, af, {normal} |
Top.pairsUp | (base, ishift) | Detects parallel edge pairs in a polygon. Returns apair (index pairs), amult (multi-paired edges) |
Top.forChunks | (base) | Decomposes a concave polygon into convex chunks via recursive chopping. Returns array of index arrays |
Top.inject | (w) | Injects the World module reference for debug output access |
Roof Generation Pipeline
local Top = require('/lua/ge/extensions/editor/gen/top')
Top.inject(worldModule)
-- 1. Detect parallel pairs in building footprint
local apair, amult = Top.pairsUp(base)
-- 2. Generate ridge roof
local ok, ridgeData = Top.forRidge(floor, base)
-- ridgeData = {av = vertices, af = faces, apair = pairs}
-- 3. Generate gable end caps
local gableData = Top.forGable(base, apair)
for _, gable in pairs(gableData) do
-- gable.av, gable.af, gable.an, gable.auv
end
-- 4. Pave flat roof sections
local av, auv, af, normals = Top.pave(flatBase)Geometry Concepts
| Concept | Description |
|---|---|
| Parallel pairs | Opposite edges of a polygon that are approximately anti-parallel (angle ≈ π) |
| Ridge line | Centerline between parallel pairs, elevated by tip parameter |
| Gable | Triangular end-cap where ridge meets non-paired edges |
| Flat children | Non-ridged polygon sections that receive flat or recursive roof treatment |
| Chunks | Convex sub-polygons produced by splitting concave shapes at reflex vertices |
Internal Algorithm
chop(base)- Finds a reflex vertex and splits polygon into two pieces at the first valid cross-edgeforChunks(base)- Iteratively chops until all pieces are convexpairsUp- Scans all edge pairs for anti-parallel alignment withinsmall_angtolerance, validates no crossing boundsstick(a, b, c, rw)- Computes gable transition geometry between thin and thick parallel plate sections
See Also
- Gen Decal Editor - Related reference
- Gen Experimental Frame Editor - Related reference
- Gen Mesh Explorer - Related reference
- World Editor Guide - Guide
Editor Gen Test
Internal test/debug module for the Building Architect Tool (BAT) procedural generation system. Contains test routines for mesh generation, DAE export, LOD creation, XML manipulation, and building geom
Editor Gen UI (Building Architect UI)
ImGui-based user interface for the Building Architect Tool (BAT). Provides the main editor windows for building shape selection, scope navigation, material/mesh picking, roof type selection, architect