Building Models
Ed Angel
Professor Emeritus of Computer Science
University of New Mexico
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
1
Objectives
• Introduce simple data structures for
building polygonal models
- Vertex lists
- Edge lists
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
2
Representing a Mesh
• Consider a mesh e2
v6
e1
v1
e6
v5
e3
e8 v e9
v4
8
e11
e10
e4
e7 v7
v2 e12
e5 v3
• There are 8 nodes and 12 edges
- 5 interior polygons
- 6 interior (shared) edges
• Each vertex has a location vi = (xi yi zi)
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
3
Simple Representation
• Define each polygon by the geometric locations
of its vertices
• Leads to WebGL code such as
vertex.push(vec3(x1, y1, z1));
vertex.push(vec3(x6, y6, z6));
vertex.push(vec3(x7, y7, z7));
• Inefficient and unstructured
- Consider moving a vertex to a new location
- Must search for all occurrences
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
4
Inward and Outward
Facing Polygons
• The order {v1, v6, v7} and {v6, v7, v1} are equivalent in
that the same polygon will be rendered by OpenGL but
the order {v1, v7, v6} is different
• The first two describe outwardly
facing polygons
• Use the right-hand rule =
counter-clockwise encirclement
of outward-pointing normal
• OpenGL can treat inward and
outward facing polygons differently
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
5
Geometry vs Topology
• Generally it is a good idea to look for data
structures that separate the geometry
from the topology
- Geometry: locations of the vertices
- Topology: organization of the vertices and
edges
- Example: a polygon is an ordered list of
vertices with an edge connecting successive
pairs of vertices and the last to the first
- Topology holds even if geometry changes
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
6
Vertex Lists
• Put the geometry in an array
• Use pointers from the vertices into this array
• Introduce a polygon list
x 1 y 1 z1
v1
x 2 y 2 z2
P1
v7
x 3 y 3 z3
P2
v6
x 4 y 4 z4
P3
x5 y5 z5.
P4
v8
x 6 y 6 z6
P5
v5
v6
x 7 y 7 z7
topology
geometry x8 y8 z8
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
7
Shared Edges
• Vertex lists will draw filled polygons correctly but
if we draw the polygon by its edges, shared
edges are drawn twice
• Can store mesh by edge list
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
8
Edge List
e2
e1
e2
e3
e4
e5
e6
e7
e8
e9
v1
v6
x 1 y 1 z1
x 2 y 2 z2
x 3 y 3 z3
x 4 y 4 z4
x5 y5 z5.
x 6 y 6 z6
x 7 y 7 z7
x 8 y 8 z8
v6
e1
v1
e6
v5
e3
e8 v e9
8
e11
e10
e4
e7 v7
v2 e12
e5 v3
Note polygons are
not represented
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
9
Draw cube from faces
var colorCube( )
{
quad(0,3,2,1);
quad(2,3,7,6);
quad(0,4,7,3);
quad(1,2,6,5);
quad(4,5,6,7);
quad(0,1,5,4);
}
5
6
2
1
7
4
0
3
Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
10
© Copyright 2026 Paperzz