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 |
| string | customShader | "" |
C++ | Lua |
Methods¶
| Type | Name | Langs |
|---|---|---|
| bool | load | C++ |
| 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 |
| void | setShaderUniform | C++ | Lua |
| Vector4 | getShaderUniform | C++ | Lua |
| bool | removeShaderUniform | 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()
Explicitly initialises the GPU buffer. This method is C++ only and is normally optional because the render system initialises lines automatically.
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.
customShader¶
- Setter:
void setCustomShader(const std::string& path) - Getter:
std::string getCustomShader() const
Project-relative base path of a forked shader ("shaders/laser" resolves to shaders/laser.vert and shaders/laser.frag, or "a.vert|b.frag" names the files separately). Empty (default) uses the scene default shader for this type, or the engine built-in. Changing it reloads the component. Same semantics as Mesh.customShader; see Custom Shaders.
setShaderUniform¶
void setShaderUniform(const std::string& name, const Vector4& value)void setShaderUniform(const std::string& name, const Vector3& value)void setShaderUniform(const std::string& name, const Vector2& value)void setShaderUniform(const std::string& name, float value)Vector4 getShaderUniform(const std::string& name) constbool removeShaderUniform(const std::string& name)
Values for the members of the custom shader's u_vs_customParams / u_fs_customParams blocks, by member name. Setting a value only rewrites the uploaded block, so it can run every frame; a member with no value reads zero, or the scene's value under a scene default shader, and time (seconds since startup) and resolution (render target size) are reserved for the engine. Same semantics as Mesh.setShaderUniform; see Custom Shaders — Shader uniforms.