CSCI 461: Computer Graphics

Middlebury College, Fall 2023

Lecture 06: Meshes

By the end of today's lecture, you will be able to:

  • represent meshes using two flattened (1d) arrays for vertices and elements,
  • access vertices and elements in a triangle mesh,
  • extract the edges of a triangle mesh,
  • extract vertex-to-vertex adjacency information in a triangle mesh,
  • subdivide a mesh using the Loop subdivision scheme.

Previously, models were represented as a "soup" of triangles.

What if we want to modify our models?


We need a concept of "connectedness."

What about memory consumption?

Assume floating-point values (each component of a vec3) are stored as Float32 (4 bytes). How much memory is used if every triangle directly stores 3 vec3s?

Meshes have two ingredients: geometry & topology.

Extracting the edges of a triangle mesh.

Getting the "opposite" vertex of an edge.

Subdividing a triangle mesh quadruples # triangles.

What are the indices of the four new triangles resulting from the subdivision?

Exercise: subdividing a mesh to approximate a sphere.

  • We'll get started with keeping track of new edge vertex indices.
  • First assign edge midpoint as coordinates for new edge vertex.
  • Then normalize to place this point on the unit sphere.

Thursday's Lab: Loop Subdivision Surfaces.

$k$: # vertices adjacent to vertex, $\rightarrow$ we need vertex-to-vertex information!
$\beta$: (k === 3) ? 0.1875 : 0.375 / k

Creating the vertex-to-vertex information.

// initialize an array for each vertex to place the v2v information let v2v = new Array(nVertices); for (let i = 0; i < nVertices; i++) v2v[i] = []; for (let i = 0; i < nTriangles; i++) { for (let j = 0; j < 3; j++) { let p = this.triangles[3 * i + j]; let q = this.triangles[3 * i + ((j + 1) % 3)]; // add q as a neighbor to p // (p will be added as a neighbor to q when looping through the adjacent triangle) v2v[p].push(q); } }

What about memory consumption now?

Meshes can also have general polygons/polyhedra. Here are some Voronoi diagrams!