Objects::Mesh::Mesh

Vertex and Mesh Structures in Unified Engine

The Vertex and Mesh structures in the Unified Engine provide the foundational building blocks for 3D model representation. The Vertex structure defines individual points on a model, including properties necessary for rendering such as position, color, UV coordinates, and normals. The Mesh structure, on the other hand, organizes these vertices and provides indices to connect them and form the final 3D shape.

Vertex Properties

The properties that define the attributes of a vertex in 3D space.

struct Vertex
{
    glm::vec3 position = {0, 0, 0};  // Position of the vertex in 3D space
    glm::vec3 color = {1, 1, 1};    // Color of the vertex
    glm::vec2 uv = {0, 0};          // UV coordinates for texture mapping
    glm::vec3 normal = {0, 0, 0};   // Normal vector for lighting calculations
};

Mesh Properties

The properties that define the shape and organization of the 3D model.

struct Mesh
{
    std::vector<Vertex> vertices = {};   // A list of vertices defining the shape
    std::vector<GLuint> indices = {};    // Indices to construct the 3D model from vertices
};

Last updated