![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
Texture WrappingTexture wrapping determines the manner in which the texture is applied to objects. The simplest wrapping method is one in which a texture is applied as if fired from a gun. The individual colors in the texture shoot straight through the object and come out the other side. This method is usually called a flat wrap (a bit of a paradox, since you cant wrap an object with something that is flat). Figure 2.19 applies the texture shown in Figure 2.18 to a cube using a flat texture wrap.
This method is frequently used on large objects, especially when the viewer will only see one side of the object. Flat wraps are easy to use because they require only that the direction of the texture application be specified. Because flat texture wraps apply textures to objects in only one direction, the sides of the object usually appear striped. Another common method is cylindrical. Cylindrical wrapping methods apply a texture to objects by bending or warping the texture into a cylinder. Figure 2.20 is a cylindrical wrap. Notice the seam where the texture edges meet.
Its important to remember that the texture wrapping method and the shape of the object being textured are completely independent. You can just as easily apply a flat wrap to a sphere as a spherical wrap to a cube. Direct3D supports flat, spherical, and cylindrical texture wrapping. Well study texture wrapping methods in more detail in Chapter 5. Texture AnimationRendering the same object with different textures or different texture wrap settings is called texture animation. A simple example is to apply the same texture to an object, but change the texture location with each animation frame. This causes the texture to move across the object. This technique is useful for representing a moving object such as a conveyor belt. Another example is to change the scale of the texture. These two methods are easy to implement (because they require only one texture), but are limited in usefulness. A more powerful texture animation technique is to use a different texture on an object for each animation frame. If, for instance, you wanted a scene with a television (and the television needed to be on), you could apply a different texture to the television screen for each screen update. This technique is very effective, but requires a lot of memory if the sequence of textures is long or if the texture is large. LightingOur translated, scaled, rotated, and textured objects can exist in a 3D world and never be seen if they remain in the dark. Before we can expect to see anything, we need to provide a light sources. When we view a final output, the objects in the scene will be rendered according to the qualities of the light sources contained in the scene. ColorAll light sources have a common attribute: color. Normally light sources are white, meaning that all color values are on at full intensity. Lighting systems vary from one graphics package to the next, but most use RGB (Red, Green, and Blue) values to define light source colors. In Direct3D, each RGB value can vary from zero (off) to one (on), so a white light has an RGB setting of 1, 1, 1. A red light has a 1, 0, 0 setting. A blue light has a 0, 1, 0 setting. Colors besides red, green, and blue can be represented by using mixture of these three colors. For example, yellow has an RGB setting of 1, 1, 0. Light TypesLight sources come in several forms. Typical light sources include ambient lights, point lights, and spotlights. Ambient Light The simplest light source is an ambient light. Ambient lights have no location and illuminate all of the objects in a scene with the same intensity. These lights are handy because they are easy to use. Ambient lights are often used in combination with more sophisticated light sources. Point Light A point light emanates light in all directions. Point lights have a specific location but no orientation. Point lights are fairly demanding in terms of processing time due to the requirement that light emanates in every direction. The cost in processing time is often worth the price, however, because of the realistic effects that point lights create. Point lights are sometimes called omni or omni-directional lights. Directional Light A more computationally efficient alternative to the point light is the directional light. Directional lights have orientation, but no location. The rays of light that a directional light produces are parallel to each other. Directional lights tend to make scenes look as if the light source is very far from the objects in the scene. Spot Light Spot lights have orientation and location, and produce light in the shape of a cone. The cone characteristics are determined by umbra and penumbra angles. The umbra angle defines the cone of light where the spotlight fully illuminates. The penumbra angle defines a cone of diminished light around the umbra cone. A spotlights penumbra angle is always greater that the umbra angle. Direct3D supports ambient light, point light, directional light, and spotlights. Direct3D also offers a variant on directional lights, called parallel light. Perspective TransformationAt the beginning of this chapter, I mentioned that the goal of 3D graphics is to present a two-dimensional representation of a three-dimensional scene. Weve covered manipulating the unseen, 3D universe; now well discuss producing a 2D version of the 3D world. The conversion from 3D to 2D requires a perspective transformation. A perspective transformation ensures that the final output looks and behaves correctly. Correct behavior means that objects closer to the viewer appear larger than distant objects. It means that objects or portions of objects located outside the scope of the scene are not drawn. It requires that we decide when an object is too far away or too close to be drawn at all.
|
![]() |
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. |