Represents a 3D mesh composed of vertices and indices. More...
#include <Mesh.h>
Public Member Functions | |
Mesh (float *vertices, unsigned int vSize, unsigned int *indices, unsigned int iCount) | |
Constructs a Mesh object from raw C-style arrays. | |
Mesh (const std::vector< float > &vertices, const std::vector< unsigned int > &indices) | |
Constructs a Mesh object from C++ std::vector containers. | |
~Mesh () | |
Destroys the Mesh object. | |
void | Draw () const |
Renders the mesh. | |
void | GetBounds (Vec3 &minBounds, Vec3 &maxBounds) const |
Gets the axis-aligned bounding box of the mesh. | |
Vec3 | GetCenter () const |
Gets the center point of the mesh bounds. | |
const std::vector< float > & | GetVertices () const |
Gets access to the vertex data for intersection testing. | |
const std::vector< unsigned int > & | GetIndices () const |
Gets access to the index data for intersection testing. | |
Represents a 3D mesh composed of vertices and indices.
The Mesh class encapsulates the vertex data, index data, and the associated OpenGL objects (Vertex Array Object, Vertex Buffer Object, and Index Buffer Object) required to render a 3D model.
Mesh::Mesh | ( | float * | vertices, |
unsigned int | vSize, | ||
unsigned int * | indices, | ||
unsigned int | iCount | ||
) |
Constructs a Mesh object from raw C-style arrays.
vertices | Pointer to the array of vertex data (e.g., positions, normals, texture coordinates). |
vSize | Total size of the vertex data array in bytes. |
indices | Pointer to the array of indices that define the triangles. |
iCount | Total number of indices. |
Mesh::Mesh | ( | const std::vector< float > & | vertices, |
const std::vector< unsigned int > & | indices | ||
) |
Constructs a Mesh object from C++ std::vector containers.
vertices | A constant reference to a vector of floats representing vertex data. |
indices | A constant reference to a vector of unsigned integers representing index data. |
Mesh::~Mesh | ( | ) |
Destroys the Mesh object.
This destructor will handle the cleanup of OpenGL resources if the underlying VertexArray, VertexBuffer, and IndexBuffer classes manage their own resource deallocation.
void Mesh::Draw | ( | ) | const |
Renders the mesh.
This method binds the associated Vertex Array Object and issues a draw call using the Index Buffer Object.
Gets the axis-aligned bounding box of the mesh.
minBounds | Output minimum bounds of the mesh. |
maxBounds | Output maximum bounds of the mesh. |
Vec3 Mesh::GetCenter | ( | ) | const |
Gets the center point of the mesh bounds.
|
inline |
Gets access to the index data for intersection testing.
|
inline |
Gets access to the vertex data for intersection testing.