Game Development Reference
In-Depth Information
Section 9.6 and Section 9.7, respectively. Here, our focus is on how more
than one triangle can be connected in a mesh.
One very straightforward way to store a triangle mesh would be to use
an array of triangles, as shown in Listing 10.4.
s t r u c t
T r i a n g l e
{
V e c t o r 3
v e r t P o s [ 3 ] ;
/ /
v e r t e x
p o s i t i o n s
} ;
s t r u c t
T r i a n g l e M e s h
{
i n t
t r i C o u n t ;
/ /
number
o f
t r i a n g l e s
T r i a n g l e
t r i L i s t ;
/ /
a r r a y
o f
t r i a n g l e s
} ;
Listing 10.4
A trivial representation of a triangle mesh
For some applications this trivial representation might be adequate.
However, the term “mesh” implies a degree of connectivity between adja-
cent triangles, and this connectivity is not expressed in our trivial repre-
sentation. There are three basic types of information in a triangle mesh:
Vertices. Each triangle has exactly three vertices. Each vertex may
be shared by multiple triangles. The valence of a vertex refers to how
many faces are connected to the vertex.
Edges. An edge connects two vertices. Each triangle has three edges.
In many cases, each edge is shared by exactly two faces, but there are
certainly exceptions. If the object is not closed, an open edge with
only one neighboring face can exist.
Faces. These are the surfaces of the triangles. We can store a face as
either a list of three vertices, or a list of three edges.
A variety of methods exist to represent this information e ciently, de-
pending on the operations to be performed most often on the mesh. Here
we will focus on a standard storage format known as an indexed triangle
mesh.
10.4.1 Indexed Triangle Mesh
An indexed triangle mesh consists of two lists: a list of vertices, and a list
of triangles.
Each vertex contains a position in 3D. We may also store other in-
formation at the vertex level, such as texture-mapping coordinates,
surface normals, or lighting values.
Search WWH ::




Custom Search