Class Mesh

Represents a 3D mesh with vertex and index data, supporting rendering and triangle iteration.

class Mesh
  : dlib.core.ownership.Owner
  , Drawable
  , TriangleSet;

The Mesh class stores vertex positions, normals, texture coordinates, and triangle indices. It supports bounding box calculation, normal generation, OpenGL VAO/VBO management, and implements the Drawable and TriangleSet interfaces.

Constructors

NameDescription
this (owner) Constructs a mesh with the given owner.

Fields

NameTypeDescription
boundingBox dlib.geometry.aabb.AABBAxis-aligned bounding box for the mesh.
canRender boolTrue if OpenGL buffers are prepared and mesh can be rendered.
dataReady boolTrue if mesh data is ready for rendering.
eao uintOpenGL element array object for indices.
indices uint[3][]Array of triangle indices (each element is a uint[3]).
nbo uintOpenGL vertex buffer object for normals.
normals dlib.math.vector.Vector!(float,3)[]Array of vertex normals.
tbo uintOpenGL vertex buffer object for texture coordinates.
texcoords dlib.math.vector.Vector!(float,2)[]Array of texture coordinates.
vao uintOpenGL vertex array object.
vbo uintOpenGL vertex buffer object for positions.
vertices dlib.math.vector.Vector!(float,3)[]Array of vertex positions.

Methods

NameDescription
calcBoundingBox () Calculates the axis-aligned bounding box for the mesh.
generateNormals () Generates smooth vertex normals for the mesh based on triangle geometry. Overwrites the normals array with computed normals.
getTriangle (faceIndex) Returns the triangle at the specified face index.
opApply (dg) Iterates over all triangles in the mesh.
prepareVAO () Prepares OpenGL VAO and VBOs for rendering the mesh. Uploads vertex, normal, texcoord, and index data to the GPU. Sets up attribute pointers and enables rendering.
render (state) Renders the mesh using the provided graphics pipeline state.