Mesh struct

A triangle mesh.

This class stores a triangle mesh object and provides numerous functions for querying the individual triangles. Subclasses of Mesh implement the specifics of how to create its contents (e.g. by loading from an external file)

Base classes

class Surface
This is the abstract superclass for all surfaces.

Constructors, destructors, conversion operators

Mesh()
Create an empty mesh.
Mesh(const json& j)
Try to load a mesh from an OBJ file.

Public functions

auto bounds() const -> Box3f override
Return the surface's world-space AABB.
auto size() const -> size_t
Report the approximate size (in bytes) of the mesh.
void add_to_parent(Surface* parent, shared_ptr<Surface> self, const json& j) override
Add this surface to the parent surface.

Public variables

vector<Vec3f> vs
Vertex positions.
vector<Vec3f> ns
Vertex normals.
vector<Vec2f> uvs
Vertex texture coordinates.
vector<Vec3i> Fv
Vertex indices per face (triangle)
vector<Vec3i> Fn
Normal indices per face (triangle)
vector<Vec3i> Ft
Texture indices per face (triangle)
vector<uint32_t> Fm
One material index per face (triangle)
vector<shared_ptr<const Material>> materials
All materials in the mesh.
Transform xform
Transformation that the data has already been transformed by.
Transform object_to_texture
Transformation from object space to texture (bounding box) space.
Box3f bbox_w
The bounds, after transformation (in world space)
Box3f bbox_o
The bounds, before transformation (in object space)

Function documentation

void Mesh::add_to_parent(Surface* parent, shared_ptr<Surface> self, const json& j) override

Add this surface to the parent surface.

Parameters
parent in/out The parent Surface (typically the scene) to add to.
self in A shared_ptr version of this
in The json parameters used to create self

By default this function just calls add_child() on the parent.

This function is used by aggregate surfaces that shouldn't themselves be added to the scene (like a mesh), but instead need to create other surfaces (individual triangles) that get added to the scene.