BufferGeometry
Representation of mesh, line, or point geometry with GPU-optimized
buffers.
This class provides geometry data storage for rendering. It includes
vertex positions, face indices, normals, colors, UVs, and custom
attributes within buffers.
- Managing indexed and non-indexed geometry
- Computing bounding volumes for culling
- Organizing geometry into render groups
- Applying geometric transformations
Methods
BufferGeometry()
Default constructor: creates an empty geometry
BufferGeometry(const string& name)
Constructor with custom name
| name | Human-readable name for the geometry |
BufferGeometry* clone() const
Creates a copy of this geometry
void copy(const BufferGeometry& geometry)
Copies properties from another geometry
| geometry | Source geometry to copy from |
void setAttribute(const string& name, void* data, u32 itemSize, u32 count, u32 format)
Sets a geometry attribute
| name | Attribute name (position, normal, color, uv, etc.) | |
| data | Pointer to the attribute data | |
| itemSize | Number of components per vertex | |
| count | Number of vertices | |
| format | GX data format (GX_S16, GX_F32, etc.) |
void* getAttribute(const string& name) const
Gets a geometry attribute
| name | Attribute name to retrieve |
bool hasAttribute(const string& name) const
Checks if an attribute exists
| name | Attribute name to check |
void deleteAttribute(const string& name)
Deletes an attribute
| name | Attribute name to delete |
void setIndex(u16* indices, u32 count)
Sets the index buffer for indexed geometry
| indices | Pointer to index data | |
| count | Number of indices |
u16* getIndex() const
Gets the index buffer
void addGroup(u32 start, u32 count, u32 materialIndex)
Adds a render group to the geometry
| start | Starting vertex/index for the group | |
| count | Number of vertices/indices in the group | |
| materialIndex | Material index to use for this group |
void clearGroups()
Clears all render groups
void applyMatrix4(const Mtx& matrix)
Applies a 4x4 matrix transformation to the geometry
| matrix | Matrix to apply |
void center()
Centers the geometry based on bounding box
void translate(f32 x, f32 y, f32 z)
Translates the geometry data
| x | Translation along X axis | |
| y | Translation along Y axis | |
| z | Translation along Z axis |
void rotateX(f32 radians)
Rotates the geometry around X axis
| radians | Rotation angle in radians |
void rotateY(f32 radians)
Rotates the geometry around Y axis
| radians | Rotation angle in radians |
void rotateZ(f32 radians)
Rotates the geometry around Z axis
| radians | Rotation angle in radians |
void scale(f32 x, f32 y, f32 z)
Scales the geometry data
| x | Scale factor for X axis | |
| y | Scale factor for Y axis | |
| z | Scale factor for Z axis |
void computeBoundingBox()
Computes the bounding box of the geometry
void computeBoundingSphere()
Computes the bounding sphere of the geometry
void setupGX()
Sets up GX for rendering this geometry
void render()
Renders the geometry using GX
Properties
| attributes | map<string, void*> | Hashmap of attributes (name -> data pointer) |
| boundingBox | void* | Bounding box (null = not computed) |
| boundingSphere | void* | Bounding sphere (null = not computed) |
| drawRangeCount | u32 | Count of vertices/indices to render |
| drawRangeStart | u32 | Start of draw range |
| groups | vector |
Render groups for multiple materials |
| id | u32 | Unique identifier |
| index | u16* | Index buffer for indexed geometry |
| indexCount | u32 | Number of indices |
| isBufferGeometry | bool | Read-only flag to check if object is BufferGeometry |
| isIndexed | bool | Whether geometry uses indices |
| name | string | Human-readable name |
| primitiveType | u32 | GX primitive type (GX_QUADS, GX_TRIANGLES, etc.) |
| userData | void* | Custom user data |
| uuid | string | UUID string |
| vertexCount | u32 | Total number of vertices |