3D Graphics Programming with QuickDraw 3D
TQ3LightObject
.
In general, the illumination of a surface in a scene is affected by multiple light sources. As a result, a view is associated with a light group, which is simply a group of lights. To illuminate the objects in the scene, you need to create a light group and attach it to a view (for example, by calling Q3LightGroup_New
and Q3View_SetLightGroup
).
If you do not attach a group of lights to a view, the results are renderer-specific.<8bat>u
QuickDraw3D supports multiple light sources and multiple types of lights in a given scene. QuickDraw3D defines four types of lights:
TQ3LightData
data structure.
typedef struct TQ3LightData { TQ3Boolean isOn; float brightness; TQ3ColorRGB color; } TQ3LightData;These fields specify the brightness (that is, the intensity) and color of the light and the current state (active or inactive) of the light. You can turn a light on and off by toggling the
isOn
field of a light data structure.As you will see, an ambient light is completely described by a light data structure. All other types of lights contain additional information, such as the location and direction of the light source. Those kinds of lights are defined by data structures that include a light data structure.
TQ3LightData
data structure.
Directional lights are therefore sometimes
also called infinite lights.<8bat>u
A directional light has no location. As a result, you specify the direction of
the light as a vector equivalent to the direction of the light. In addition, a directional light cannot suffer attenuation (that is, a loss of intensity over distance). It can, however, cast shadows.
A point light can suffer attenuation, in which case objects closer to the light source receive more illumination than objects farther away. QuickDraw3D allows you to specify one of several attenuation values that determine the precise amount by which the intensity of a point light decays over distance. For example, you can use the constant kQ3AttenuationTypeInverseDistance
to have the intensity of a point light be inversely proportional to the distance between the illuminated surface and the light source. See "Light Attenuation Values" on page 8-10 for a complete list of the available attenuation values.
A spot light's hot angle is the half-angle (specified in radians) from the center of the cone of light within which the light remains at constant full intensity. In Figure 8-1, h is the hot angle. A spot light's outer angle is the half angle (specified in radians) from the center of the cone to the edge of the cone. In Figure 8-1, o is the outer angle.
The attenuation of the light's intensity from the edge of the hot angle to
the edge of the outer angle is determined by the light's fall-off value. QuickDraw3D allows you to specify no fall-off, a linear fall-off, an
exponential fall-off, and a fall-off that is proportional to the cosine of the
angle. The available fall-off algorithms are illustrated in Figure 8-2.
Figure 8-2 Fall-off algorithms
See "Light Fall-Off Values" on page 8-10 for a description of the constants you can use to specify a spot light's fall-off value.
Let us know what you think of these prototype pages.
Generated with Harlequin WebMaker