Graphics Reference
In-Depth Information
8
9
10
11
12
...
// Final action: force display of the newly-generated image
glFlush();
}
16.2.8 Putting It All Together—Part 2: Dynamics
Let's extend the scenario to include dynamics; let's have our simple pyramid
model spin around the y -axis as though on an invisible turntable, the visualiza-
tion technique used in the lab software for Chapter 6 to demonstrate the effect of
directional lighting.
In an object-oriented system, each node in the hierarchical scene specification
supports attached transformation properties, so you would perform this animation
by attaching a rotation transformation to the pyramid primitive and tasking an
Animator element to dynamically modify the amount of rotation. This technique
is identical to the clock-rotation technique we used in Chapter 2.
In an immediate-mode platform, we perform modeling by direct manipulation
of the MODELVIEW matrix. We've already learned how to initialize the MOD-
ELVIEW matrix with the viewing transform. To achieve the spinning dynamics,
we must change our scene-generation function slightly, by appending a rotation
transformation to the MODELVIEW matrix just before drawing the scene.
We elaborate on this technique, and provide source-code examples, in the
online material for this chapter.
16.2.9 Hierarchical Modeling
Previously, we presented two examples of hierarchical modeling: a 2D clock in
Chapter 2, and a 3D camel in Section 6.6. In those examples, we learned how
to create a scene using a retained-mode platform such as WPF: The application
sets up the scene by creating a hierarchy of component nodes (attaching instance
transforms to specify initial placement), and animates the scene by adjusting the
values of the joint transformations attached to the nodes. This is an intuitive way
to work, since the scene graph's structure exactly mirrors the physical structure of
the scene being modeled.
Now, reconsider the camel hierarchy shown in Figure 6.41. How can we con-
struct this model using an immediate-mode platform?
The challenges here are twofold.
• The IM platform has no facility for storing the model. The application is
wholly responsible for representing the model's hierarchy, and for com-
puting and storing the values of all transforms that control position and
orientation.
• Section 10.11 describes the graph-traversal and matrix-stack techniques
necessary to compute the composite transformation matrix to properly
position and orient a particular leaf component in the hierarchy. A retained-
mode platform performs this calculation automatically, but this burden
rests on the application when using an IM platform.
 
 
 
 
Search WWH ::




Custom Search