Graphics Reference
In-Depth Information
LookDirection is a vector specifying the direction of the camera projec-
tion, in world coordinates. Think of the LookDirection as the center line
of the barrel of the lens that you are pointing toward the central object.
UpDirection rotates the camera about the look-direction vector to specify
what will constitute the “up” direction to the viewer. In our example, in
which the ground plane is the xz -plane, the up-direction vector 0, 1, 0 T
simulates a stationary tripod on the desert sand set up to photograph the
pyramid, with the image plane perpendicular to the ground plane.
Additionally, the width of the camera's field of view can be specified as
an angle in degrees; for example, a wide-angle lens can be simulated with
a wide field of view such as 160°. Also, two clipping planes can be speci-
fied to prevent anomalies that occur when objects are too close to the camera
( NearPlaneDistance property), and to reduce computation expense by ignoring
objects that are very distant ( FarPlaneDistance property) and thus too small to
resolve due to perspective foreshortening.
Next we light the scene with nondirectional ambient light that applies a con-
stant amount of illumination on all surfaces regardless of location or orientation.
(We'll supplement this with more realistic lighting later.) Ambient light ensures
that each surface is illuminated to some degree, preventing unrealistic pure-black
regions on surfaces facing away from light sources. (Such regions would, in the
“real world,” be subjected to at least some level of interobject reflection.) The
amount of ambient light is kept to a minimum when used in combination with
other lighting, but in this initial scene, ambient is the only lighting type, so we'll
use full-intensity white to ensure a bright rendering. We specify this light by
adding an AmbientLight element inside the Model3DGroup element:
<AmbientLight Color= "white" />
Inline Exercise 6.1: At this point, we recommend that you start running mod-
ule #1 (“Modeling Polyhedra...”)of the laboratory software for this chapter,
available in the online resources. We will refer to this module throughout this
section.
6.2.1.2 Placing the First Triangle
It is no coincidence that we have selected a pyramid as our first example object,
since the triangular mesh is the only 3D primitive type currently supported by
WPF (and is the most common format generated by interactive modeling appli-
cations). The first step in creating a 3D object is to define a resource object of
type MeshGeometry3D by providing a list of 3D Positions (vertices) and a list
of triangles. The latter is specified via the TriangleIndices property, in which
we specify each triangle via a sequence of three integer indices into the zero-
based Positions array. In this case, we are specifying a mesh containing just one
triangle, the first face of our pyramid. Figure 6.4 shows a tabular representation of
the mesh.
Positions
Index
X
Y
Z
0
0
75
0
1
2
-50
0
50
50
0
50
TriangleIndices
0,1,2
It is the programmer's responsibility to identify the front side of each trian-
gle, because the front/back distinction is important, as we will soon discover.
Thus, when specifying a vertex triplet in the TriangleIndices array, list the
vertex indices in a counterclockwise order from the point of view of someone
Figure 6.4: Tabular representa-
tion of the geometric specifica-
tion of a single-triangle mesh.
 
 
Search WWH ::




Custom Search