Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Cutting Edge Direct 3D Programming
(Publisher: The Coriolis Group)
Author(s): Stan Trujillo
ISBN: 1576100502
Publication Date: 11/01/96

Bookmark It

Search this book:
 
Previous Table of Contents Next


Chapter 7
Frames and Animation

  Frame Hierarchies
  Key-Framing

The subject of this chapter is animation. In particular, we are interested in animation techniques supported by Direct3D. As it turns out, Direct3D provides strong general-purpose animation support.

We’ve already seen some of Direct3D’s animation support. Some of the demos in chapters 5 and 6 used the Direct3DRMFrame interface to animate meshes. The Decal demo (Chapter 5) and the Firefly demo (Chapter 6) use dummy frames and rotation attributes to perform animation. Other demos use callback functions to adjust a frame’s position and/or orientation. Frames provide a powerful animation tool, especially when organized in hierarchies. We’ll look at frame hierarchies in this chapter.

We will also explore Direct3D’s key-framing support. Key-framing support is provided by the Direct3DRMAnimation interface and provides flexible, general purpose animation capabilities.

We’ll study these demos in this chapter:

  Molecule
  Rocket
  Target

We’ll use the Molecule demo to study frame hierarchies. The Rocket and Target demos provide examples of key-framing. The Target demo uses several animation techniques in addition to key-framing.

Frame Hierarchies

All Direct3D scenes are constructed using frame hierarchies. The demos that we’ve looked at so far use simple hierarchies consisting of a single root frame and any number of child frames. Although we have been using frame hierarchies all along, it hasn’t been very obvious because the hierarchies have been very simple. Figure 7.1 shows a simple frame hierarchy, typical of those used by previous demos.


Figure 7.1  A simple frame hierarchy.

The frames in Figure 7.1 are named to suggest their purpose. The hierarchy shown might appear in any application that uses two meshes, a light source, and a camera.

We have seen demos with more complicated frame hierarchies in previous chapters. The Decal and Firefly demos use dummy frames, so the frame hierarchy is slightly more complicated. The frame hierarchy used by these two demos looks like the hierarchy that appears in Figure 7.2.


Figure 7.2  A slightly more complex frame hierarchy.

In the hierarchy shown in Figure 7.2, the second mesh frame (mesh2frame) is attached to a dummy frame instead of the scene’s root frame. This allows the second mesh frame to be animated either by moving the mesh2frame or the dummy frame. You may want to review the Decal and Firefly demos if you are unclear on dummy frames.

The Molecule Demo

The Molecule demo uses frame hierarchies to model theoretical molecular structures. The demo constructs a frame hierarchy and attaches spherical meshes to each frame in the hierarchy. The size and color of the attached mesh depends on the frame’s location within the hierarchy. The Molecule demo provides menu commands that allow the complexity of the molecule to be adjusted. The Molecule demo appears in Figure 7.3.


Figure 7.3  The Molecule demo.

The demo’s Depth menu allows the depth of the frame hierarchy to be adjusted. The menu allows depths ranging from one through six. A setting of one means that the molecule will consist of just one sphere. A setting of six means that the frame hierarchy has six levels of child frames.

The Children menu allows you to specify the number of child frames. By default, each frame in the hierarchy has two children. The Children menu allows one, two, three, or four children to be specified.

These two menus allow the Molecule’s frame hierarchy to be modified considerably. A depth setting of one, for example, creates a frame hierarchy with only one frame. The default setting (depth=4, children=2) produces 15 frames. The maximum setting (depth=6, children=4) produces a hierarchy with 1,365 frames.

The Molecule demo demonstrates the following techniques:

  Using the Direct3DRMFrame interface and recursive functions to create frame hierarchies
  Using mesh instances
  Using menu commands to adjust the frame hierarchy settings


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.