Graphics Reference
In-Depth Information
Returning to the WPF camera model, the look direction specifies in which
direction the camera is pointed. If we trace a ray in the scene starting at the position
and pointing in the look direction, we'll hit some object. That object will appear
in the exact center of the “picture” taken by our camera. The field-of-view angles
describe how far from the look direction, in degrees, the camera sees. The basic
WPF camera produces a square picture, so the field of view is the same in both
the horizontal and vertical directions. In some other systems, you get to specify
both a horizontal and vertical field of view (see Exercise 13.1). Others, including
WPF, let you specify both the aspect ratio and the horizontal field of view, and
compute the vertical field of view for you. In fact, in WPF you specify the aspect
ratio indirectly. You specify the width and height of the viewport (a rectangle on
the display used for exhibiting the image), and the aspect ratio is determined by
the ratio of the width to the height. In the remainder of our presentation, we'll
specify the view in terms of both horizontal and vertical field of view, and we'll
discuss the relationship to aspect ratio afterward.
The only subtle point is the specification of the up direction , which orients
the camera about the look direction, just as you can look out a window with your
head tilted either left or right. If we imagine a vertical unit vector v painted on
the back of the camera body, then this vector, together with the look direction,
determines a plane. You might think that we should require the user to specify the
vector v directly, but that's rather difficult to do in general. Instead, we require
the user to specify any nonzero vector in the plane (except the look direction),
and from this we compute the vector v . Figure 13.3 shows this: Any of three
different vectors can be used as the up direction, from which we can compute the
vector v that is in the vertical plane of the camera and is perpendicular to the look
direction. Often in practice the UpDirection is set to Vector3D(0,1,0) , that is,
the y -direction. As long as the camera does not look straight up or down, this is the
most natural direction in which to hold it. 1 If the camera does look straight up,
then the computed vector v will be zero; if the camera looks nearly straight up,
the computation of v from vup will involve division by a number that's almost
zero, and hence will be numerically unstable.
v
v 1
v 2
v 3
Look direction
Figure 13.3: The vectors v 1 , v 2 ,
and v 3 all lie in the plane of
LookDirection and v , and any
one of them can be used as the
UpDirection and result in the
same view.
At this point, the view specification tells where the camera is, in which direc-
tion it's looking, and how the camera body is rotated around that view direction;
the field of view determines how wide an area the camera “sees.” We've indirectly
described a four-sided view volume with a rectangular cross section in space.
Two more parts of the specification remain: the near-plane and far-plane dis-
tances shown in Figure 13.4. The near and far planes cut out a frustum of the
view cone. Objects within this frustum will be displayed in our image, but objects
outside will not (see Figure 13.5).
This can be a useful device: By setting the near-plane distance to be almost
the distance to the subject, we guarantee that objects between us and the subject
do not interfere with the picture. We also avoid ever considering objects that are
behind the camera, which can be a huge time-saver. And by setting the far-plane
distance so that it is not too large, we can similarly save lots of time, by never
considering all the objects in the world that are potentially within our view but
would hardly affect it at all, such as a person standing 30 miles away.
1. In CAD, the horizontal plane is often xy , with z used for the vertical direction; in that
case, of course, the up vector would be Vector3D(0,0,1) .
 
 
Search WWH ::




Custom Search