Graphics Reference
In-Depth Information
Transformation. Mesh files often include transformation information to
be applied to part of or the entire mesh object. In this case, label A defines
the identify matrix ( I 4 ) to be applied to all the geometries in this file.
Geometry. Mesh files always encode the geometry of an object. In general,
the geometry may include components and even animation sequences of
the components. In our very simple case, we can see that at label B, the
keyword Mesh signifies the beginning of the geometric definition for the
cube.
After this keyword, we see the number 24 followed by 24 vertex
Indexed polygons. List-
ing unique vertices in an or-
dered list and defining poly-
gons by specifying vertices
from this list. When poly-
gons share common vertices,
this scheme of encoding ge-
ometry optimizes memory.
positions. These positions are ordered beginning with index 0 th
1 st
to
the 23 rd . After the 24 vertex positions, the number 12 at label C signifies
there will be 12 polygons to follow. We see that each polygon is defined
according to:
,
, ...
n ; i
,
j
, ...
;
,
where n is the number of vertices a polygon has and i
are the indices
of the vertices. In this case, we see a polygon with three vertices: the 0 th ,
first, and second vertex listed at label B. At label D, 24 normal vectors (or
,
j
, ...
Material and normal. Ma-
terial properties and normal
directions at vertices help de-
fine the appearance of ob-
jects. We will examine exam-
ples that work with material
and normal direction in Ap-
pendix A.
directions) are defined, one for each of the 24 vertex positions.
Appearance. Mesh files often define the appearance (or material prop-
erties) for the mesh object. In this case, at label E we see the keyword
MeshMaterialList where material properties are defined for the cube.
This is where the texture image files will be specified.
UWBGL_D3D_Lib15
Change summary. See p. 529
for a summary of changes to
the library.
This version of the UWBGL library integrates the .x mesh objects as specializations
of our Primitive class. There are three main aspects to our implementation:
(1) loading of mesh files as resources; (2) managing the mesh resources; and
(3) creating mesh specific subclasses to the Primitive class.
Mesh File Resources
Recall that when working with file textures in Lib13 (p. 359), we introduced
the Resource class (Listing 12.12) to abstract the interaction with and man-
agement of files. For example, we have defined the TextureResource (List-
ing 12.13) class to interact with and load file textures as a resource. Listing 16.2
shows the MeshResource class where we subclass from the UWBD3D _ Resource
to inherit the file searching functionality. At label A, the DrawMesh() function
Search WWH ::




Custom Search