Class: TSpotLight

Declaration: LightSource.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TLight

Inherited By:

None.

Purpose:

TSpotLight is a concrete derived class of TLight. TSpotLight represents a nearby light source whose rays are not parallel and whose intensity is strongest within a certain conical region (due to a lampshade, for example). For a more natural effect, the TSpotLight class actually provides two cones: within the inner cone, the intensity is the greatest; outside the outer cone, the intensity is zero; and in the region between the inner and outer cones, the intensity is interpolated between these two extremes. A TSpotLight is defined by its position, direction vector, color, inner and the outer cone angles, and fall-off exponent. Within the outer cone, the intensity is determined by the following factors: the distance attenuation; the fall-off factor based on the off-axis angle and the fall-off exponent; and the fuzziness factor that causes a smooth interpolation of the intensity in the region between the inner cone and the outer cone. The defaults are: position =TGPoint3D(1000,1000,1000), direction vector =TGPoint(1,1,1), color =white, inner cone angle =20 degrees, outer cone angle =25 degrees, fall-off exponent =4.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

None.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TSpotLight::TSpotLight

  1. TSpotLight ()
  2. TSpotLight (const TGPoint3D & position, const TGPoint3D & directionVector, const TColor & color, GDegrees innerConeAngle, GDegrees outerConeAngle, double falloffExp)
  3. TSpotLight (const TSpotLight & spotLight)

Interface Category:

API.

Purpose:

  1. Default constructor. The default position is set to (1000,1000,1000); the default direction vector is set to (1,1,1); the default color is set to white; the default inner cone angle is set to 20 degrees; the default outer cone angle is set to 25 degrees; the fall-off exponent is set to four.
  2. Constructor that sets the position, direction vector, color, inner cone angle, outer cone angle, and fall-off exponent of the spotlight.
  3. Copy constructor.

Calling Context:

  1. Called by the stream-in operators. You can also call this function directly.
  2. Call this function directly.
  3. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::~TSpotLight

virtual ~ TSpotLight ()

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: TSpotLight::ComputeDiffuse

virtual void ComputeDiffuse (const TShadingSample & shadingInfo, 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 if there is no diffuse light reaching the location.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::ComputeSpecular

virtual void ComputeSpecular (const TShadingSample & shadingInfo, const TSceneState & sceneState, double specularExp, TColor & resultantColor)

Interface Category:

API.

Purpose:

Calculates the specular intensity of the light at a particular surface location. The function returns kBlack if there is no specular light component at the location.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::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.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::SetPosition

virtual void SetPosition (const TGPoint3D & position)

Interface Category:

API.

Purpose:

Sets the position of the spotlight.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::SetDirection

virtual void SetDirection (const TGPoint3D & position)

Interface Category:

API.

Purpose:

Sets the direction vector of the spotlight. The direction vector is internally normalized, so you pass the vector that starts at the source and points toward the light.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::SetColor

virtual void SetColor (const TColor & color)

Interface Category:

API.

Purpose:

Sets the color of the spotlight.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::SetConeAngles

virtual void SetConeAngles (double innerConeAngle, double outerConeAngle)

Interface Category:

API.

Purpose:

Sets both the inner and outer cone angles of the spotlight. Inside the inner cone angle the light is brightest. Outside the outer cone angle the light intensity is zero.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::SetFalloffExponent

virtual void SetFalloffExponent (double falloffExp)

Interface Category:

API.

Purpose:

Sets the fall-off exponent of the spotlight. This is used to compute the intensity level of light in areas between the inner and outer angles of the spotlight.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::GetPosition

virtual TGPoint3D GetPosition () const

Interface Category:

API.

Purpose:

Gets the position of the spotlight.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the position of the spotlight.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::GetNormalizedDirection

virtual TGPoint3D GetNormalizedDirection () const

Interface Category:

API.

Purpose:

Gets the normalized direction vector of the spotlight. Because the direction vector is normalized internally, this function returns the direction vector that starts at the source and points towards the spotlight.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the direction vector of the spotlight.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::GetColor

virtual void GetColor (TColor & color)

Interface Category:

API.

Purpose:

Returns the color of the spotlight.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::GetConeAngles

virtual void GetConeAngles (double & innerConeAngle, double & outerConeAngle)

Interface Category:

API.

Purpose:

Gets the inner and outer cone angles.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::GetFalloffExponent

virtual double GetFalloffExponent ()

Interface Category:

API.

Purpose:

Returns the fall-off exponent used to compute the intensity of light between the inner and outer cone angles.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the fall-off intensity of the spotlight.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::operator=

TSpotLight & operator =(const TSpotLight & Src)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function by using the operator in an assignment statement.

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.

Member Function: TSpotLight::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.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TSpotLight::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.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.