Geometry and Meshes

This section delves into the fundamental building blocks of 3D graphics: geometry and meshes. Understanding how to represent, manipulate, and render geometric data is crucial for creating any visual experience in 3D.

What is Geometry in 3D Graphics?

In computer graphics, geometry refers to the mathematical description of shapes and their positions in 3D space. The most common way to represent complex geometric objects is through meshes.

Meshes: Vertices, Edges, and Faces

A mesh is a collection of vertices, edges, and faces that define the shape of a 3D object.

Mesh Data Structures

Efficiently storing and accessing mesh data is vital for performance. Common structures include:

Common Geometric Primitives

While complex meshes can be loaded from files, many applications start with basic primitives:

Mesh Manipulation

Once a mesh is defined, it can be transformed in various ways:

Normals: Lighting and Shading

For realistic lighting, meshes need normals. A normal is a vector perpendicular to the surface at a given point.

Example: A Simple Triangle Mesh

Here's a conceptual representation of a simple triangle:

// Using pseudocode for clarity
struct Vertex {
    float3 Position;
    float3 Normal;
    float2 TexCoords;
}

Vertex[] vertices = {
    { Position: float3(-1.0f, -1.0f, 0.0f), Normal: float3(0.0f, 0.0f, 1.0f), TexCoords: float2(0.0f, 0.0f) },
    { Position: float3( 1.0f, -1.0f, 0.0f), Normal: float3(0.0f, 0.0f, 1.0f), TexCoords: float2(1.0f, 0.0f) },
    { Position: float3( 0.0f,  1.0f, 0.0f), Normal: float3(0.0f, 0.0f, 1.0f), TexCoords: float2(0.5f, 1.0f) }
};

ushort[] indices = { 0, 1, 2 }; // Defines the order to draw the vertices as a triangle
            

Visual representation of the triangle described above.

Further Reading