Graphics Reference
In-Depth Information
10
11
12
13
14
edgeTable:
001
112
...
11
7
8
Other formats are certainly possible; indeed, there are many, many formats for
specifying models of all sorts, and programs for interconverting them (sometimes
losing some data in the conversion). Because the choice of formats is subject to
the whims of fashion, and changes quickly, we'll make no attempt to survey them.
With any such storage format, one can define multiple shapes, such as the
cube, a tetrahedron, or even a faceted sphere, and enhance the program to load
each one in turn, adding some variety. To do so will require that you understand
the test bed more fully by reading parts of the next chapter, however.
We can also enhance the program by adding a limited form of animation: The
xy -coordinates of the bottom (or top) fou r vertices of our cube are four equally
spaced points on a circle of radius r = 2
/
2, namely r (cos
θ
, sin
θ
) , where
θ
=
= 4 + t , 3 4 +
t , 5 4 + t , and 7 4 + t for the four corners, for some small value of t . By gradually
increasing t , and redrawing the model each time, we can display a rotating cube.
This method of explicitly changing the coordinates of the cube and then redis-
playing it is not particularly efficient. The cube effectively becomes a parameter-
ized model, with the rotation amount, t , serving as the parameter. The problem
is that when we want to rotate the cube 6 in the yz -plane instead of the xy -plane,
we need to change the model. And if we want to rotate first in one plane, then in
the other, we must do some messy algebra and trigonometry. It's actually far sim-
pler to model the cube just once, and then learn how to transform its vertices by
a rotation (or other operations). We'll discuss this extensively in the next several
chapters.
On the other hand, there are models that are defined parametrically, and are
animated by changing these parameters. So-called “spline” models are a particu-
larly important example, discussed in Chapter 22, but others abound, particularly
in physical simulations: A model of fluid, for instance, has parameters like the
viscosity and the density of the fluid, as well as the initial positions and velocities
of the fluid particles. The effects of these parameters on the appearance of the fluid
at some time are rather indirect—we have to perform a simulation to understand
the effects—but it is a parameterized model nonetheless.
4 , 3 4
, 5 4
, and 7 4
. We can create a slightly rotated cube by making
θ
3.6 Discussion and Further Reading
The “rendering” in this chapter was a little unusual, in the sense that we converted
our 3D scene into a collection of 2D things (points and lines), which we then drew
with a 2D renderer. In this sense, the process somewhat resembles a compiler
that turns a high-level language into low-level assembly language. Only when
this assembly language is further processed into machine language and executed
does the computation take place. In the same way, only when we actually draw
6. We speak of rotation in the xy -plane rather than “around the z -axis,” because rotation
in a plane generalizes to all dimensions, while rotation about an axis is specific to three
dimensions. Chapter 11 discusses this further.
 
 
 
Search WWH ::




Custom Search