Public Member Functions | Public Attributes

LightDesc Class Reference

This reference page is linked to from the following overview topics: Principal Light Classes.


Search for all occurrences

Detailed Description

See also:
Class RenderData, Class LightRayTraversal, Class ObjLightDesc, Class ShadeContext, Class Color, Class Point3.

Description:
This class has a method Illuminate() used to determine the color and direction of the light striking the point sc.P() and a method to get the position of the light. It also has two public data members that determine if the diffuse and specular colors of objects are affected.
Data Members:
BOOL affectDiffuse;

This data member is available in release 2.0 and later only.

If TRUE the light affects the diffuse color; otherwise it does not.

BOOL affectSpecular;

This data member is available in release 2.0 and later only.

If TRUE the light affects the specular color; otherwise it does not.

BOOL ambientOnly;

This data member is available in release 3.0 and later only.

If TRUE the light affects the ambient color only; otherwise it does not.

DWORD extra;

This data member is available in release 3.0 and later only.

This is not currently used and is available for use in the future.

#include <imtl.h>

Inheritance diagram for LightDesc:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  LightDesc ()
virtual BOOL  Illuminate (ShadeContext &sc, Point3 &normal, Color &color, Point3 &dir, float &dot_nl, float &diffuseCoef)
virtual Point3  LightPosition ()
virtual CoreExport void  DeleteThis ()

Public Attributes

BOOL  affectDiffuse
BOOL  affectSpecular
BOOL  ambientOnly
DWORD  extra

Constructor & Destructor Documentation

LightDesc ( ) [inline]
Remarks:
Constructor. The affectDiffuse and affectSpecular data members are set to TRUE.
{ affectDiffuse = affectSpecular = TRUE; ambientOnly = FALSE; }

Member Function Documentation

virtual BOOL Illuminate ( ShadeContext sc,
Point3 normal,
Color color,
Point3 dir,
float &  dot_nl,
float &  diffuseCoef 
) [inline, virtual]
Remarks:
This method is called to determine the color and direction of illumination from the light that is hitting the point (sc.P()).
Parameters:
ShadeContext& sc

Describes the properties of the point to shade. The point itself is sc.P().

Point3& normal

The normal to the surface in camera space.

Color& color

The color that is returned. This is the brightness of light striking the point (sc.P())

Point3 &dir

The direction that the light is coming from.

float &dot_nl

This provides a bit of optimization as most lights will have to calculate this quantity. This is the dot product between the light vector and the normal to the surface.

float &diffuseCoef

This parameter should be set by the Illuminate function. The default value is the same as dot_nl. It will be used by shading functions instead of dot_nl to compute the diffuse illumination of the surface. The built-in lights use the new "Contrast" parameter (which has a range of [0..100]) to compute the diffuseCoef from the dot_nl by the Contrast function:
            // precomputed:
            float a = contrast/200.0f + 0.5f;                 // so "a" varies from .5 to 1.0
            kA = (2.0f-1.0f/a);
            kB = 1.0f-kA;
            
            // called by Illuminate() to compute diffuseCoef from dot_nl.
            float ContrastFunc(float nl)
            {
            // the "Bias" function described in Graphics Gems IV, pp. 401ff
                return (contrast==0.0f)? nl : nl/(kA*nl+kB);
            }
Returns:
Returns FALSE if the hitpoint is outside the effective range of the light or if the normal of the surface faces away from the light. This is a hint to the material that the light did not calculate its illumination because it is assumed it wasn't going to be used. If TRUE the point is being illuminated.
Default Implementation:
{ return 0;}
{ return 0;}
virtual Point3 LightPosition ( ) [inline, virtual]
Remarks:
Returns the position of the light.
Default Implementation:
{ return Point3(0,0,0); }

Reimplemented in ObjLightDesc.

{ return Point3(0,0,0); } 
virtual CoreExport void DeleteThis ( ) [virtual]
Remarks:
This method is used to delete an instance of the class.
Default Implementation:
{delete this; }

Implements RenderData.


Member Data Documentation

DWORD extra

LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc
LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc LightDesc