Lines¶
Inherits: Object
C++ type: Lines
Description¶
Renders a collection of 3D line segments. Useful for debug overlays, grids, trajectory paths, and other wireframe visuals. Each line is defined by two endpoints and an optional per-endpoint colour for gradient lines.
The Lines object maintains an internal dynamic buffer. Call updateLines() after modifying line data to upload changes to the GPU.
Properties¶
| Type | Name | Default | Langs |
|---|---|---|---|
| unsigned int | maxLines | 100 |
C++ | Lua |
Methods¶
| Type | Name | Langs |
|---|---|---|
| bool | load | C++ | Lua |
| void | addLine | C++ | Lua |
| LineData | getLine | C++ | Lua |
| void | updateLine | C++ | Lua |
| void | removeLine | C++ | Lua |
| void | updateLines | C++ | Lua |
| size_t | getNumLines | C++ | Lua |
| void | clearLines | C++ | Lua |
Property details¶
maxLines¶
- Setter: void setMaxLines(unsigned int maxLines)
- Getter: unsigned int getMaxLines() const
Pre-allocates buffer space for this many lines. Resize before calling load() for best performance.
Method details¶
load¶
- bool load()
Initialises the GPU buffer. Must be called once before lines are rendered.
addLine¶
Several overloads are available:
- void addLine(LineData line)
- void addLine(Vector3 pointA, Vector3 pointB)
- void addLine(Vector3 pointA, Vector3 pointB, Vector3 color)
- void addLine(Vector3 pointA, Vector3 pointB, Vector4 color)
- void addLine(Vector3 pointA, Vector3 pointB, Vector4 colorA, Vector4 colorB)
Adds a new line segment. The last overload lets each endpoint have a different colour.
getLine¶
- LineData& getLine(size_t index)
Returns a reference to the LineData at the given index. Modify in-place then call updateLines().
updateLine¶
- void updateLine(size_t index, ...)
Overwrites an existing line's endpoints and/or colour. Multiple overloads mirror addLine(). Call updateLines() afterwards.
removeLine¶
- void removeLine(size_t index)
Removes the line at index. All subsequent indices shift down.
updateLines¶
- void updateLines()
Uploads all pending line changes to the GPU. Must be called after any addLine, updateLine, or removeLine call.
getNumLines¶
- size_t getNumLines()
Returns the current number of line segments.
clearLines¶
- void clearLines()
Removes all line segments.