Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
MCollectible
Inherited By:
TParallelLight
TPointLight
TSpotLight
Purpose:
TLight is an abstract base class that represents a light source for a 3-D scene. Derived classes (TPointLight, TParallelLight, and TSpotLight) define lights with different characteristics, such as color, location, and intensity. The TSceneBundle class maintains a list of all the light sources in a particular scene. Individual lights can be added to and removed from the scene using TSceneBundle member functions.
TLight provides three main member functions: TLight::ComputeDiffuse, TLight::ComputeSpecular, and TLight::ComputeIntensity. The base class implements all three functions by simply setting the resultant color to black; derived classes should override these member functions as needed. ComputeDiffuse and ComputeSpecular calculate the diffuse and the specular contribution, respectively, of a light at a particular surface location, based on the light's geometry, the surface orientation, the camera setting (for the specular computation), and the light's color. ComputeIntensity calculates the intensity of a light at the location of interest (the surface point to be shaded). The function can also be used to simulate shadows.
Instantiation:
Abstract class; do not allocate.
Deriving Classes:
Derived classes should override ComputeDiffuse, ComputeSpecular, and ComputeIntensity, and should add whatever other characteristics are desired (such as location, color, intensity, and geometry).
Concurrency:
Not multithread safe.
Resource Use:
No special requirements.
virtual ~ TLight ()
Interface Category:
API.
Purpose:
Destructor.
Calling Context:
Called to destroy an object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TLight::ComputeDiffuse
virtual void ComputeDiffuse (const TShadingSample & shadingSample, const TSceneState & sceneState, TColor & resultantColor)
Interface Category:
API.
Purpose:
Calculates the diffuse contribution of the light at a particular surface location. The function returns kBlack as a default value.
Calling Context:
You can call this function directly, but it designed to be overridden.
Parameters:
- const TShadingSample & shadingSample -The shading information for the point in question.
- const TSceneState & sceneState -The state of the scene.
- TColor & resultantColor -The resulting contribution of diffuse lighting for this sample location.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TLight::ComputeSpecular
virtual void ComputeSpecular (const TShadingSample & shadingSample, const TSceneState & sceneState, double specularExp, TColor & resultantColor)
Interface Category:
API.
Purpose:
Calculates the specular intensity of the light at a particular surface location. The default value is kBlack.
Calling Context:
You can call this function directly, but it is designed to be overridden.
Parameters:
- const TShadingSample & shadingSample -The shading information for the point in question.
- const TSceneState & sceneState -The state of the scene.
- double specularExp -The exponential value used to amplify the effect of the reflected light intensity.
- TColor & resultantColor -The resulting specular intensity at the surface location.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TLight::ComputeIntensity
virtual void ComputeIntensity (const TGPoint3D & position, TColor & resultantColor, double scale =1.)
Interface Category:
API.
Purpose:
Calculates the intensity of the light at a particular surface point. The default value is kBlack.
Calling Context:
You can call this function directly, but it is designed to be overridden.
Parameters:
- const TGPoint3D & position -The 3-D location in question.
- TColor & resultantColor -The resulting intensity.
- double scale =-The scale value used to multiply the intensity value by. The default scale value is 1.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TLight::operator>>=
virtual TStream & operator >>=(TStream &) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Parameters:
- TStream & -The stream that the object streams itself out to.
Return Value:
Returns a reference to the stream the object streams itself out to.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TLight::operator<<=
virtual TStream & operator <<= (TStream &)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Parameters:
- TStream & -The stream that the object streams itself in from.
Return Value:
Returns a reference to the stream the object streams itself in from.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
- TLight ()
- TLight (const TLight & aLight)
Interface Category:
API.
Purpose:
- Default constructor. This is a protected constructor.
- Copy constructor. This is a protected constructor.
Calling Context:
- Called by the stream-in operators. Do not call this function directly.
- Called to copy an object. Do not call this function directly, except from a derived class' copy constructor.
Parameters:
- Takes no parameters.
- const TLight & aLight -The object to be copied.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TLight::operator=
TLight & operator =(const TLight & src)
Interface Category:
API.
Purpose:
Assignment operator. This is a protected member function.
Calling Context:
Do not call this function directly, except from within a derived class' operator =function.
Parameters:
- const TLight & src -The object to be copied.
Return Value:
A non-const reference to the left-hand side object.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.