![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
Direct3DRMShadow: The Shadow InterfaceDirect3D is designed for performance. This means that other design goals, such as precision and realism, are sometimes sacrificed. Direct3Ds 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 shadows effect. This emulation is only a rough approximation and has several limitations. A shadow is created by specifying the following items:
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 cant 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 InterfaceIn 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 KeysThe 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 objects settings between the key frames. The Animation interface supports the construction of key frames with these functions:
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 AnimationsOnce 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 animationeven 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 OptionsThe GetOptions() and SetOptions() member functions are used to specify an animations behavior. These options include:
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 objects 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 animations time value. The use position setting activates the animations 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 objects scale and rotation, but not its position. The use scale and rotation setting activates the animations 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 objects scale and rotation while the objects position is controlled by the animation object.
|
![]() |
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. |