Class: TImageMapShader

Declaration: SampleShaders.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TShader

Inherited By:

None.

Purpose:

TImageMapShader is a concrete class, derived from TShader, that maps a 2-D image to a 3-D surface, much like applying wallpaper. The image is stored in a TImageMap object (which is NIL by default and which you should set by a constructor argument or by invoking TImageMapShader::SetImageMap). TImageMapShader::ComputeShade overrides that of the TShader base class. TImageMapShader::ComputeShade first extracts a value from the TImageMap, using the texture coordinate to determine which spot in the map should be used. The value extracted from TImageMap is used as the base color for the current point on the object's surface, replacing whatever color was set in the graphic's bundle. The TImageMapShader has a subsidiary shader that it uses to perform additional shading after extracting the color from the texture map. By default, this shader is a TReflectanceShader, but by invoking TImageMapShader::SetChildShader (or with a constructor argument) you can replaced the default shader with an instance of any other class that descends from TShader. The TImageMapShader automatically invokes this subsidiary shader's ComputeShade member function to perform the additional shading.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

None.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TImageMapShader::TImageMapShader

  1. TImageMapShader ()
  2. TImageMapShader (const TImageMap & map)
  3. TImageMapShader (const TImageMap & map, const TShader & childShader)
  4. TImageMapShader (const TImageMapShader & source)

Interface Category:

API.

Purpose:

  1. Default constructor. Sets the image map to NIL and the child shader to a TReflectanceShader.
  2. Constructor that sets the image map to the given map.
  3. Constructor that sets both the image map and the child shader to the given values.
  4. Copy constructor.

Calling Context:

  1. Called by the stream-in operators. You can also call this function directly.
  2. Call this function directly.
  3. Call this function directly.
  4. 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: TImageMapShader::~TImageMapShader

virtual ~ TImageMapShader ()

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: TImageMapShader::SetImageMap

virtual void SetImageMap (const TImageMap & imageMap)

Interface Category:

API.

Purpose:

Sets the image map to the specified TImageMap.

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: TImageMapShader::GetImageMap

virtual const TImageMap * GetImageMap () const

Interface Category:

API.

Purpose:

Returns a pointer to the current image map held by this object.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a constant pointer to a TImageMap object that represents the image map held by this object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TImageMapShader::ComputeShade

virtual void ComputeShade (TShadingSample & shadingInfo, const TSceneState & sceneState)

Interface Category:

API.

Purpose:

Computes the resultant color and other shading variables, given the current surface point and scene state.

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: TImageMapShader::SetChildShader

virtual void SetChildShader (const TShader & aShader)

Interface Category:

API.

Purpose:

Sets the child shader, which is used to shade the base color after it is chosen from the image map, to the given shader.

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: TImageMapShader::GetChildShader

virtual TShader * GetChildShader () const

Interface Category:

API.

Purpose:

Returns a pointer to the child shader held by this object.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a pointer to a TShader object that represents the shader used to shade the base color after it has been selected from the image map.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TImageMapShader::GetShadingUsageVariables

virtual void GetShadingUsageVariables (TShadingUsageVariables & variables) const

Interface Category:

API.

Purpose:

Returns a TShadingUsageVariables object specifying what information the shader needs in order to shade the surface. This is dependent upon the needs of the child shader as well as the needs of the image map color getter.

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: TImageMapShader::operator=

TImageMapShader & operator =(const TImageMapShader & source)

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: TImageMapShader::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: TImageMapShader::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.