Making a Mesh

How to 3D

Chapter 3: Meshes

Making a Mesh

Triangles are to a graphics developer as clay is to a sculptor. Clay is physical and yields to our hands. Triangles are virtual and yield to math. In our software, we push, twist, and stretch triangles into complex and interesting models using two complementary techniques:

Most models in games are made by professional 3D artists using direct manipulation tools like 3ds Max, Maya, and Blender. Software developers import these models. But sometimes the developers get to make models themselves by writing code. Models made in either manner are represented in graphics programs using a data structure we'll call a triangle mesh or a trimesh. Some algorithms expect quadrilateral meshes or quadmeshes, but we will stick with trimeshes.

In this chapter, we'll explore both generating models directly in our own programs and importing models made in 3D modeling programs. By its end, you'll be able to answer the following questions:

What state and behaviors do we need in the trimesh data structure?
How do we use parametric equations to generate grids, cylinders, cones, and spheres?
How do we read in models stored in the OBJ and glTF formats?
How do we compute normals for a mesh?

After working through the exercises ahead, we'll be able to render models that are too much to type in by hand. In the succeeding chapters, we'll learn how to arrange them in space and illuminate them.

Trimesh →