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


Direct3DRMShadow: The Shadow Interface

Direct3D is designed for performance. This means that other design goals, such as precision and realism, are sometimes sacrificed. Direct3D’s shadow support is a good example of a design sacrifice because the rendering techniques used in Direct3D do not account for shadows. Shadow support comes in the form of an object that is added to a scene that emulates a shadow’s effect. This emulation is only a rough approximation and has several limitations.

A shadow is created by specifying the following items:

  The object casting the shadow.
  The light source used to calculate the shadow’s characteristics.
  A plane on which the shadow will appear.

The fact that a light source must be supplied points to the first limitation: each light source that is to cast a shadow must have its own shadow object. Shadow support is not a feature that can simply be enabled.

Another limitation is that the location of the shadow is defined by a plane. This means that you can’t cast a shadow over a complex object. Convincing shadows in Direct3D require flat surfaces.

Shadow objects are instances of the Direct3DRMShadow interface, and are created with the Direct3DRM CreateShadow() member function. The Shadow interface offers one member function: Init(). The Init() function is rarely necessary because the CreateShadow() function performs the same purpose and is easier to use.

Direct3DRMAnimation: The Animation Interface

In Direct3D, the term animation has two meanings. Animation is the movement of objects in a scene, but animation is also the name of an interface that supports the creation and playback of key-framed animations.

Creating Keys

The Direct3DRMAnimation interface allows the construction of an animation sequence based on keys. Each key is a translation, rotation, or scale factor that is to be applied to an object at a specific point in an animation. The Animation interface can then produce an entire animation based on a few keys by calculating an object’s settings between the key frames.

The Animation interface supports the construction of key frames with these functions:

  AddPositionKey()
  AddRotateKey()
  AddScaleKey()

Each of the addkey functions requires a time and a translation. The time indicates the point in the animation when the key is to take effect. The translation is the position, rotation, or scale that is to be used at the key frame. The total length of the animation is determined by the key with the largest time value. Keys can be removed from an animation with the DeleteKey() member function.

Setting Time In Animations

Once an animation has been constructed, the SetTime() member function can be used to determine the current location within the animation. The values sent to SetTime() depend on the values used to install the key frames.

The time values are floating point numbers, so keys can be installed anywhere in an animation—even if the total length of the animation is 1. This also allows an animation to run very slowly or very quickly by using small or large increments with the SetTime() member function.

Because arbitrary values can be sent to the SetTime() member function, animations can be stopped, started, sped up, slowed down, and even played in reverse.

Animation Options

The GetOptions() and SetOptions() member functions are used to specify an animation’s behavior. These options include:

  linear vs. spline animation
  open vs. closed animation
  use position
  use scale and rotation

Using linear animation means that the Animation interface will animate objects between key frames by calculating the shortest distance between keys. Spline-based animation uses curves to calculate an object’s position, providing a more rounded, flowing movement.

The open/close option determines how the Animation object interprets out-of-range time values used with the SetTime() function. In a closed animation, time values wrap around. That is, an out-of-range time value is subtracted by the greatest key value, so closed animations repeat themselves even when the time setting keeps increasing. Open animations ignore out-of-range time settings. This setting is purely for convenience, because an open animation can be repeated by re-starting the animation’s time value.

The use position setting activates the animation’s position keys. With this setting disabled, the position keys have no effect. Deactivating the position keys can be useful if you want an animation to control an object’s scale and rotation, but not its position.

The use scale and rotation setting activates the animation’s scale and rotation keys. When this setting is disabled, the scale and rotation keys have no effect. Deactivating this setting allow you to control an object’s scale and rotation while the object’s position is controlled by the animation object.


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.