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.
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.
Box3f bbox
The bounds, after transformation.

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 The parent Surface (typically the scene) to add to.
self A shared_ptr version of this
j 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.