Graphics Reference
In-Depth Information
.
Source file. box.x file in the
MeshFiles folder.
A:
FrameTransformMatrix {
// Define object transform
// Default is I 4
1.000000,0.000000, ...
B:
Mesh {
// Define mesh geometric information
24;
// There are 24 triangles
Geometric position of the 0 th
-0.500000;-0.500000;-0.500000;,
//
vertex
.
//
Other vertex positions
C:
12;
// There are 12 polygons
0 th
1 st
2 nd
{
,
,
}
3;0,1,2;,
//
Polygon-0 has 3 vertices:
.
//
Rest of the polygons (all triangles)
D:
MeshNormals {
// Define normal vectors
24;
// There are 24 unique vectors
.
//
Define the vectors for the vertices
E:
MeshMaterialList {
// Define material properties for the mesh
Listing 16.1. Example of a simple D3D mesh file ( .x ).
The top image of Figure 16.2 shows a biplane, and the lower image overlays
the triangles that define the geometry. To design such a model, a skillful artist has
24 versus eight vertices.
There are only eight unique
vertex positions for a cube.
However, each of these vertex
positions can have three
different directions ( normal )
depending on which triangle
they are associated with. For
example, the top-front-left
vertex has an upward direc-
tion when it is part of the top
triangle, a leftward direction
when it is part of the left
triangle, and a frontward
direction when it is part of
the front triangle. In this way,
24 unique vertex positions
and directions (normals) are
needed to represent a cube.
to spend long hours working with commercial 3D modeling software (e.g., Maya)
in perfecting every vertex position. The artist then stores all the triangles and the
associated vertices in a mesh file. We notice that the biplane model has interest-
ing wood textures. To accomplish this effect, the artist has to create image files
as texture maps for the biplane geometries. Similar to the geometries, these tex-
ture image files are usually created by skillful artists spending long hours working
with commercial painting software (e.g., Photoshop). The mesh file contains ref-
erences to the texture image files. Mesh files are typically complex and typically
contain geometric information, material properties of the geometry (including file
texture information), animations of the geometries, and even transformations and
relationships with respect to other objects. Due to the complexity and the fact that
much of the information encoded in a mesh file may be closely related to a partic-
ular commercial software system, almost all vendors have specialized proprietary
file formats. The D3D API defines the .x mesh file format where information is
encoded in simple ASCII text. In the following, we use a simple example from
this file format to illustrate how information is stored in a mesh file. Listing 16.1
shows fragments from the mesh file that defines the cube shown in Figure 16.1.
Although this is a simple example, we can identify some important characteristics
common to typical mesh files:
Search WWH ::




Custom Search