Grid Struct
A configurable grid shape for rendering reference lines in 3D space. More...
Declaration
Base struct
| struct | Shape |
|
Struct representing geometric primitives and indices for various shapes. provides immutable, shared access to vertices and indices of the represented geometric shape. More... | |
Public Constructors Index
| Grid () | |
|
Creates a default grid with 2 segments per coordinate axis. More... | |
| Grid (unsigned int segmentsX, unsigned int segmentsY) | |
|
Creates a grid with a specified number of subdivisions. More... | |
Private Constructors Index
| Grid (std::pair< std::vector< Vertex >, std::vector< unsigned int > > data) | |
|
Private constructor that takes pre-generated geometry data. More... | |
Public Member Functions Index
| helios::rendering::mesh::PrimitiveType | primitiveType () const noexcept override |
|
Returns the primitive type used for rendering this shape. More... | |
Private Static Functions Index
| static std::pair< std::vector< Vertex >, std::vector< unsigned int > > | generate (unsigned int segmentsX, unsigned int segmentsY) |
|
Generates vertex and index data for the grid geometry. More... | |
Description
A configurable grid shape for rendering reference lines in 3D space.
The Grid class generates a planar grid mesh composed of line segments. The grid is centered at the origin and spans from -1 to +1 on both the X and Y axes. The number of subdivisions along each axis can be configured via constructor parameters.
The generated grid lies in the XY-plane with all vertices having a Z-coordinate of 0. All normals point in the positive Z direction (0, 0, 1).
Typical use cases include:
- Scene orientation and scale reference
- Debug visualization
- Editor overlays
Example usage: ```cpp // Create a 10x10 grid auto grid = std::make_shared<Grid>(10, 10); scene->addRenderable(grid); ```
The grid uses `PrimitiveType::Lines` for rendering, not triangles.
- See Also
Definition at line 48 of file Grid.ixx.
Public Constructors
Grid()
| inline |
Grid()
| inline explicit |
Creates a grid with a specified number of subdivisions.
Constructs a grid with the given number of segments along each axis. Higher segment counts produce finer grids with more lines.
- Parameters
-
segmentsX Number of subdivisions along the X-axis. Must be at least 2.
segmentsY Number of subdivisions along the Y-axis. Must be at least 2.
- Exceptions
-
std::invalid_argument If either segmentsX or segmentsY is less than 2.
Private Constructors
Grid()
| inline explicit |
Private constructor that takes pre-generated geometry data.
Used internally by the public constructors to initialize the base Shape class with vertex and index data.
- Parameters
-
data A pair containing vertex data and index data for the grid.
Public Member Functions
primitiveType()
| inline nodiscard noexcept virtual |
Returns the primitive type used for rendering this shape.
- Returns
`PrimitiveType::Lines` since the grid is rendered as line segments.
Definition at line 159 of file Grid.ixx.
Reference helios::rendering::mesh::Lines.
Private Static Functions
generate()
| inline static |
Generates vertex and index data for the grid geometry.
Creates a grid of vertices in the XY-plane spanning from (-1, -1) to (1, 1). Vertices are generated row by row, and indices are created to form horizontal and vertical line segments connecting adjacent vertices.
- Parameters
-
segmentsX Number of subdivisions along the X-axis.
segmentsY Number of subdivisions along the Y-axis.
- Returns
A pair containing the vertex list and the index list for line rendering.
- Exceptions
-
std::invalid_argument If either segmentsX or segmentsY is less than 2.
Definition at line 68 of file Grid.ixx.
The documentation for this struct was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.