API ReferenceGE Extensionseditorgen
Gen Render Module
Debug rendering utilities for the gen editor framework - paths, points, labels, and circles.
Debug rendering utilities for the gen editor framework - paths, points, labels, and circles.
Overview
The render module provides lightweight debug drawing functions using BeamNG's debugDrawer and FFI-based line batching. It renders paths (polylines), point sets (spheres), text labels, and circles in 3D space. Used throughout the gen editor for visualizing procedural geometry.
Functions
| Function | Signature | Description |
|---|---|---|
Render.graph(apath, c, w, z) | (table, table?, number?, boolean?) | Draws an array of polyline paths |
Render.path(apoint, c, w, dd, z) | (table, ColorF?, number?, boolean?, boolean?) | Draws a single polyline path |
Render.set(set, c, w) | (table, table?, number?) | Draws points as spheres, size scaled by camera distance |
Render.label(list, c, w) | (table, table?, number?) | Draws 3D text labels at positions |
Render.sphere(pos, r, c) | (vec3, number, table) | Draws a sphere scaled by camera distance; c = {r,g,b,a} |
Render.circle(center, r, c, w, dd) | (vec3, number, color?, number?, boolean?) | Draws a circle in the XY plane using line segments |
Local Helpers
| Function | Description |
|---|---|
toLineBuf(u, v, pos) | Writes two vec3 endpoints into the FFI float buffer |
pathUp(buf, nStep, c, w) | Submits the line buffer to the engine's debug draw system |
Color Format
Colors are passed as tables {r, g, b, a} with values 0–1, then converted internally:
Render.graph/set→ColorF(r, g, b, a)circle(non-debug) →color(r*255, g*255, b*255)
Performance
The module uses an FFI float buffer (float[6000]) for batch line rendering via BNG_DBG_DRAW_LineInstance_MinArgBatch, which is significantly faster than individual drawLine calls for large path sets.
Usage Example
local Render = require('/lua/ge/extensions/editor/gen/render')
-- Draw a path in yellow, width 2
Render.graph({{vec3(0,0,0), vec3(10,0,0), vec3(10,10,0)}}, {1,1,0,1}, 2)
-- Draw points as spheres
Render.set({vec3(5,5,0), vec3(15,5,0)}, {1,0,0,1}, 0.05)
-- Draw text labels
Render.label({{"Start", vec3(0,0,0)}, {"End", vec3(10,10,0)}}, {0,0,1,1})See Also
- Gen Mesh - 3D mesh construction
- Gen Network - Road network geometry
- Gen Decal - Road decal rendering