virtual TLightSurrogate AdoptLight( TLight* aLight ); virtual TLight* OrphanLight( const TLightSurrogate& lightSurrogate ); virtual TLight* ReplaceLight( const TlightSurrogate& lightSurrogate, TLight* aNewLight);
ComputeDiffuse and ComputeSpecular are called by a shader that adds up the diffuse and specular reflection from all lights in the scene bundle. This summation occurs in the implementations of the Diffuse and Specular functions for each TShader derived class.
The ComputeDiffuse function computes the diffuse color by iterating through the light list, calling the ComputeDiffuse function for each light, and adding the returned value to the diffuse color.
The ComputeSpecular function computes the specular color by iterating through the light list, calling the ComputeSpecular function for each light, and adding the returned value to the specular color.
ComputeIntensity is called by both ComputeDiffuse and ComputeSpecular. It calculates the intensity of a light at the location of interest, which is most often the surface point to be shaded.
color: The color of t the light.
color: The color of the light.
vector: A point to which the rays are parallel. The default is TGPoint3D( 1, 1, 1 ).
color: The color of the light. The default is TRGBColor( 1, 1, 1 ).
fallOffExponent: A factor used to calculate the color intensity for the outer cone. The default is 4.
innerConeAngle: The angle at which the inner cone of the spotlight tilts. The default is 20 degrees.
outerConeAngle: The angle at which the outer cone of the spotlight tilts. The default is 25 degrees. The intensity is determined by the distance attenuation; the falloff factor based on the off-axis angle and the falloff exponent; and the fuzzy factor that causes a smooth interpolation of the intensity in the region between the inner cone and the outer cone.
Point light
A point light emits a light similar in intensity to the light emitted by a small light bulb.An attenuation factor that is computed internally reduces the light intensity as a function of the distance between a surface point and the light. This ensures that surfaces of the same coordinate and orientation with respect to the light, but at different distances from the light, are not assigned the same intensity.
position: The location from which the light emanates.TPointLight( const TGPoint3D& position, const TColor& color );
Parallel light
A parallel light is a light that is similar to sunlight. The attenuation factor is not involved in the intensity calculation. The directional vector does not need to be normalized and causes an exception if the vector is zero (all points set to zero).
vector: A 3-D point to which the light is parallel.TParallelLight( const TGPoint3D& vector, const TColor& color );
Spotlight
A spotlight is a direct, non-parallel light that has two cones for a lampshade effect. The intensity is greatest within the inner cone, zero outside the outer cone, and interpolated between these two extremes for the region between the inner and outer cones. Figure 212 shows a spotlight and its parts.
position: The spotlight location. The default is TGPoint3D(1000, 1000, 1000). TSpotLight( const TGPoint3D& position,
const TGPoint3D& vector,
const TColor& color,
double fallOffExponent,
gDegrees innerConeAngle,
gDegrees outerConeAngle );
ComputeColor
The derived classes of TLight have a ComputeColor function that returns the color of a light at the location of interest, which is often the surface point to be shaded. You can implement a ComputeColor function to create interesting light sources such as the window light shown in Figure 213