Class: TLight

Declaration: LightSource.h

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.

Member Function: TLight::~TLight

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:

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:

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:

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:

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:

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.

Member Function: TLight::TLight

  1. TLight ()
  2. TLight (const TLight & aLight)

Interface Category:

API.

Purpose:

  1. Default constructor. This is a protected constructor.
  2. Copy constructor. This is a protected constructor.

Calling Context:

  1. Called by the stream-in operators. Do not call this function directly.
  2. Called to copy an object. Do not call this function directly, except from a derived class' copy constructor.

Parameters:

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:

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.