RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Editor AI TestsEditor AI VisualizationEditor – Assembly Spline ToolAsset BrowserAsset DeduplicatorAsset Management ToolSFX Previewer (Audio Events List)Audio Ribbon EditorAutoSaveBarriers EditorBiome ToolBuilding EditorBulk RenameCamera BookmarksCamera TransformCamera Path EditorCEF HelperCo-Simulation Signal EditorCrawl Data EditorCreate Object ToolDataBlock EditorDecal EditorDecal Spline EditorDocumentation HelperDrag Race EditorDrift Data EditorDrive Path EditorDynamic Decals Tool (Vehicle Livery Creator)Engine Audio DebugExtensions DebugExtensions EditorFFI Pointer Leak TestFile DialogFlowgraph EditorForest EditorForest ViewEditor Gizmo HelperEditor Ground Model Debug HelperEditor Headless Editor TestEditor Icon OverviewEditor ImGui C DemoEditor InspectorEditor Layout ManagerEditor Level SettingsEditor Level ValidatorEditor LoggerEditor Log HelperEditor MainEditor Main MenuEditor Main ToolbarEditor Main UpdateMap Sensor EditorMaster Spline EditorMaterial EditorMeasures Inspector HeaderMesh Editor (Base)Mesh Road EditorMesh Spline EditorMission EditorMission PlaybookMission Start Position EditorMulti Spawn Manager (Vehicle Groups)Navigation Mesh EditorEditor News MessageObject Tool (Object Select Edit Mode)Object To Spline EditorParticle EditorPerformance Profiler / Camera RecorderPhysics ReloaderPrefab Instance EditorEditor PreferencesRace / Path EditorRally EditorRaycast Test Editor ToolRenderer Components Editor ToolRender Test Editor ToolResource Checker Editor ToolRiver EditorRoad Architect EditorRoad DecorationsRoad Editor (Decal Road)Road Network ExporterRoad River Cache HandlerRoad River GUIRoad Spline EditorRoad Template EditorRoad UtilitiesScene TreeScene ViewScreenshot Creator BootstrapScript AI EditorScript AI ManagerSensor Configuration EditorSensor DebuggerShape EditorShortcut LegendSidewalk Spline EditorSites EditorSlot Traffic EditorSuspension Audio DebugTech Server ManagerTerraform ToolTerrain And Road ImporterTerrain EditorTerrain Materials EditorText EditorTool ManagerTool ShortcutsTraffic DebugTraffic ManagerTraffic Signals EditorUndo History ViewerVehicle Bridge TestVehicle Detail ViewerVehicle Editor MainEditor - VisualizationEditor Viz HelperEditor Water Object HelperEditor Windows Manager
Gen Decal EditorGen Experimental Frame EditorGen Mesh ExplorerGen Experimental SolidFlexGen Mesh ModuleGen Network ModuleGen Region ModuleGen Render ModuleGen Terrain ModuleEditor Gen TestEditor Gen Top (Roof Geometry)Editor Gen UI (Building Architect UI)Editor Gen UtilsEditor Gen World

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionseditorgen

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

AspectDetail
Fileextensions/editor/gen/top.lua
ReturnsTop table
Requireseditor/gen/utils, editor/gen/mesh
InjectedWorld module via Top.inject(w)

Public Functions

FunctionSignatureDescription
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

ConceptDescription
Parallel pairsOpposite edges of a polygon that are approximately anti-parallel (angle ≈ π)
Ridge lineCenterline between parallel pairs, elevated by tip parameter
GableTriangular end-cap where ridge meets non-paired edges
Flat childrenNon-ridged polygon sections that receive flat or recursive roof treatment
ChunksConvex 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-edge
  • forChunks(base) - Iteratively chops until all pieces are convex
  • pairsUp - Scans all edge pairs for anti-parallel alignment within small_ang tolerance, validates no crossing bounds
  • stick(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

On this page

Module OverviewPublic FunctionsRoof Generation PipelineGeometry ConceptsInternal AlgorithmSee Also