Mesh represents a drawable collection of vertices, textures, and shader data. It stores vertex data, manages a vertex array object (VAO), and allows attaching multiple textures. The mesh also supports serialization of vertex data into a flat array for GPU uploading.
More...
#include <Mesh.h>
|
| Mesh () |
| Default constructor. Initializes an empty mesh.
|
|
| Mesh (const std::vector< Vertex > &pVertices) |
| Constructs a mesh using a list of vertices. Automatically creates a vertex array object using the provided vertex data.
|
|
void | Unload () |
| Unloads the mesh by deleting the vertex array object. This frees GPU resources associated with the mesh.
|
|
void | AddTexture (Texture *pTexture) |
| Adds a texture to the mesh. The texture can later be bound during rendering.
|
|
float * | ToVerticeArray () |
| Converts the mesh's vertex data into a flat float array suitable for GPU uploading. Each vertex contributes 8 floats (position [3], normal [3], uv [2]).
|
|
Texture * | GetTexture (int index) |
| Retrieves a texture attached to the mesh at a specified index.
|
|
ShaderProgram | GetShaderProgram () |
| the shader program currently assigned to the mesh.
|
|
VertexArray * | GetVertexArray () |
| the vertex array object used to render the mesh.
|
|
void | SetShaderProgram (ShaderProgram pShaderProgram) |
| the shader program to be used by the mesh for rendering.
|
|
void | SetVertexArray (VertexArray *pVao) |
| the vertex array object (VAO) for the mesh. This replaces the current VAO if one exists.
|
|
Mesh represents a drawable collection of vertices, textures, and shader data. It stores vertex data, manages a vertex array object (VAO), and allows attaching multiple textures. The mesh also supports serialization of vertex data into a flat array for GPU uploading.
◆ Mesh() [1/2]
Default constructor. Initializes an empty mesh.
◆ Mesh() [2/2]
Mesh::Mesh |
( |
const std::vector< Vertex > & | pVertices | ) |
|
Constructs a mesh using a list of vertices. Automatically creates a vertex array object using the provided vertex data.
- Parameters
-
pVertices | The list of vertices that make up the mesh geometry. |
◆ AddTexture()
void Mesh::AddTexture |
( |
Texture * | pTexture | ) |
|
Adds a texture to the mesh. The texture can later be bound during rendering.
- Parameters
-
pTexture | Pointer to the texture to add to the mesh. |
◆ GetShaderProgram()
the shader program currently assigned to the mesh.
- Returns
- The shader program used by this mesh.
◆ GetTexture()
Texture * Mesh::GetTexture |
( |
int | index | ) |
|
Retrieves a texture attached to the mesh at a specified index.
- Parameters
-
index | The index of the texture in the internal texture list. |
- Returns
- Pointer to the texture if it exists, otherwise nullptr.
◆ GetVertexArray()
the vertex array object used to render the mesh.
- Returns
- Pointer to the VertexArray object associated with the mesh.
◆ SetShaderProgram()
the shader program to be used by the mesh for rendering.
- Parameters
-
pShaderProgram | The shader program to assign. |
◆ SetVertexArray()
the vertex array object (VAO) for the mesh. This replaces the current VAO if one exists.
- Parameters
-
◆ ToVerticeArray()
float * Mesh::ToVerticeArray |
( |
| ) |
|
Converts the mesh's vertex data into a flat float array suitable for GPU uploading. Each vertex contributes 8 floats (position [3], normal [3], uv [2]).
- Returns
- Pointer to a newly allocated float array. Caller is responsible for deleting it.
◆ Unload()
Unloads the mesh by deleting the vertex array object. This frees GPU resources associated with the mesh.
The documentation for this class was generated from the following files:
- Engine/GameTool/Visual/Mesh/Mesh.h
- Engine/GameTool/Visual/Mesh/Mesh.cpp