Core::Mesh
Mesh represents a complete 3D model. More...
#include "Core/Resources/Mesh.h"
Inherits from Core::ManagedResource
Public Classes
Name | |
---|---|
struct | Material <br>Data class holding basic material information. |
struct | MeshPart <br>Individual part of the bigger mesh containing separate geometry, material and textures. |
struct | TextureSet <br>A set of textures for multi-mapping. |
Public Types
Name | |
---|---|
enum | DrawType { ARRAYS, ELEMENTS} |
enum | PrimitiveType { LINES, TRIANGLES} |
Public Functions
Name | |
---|---|
void | dispose() const |
void | render() const<br>Renders the mesh and all its mesh parts. |
void | renderMeshPart(const MeshPart & meshPart) const<br>Renders an individual mesh part. |
Mesh * | create(Mesh::PrimitiveType primitiveType, const float * verts, const unsigned int nVertices, const float * colors, const unsigned int nColors)<br>Create mesh from vertices and colors. |
Mesh * | create(Mesh::PrimitiveType primitiveType, const float * verts, const unsigned int nVertices, const unsigned int * indices, const unsigned int nIndices, const float * colors, const unsigned int nColors)<br>Create mesh from indexed vertices and colors; Only fills the color vertex buffer. |
Mesh * | load(const std::string & path, bool normalize =false, bool minimalLoad =false)<br>Load mesh from a model file using assimp Fills normal, texcoord and tangent vertex buffers. |
Public Attributes
Name | |
---|---|
glm::vec3 | m_boundingBoxMax <br>Mesh bounding box max, derived from bounding boxes of mesh parts. |
glm::vec3 | m_boundingBoxMin <br>Mesh bounding box min, derived from bounding boxes of mesh parts. |
GLuint | m_color_vbo |
DrawType | m_drawType |
GLuint | m_ebo |
std::vector< MeshPart > | m_meshParts <br>List of mesh parts making up this mesh. |
unsigned int | m_nIndices <br>count of indices af all the mesh parts together |
GLuint | m_normal_vbo |
bool | m_normalized <br>Whether the mesh geometry has been normalized on load. |
unsigned int | m_nVertices <br>count of vertices af all the mesh parts together |
std::string | m_path <br>If applicable, file path to the primary source file. |
PrimitiveType | m_primitiveType |
GLuint | m_tangent_vbo |
int | m_textureCount <br>Number of loaded textures for this mesh (files or embedded) |
std::set< std::string > | m_textureFileList <br>List of texture file paths this mesh requires (not including embedded textures) |
bool | m_useColors <br>Whether the vertex colors vbo is used. |
bool | m_useNormals <br>Whether the normal vbo is used. |
bool | m_useTangents <br>Whether the tangent vbo is used. |
bool | m_useTexcoords <br>Whether the texture coordinates vbo is used. |
GLuint | m_uv_vbo |
GLuint | m_vao |
GLuint | m_vertex_vbo |
Friends
Name | |
---|---|
class | ResourceManager |
Additional inherited members
Public Attributes inherited from Core::ManagedResource
Name | |
---|---|
size_t | m_resourceId <br>Resource ID of an object An identifier used by a ResourceManager. |
Detailed Description
class Core::Mesh;
class Core::Mesh;
Mesh represents a complete 3D model.
It hold relevant opengl state data and a list of mesh parts that actually make up the model. Each mesh part also holds information about a material and a set of textures. Geometry is immediately passed to OpenGL and not preserved in memory. All geometry data is stored in a set of buffers that are shared among the mesh parts of the mesh.
Can be loaded using assimp with Mesh::load() Or created directly from data using Mesh::create()
Vertex attribute locations are hardcoded and are:
- location 0 = aPos (vec3)
- location 1 = aNormal (vec3)
- location 2 = aTexCoord (vec2)
- location 3 = aTangent (vec3)
- location 4 = aColor (vec3)
Normals, TexCoords, Tangents and Colors can be individually disabled
Public Types Documentation
enum DrawType
Enumerator | Value | Description |
---|---|---|
ARRAYS | ||
ELEMENTS |
enum PrimitiveType
Enumerator | Value | Description |
---|---|---|
LINES | ||
TRIANGLES |
Public Functions Documentation
function dispose
void dispose() const
void dispose() const
function render
void render() const
void render() const
Renders the mesh and all its mesh parts.
For more control over rendering you can iterate through individual meshParts and use renderMeshPart()
function renderMeshPart
void renderMeshPart(
const MeshPart & meshPart
) const
void renderMeshPart(
const MeshPart & meshPart
) const
Renders an individual mesh part.
Parameters:
- meshPart The mesh part to render.
Note that prior to calling this method the mesh's VAO needs to be bound!
function create
static Mesh * create(
Mesh::PrimitiveType primitiveType,
const float * verts,
const unsigned int nVertices,
const float * colors,
const unsigned int nColors
)
static Mesh * create(
Mesh::PrimitiveType primitiveType,
const float * verts,
const unsigned int nVertices,
const float * colors,
const unsigned int nColors
)
Create mesh from vertices and colors.
Return: Pointer to the new Mesh object (newly allocated, to be managed externally)
Only fills the color vertex buffer.
function create
static Mesh * create(
Mesh::PrimitiveType primitiveType,
const float * verts,
const unsigned int nVertices,
const unsigned int * indices,
const unsigned int nIndices,
const float * colors,
const unsigned int nColors
)
static Mesh * create(
Mesh::PrimitiveType primitiveType,
const float * verts,
const unsigned int nVertices,
const unsigned int * indices,
const unsigned int nIndices,
const float * colors,
const unsigned int nColors
)
Create mesh from indexed vertices and colors; Only fills the color vertex buffer.
Return: Pointer to the new Mesh object (newly allocated, to be managed externally)
function load
static Mesh * load(
const std::string & path,
bool normalize =false,
bool minimalLoad =false
)
static Mesh * load(
const std::string & path,
bool normalize =false,
bool minimalLoad =false
)
Load mesh from a model file using assimp Fills normal, texcoord and tangent vertex buffers.
Parameters:
- path Path to the model file.
- minimalLoad If true, only the bare minimum of the model is loaded. Used to quickly aquire basic information from assimp without actually meaning to use the mesh.
Return: Pointer to the new Mesh object (newly allocated, to be managed externally)
Public Attributes Documentation
variable m_boundingBoxMax
glm::vec3 m_boundingBoxMax {0.0f};
glm::vec3 m_boundingBoxMax {0.0f};
Mesh bounding box max, derived from bounding boxes of mesh parts.
variable m_boundingBoxMin
glm::vec3 m_boundingBoxMin {0.0f};
glm::vec3 m_boundingBoxMin {0.0f};
Mesh bounding box min, derived from bounding boxes of mesh parts.
variable m_color_vbo
GLuint m_color_vbo;
GLuint m_color_vbo;
variable m_drawType
DrawType m_drawType;
DrawType m_drawType;
variable m_ebo
GLuint m_ebo;
GLuint m_ebo;
variable m_meshParts
std::vector< MeshPart > m_meshParts;
std::vector< MeshPart > m_meshParts;
List of mesh parts making up this mesh.
variable m_nIndices
unsigned int m_nIndices {0};
unsigned int m_nIndices {0};
count of indices af all the mesh parts together
variable m_normal_vbo
GLuint m_normal_vbo;
GLuint m_normal_vbo;
variable m_normalized
bool m_normalized {false};
bool m_normalized {false};
Whether the mesh geometry has been normalized on load.
variable m_nVertices
unsigned int m_nVertices {0};
unsigned int m_nVertices {0};
count of vertices af all the mesh parts together
variable m_path
std::string m_path;
std::string m_path;
If applicable, file path to the primary source file.
variable m_primitiveType
PrimitiveType m_primitiveType;
PrimitiveType m_primitiveType;
variable m_tangent_vbo
GLuint m_tangent_vbo;
GLuint m_tangent_vbo;
variable m_textureCount
int m_textureCount {0};
int m_textureCount {0};
Number of loaded textures for this mesh (files or embedded)
variable m_textureFileList
std::set< std::string > m_textureFileList;
std::set< std::string > m_textureFileList;
List of texture file paths this mesh requires (not including embedded textures)
variable m_useColors
bool m_useColors {false};
bool m_useColors {false};
Whether the vertex colors vbo is used.
variable m_useNormals
bool m_useNormals {false};
bool m_useNormals {false};
Whether the normal vbo is used.
variable m_useTangents
bool m_useTangents {false};
bool m_useTangents {false};
Whether the tangent vbo is used.
variable m_useTexcoords
bool m_useTexcoords {false};
bool m_useTexcoords {false};
Whether the texture coordinates vbo is used.
variable m_uv_vbo
GLuint m_uv_vbo;
GLuint m_uv_vbo;
variable m_vao
GLuint m_vao;
GLuint m_vao;
variable m_vertex_vbo
GLuint m_vertex_vbo;
GLuint m_vertex_vbo;
Friends
friend ResourceManager
friend class ResourceManager(
ResourceManager
);
friend class ResourceManager(
ResourceManager
);
Updated on 2025-01-07 at 13:40:44 +0000