Voltray Engine Docs
Loading...
Searching...
No Matches
Mesh Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

Mesh::Mesh ( float *  vertices,
unsigned int  vSize,
unsigned int *  indices,
unsigned int  iCount 
)

Constructs a Mesh object from raw C-style arrays.

Parameters
verticesPointer to the array of vertex data (e.g., positions, normals, texture coordinates).
vSizeTotal size of the vertex data array in bytes.
indicesPointer to the array of indices that define the triangles.
iCountTotal number of indices.

◆ Mesh() [2/2]

Mesh::Mesh ( const std::vector< float > &  vertices,
const std::vector< unsigned int > &  indices 
)

Constructs a Mesh object from C++ std::vector containers.

Parameters
verticesA constant reference to a vector of floats representing vertex data.
indicesA constant reference to a vector of unsigned integers representing index data.

◆ ~Mesh()

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.

Member Function Documentation

◆ Draw()

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.

◆ GetBounds()

void Mesh::GetBounds ( Vec3 minBounds,
Vec3 maxBounds 
) const

Gets the axis-aligned bounding box of the mesh.

Parameters
minBoundsOutput minimum bounds of the mesh.
maxBoundsOutput maximum bounds of the mesh.

◆ GetCenter()

Vec3 Mesh::GetCenter ( ) const

Gets the center point of the mesh bounds.

Returns
The center point of the mesh.

◆ GetIndices()

const std::vector< unsigned int > & Mesh::GetIndices ( ) const
inline

Gets access to the index data for intersection testing.

Returns
Const reference to the index data vector.

◆ GetVertices()

const std::vector< float > & Mesh::GetVertices ( ) const
inline

Gets access to the vertex data for intersection testing.

Returns
Const reference to the vertex data vector.

The documentation for this class was generated from the following files: