LightManager Class Reference


lightScene( const char*, const char* )
Will generate static lighting (aka lightmaps) for the scene if supported by the active light manager. If mode is "forceAlways", the lightmaps will be regenerated regardless of whether lighting cache files can be written to. If mode is "forceWritable", then the lightmaps will be regenerated only if the lighting cache files can be written.

Syntax

lightScene(const char* callback, const char* param )
  • callback:  The name of the function to execute when the lighting is complete.
  • param: Either "forceAlways" or "forceWritable".

Returns
  • bool: Returns true if the scene lighting process was started.

Examples
// Get the sunlight.
LightInfo *sunLight = mLightManager->getSpecialLight( LightManager::slSunLightType );

getSceneLightingInterface( )
Will return the AvailableSLInterfaces for the LightManager, if there is no available lighting system then it will create a new AvailableSLInterfaces and then return that.

Syntax

getSceneLightingInterface()

Returns
  • LightInfo *: The LightInfo * of the special light.

Examples
// From PersistInfo::read 
SceneLightingInterfaces sli = LIGHTMGR->getSceneLightingInterface()->
    mAvailableSystemInterfaces;

_update4LightConsts( const SceneGraphData &sgData, GFXShaderConstHandle *, GFXShaderConstHandle *,GFXShaderConstHandle *, GFXShaderConstHandle *, GFXShaderConstHandle *,GFXShaderConstHandle *,GFXShaderConstBuffer *)
Will update the shader constants of "GFXShaderConstBuffer *" depending on the validity of the "GFXShaderConstHandle *"'s passed in.

Syntax

update4LightConsts(const SceneGraphData &sgData, GFXShaderConstHandle *lightPositionSC, GFXShaderConstHandle *lightDiffuseSC, GFXShaderConstHandle *lightAmbientSC, GFXShaderConstHandle *lightInvRadiusSqSC, GFXShaderConstHandle *lightSpotDirSC, GFXShaderConstHandle **lightSpotAngleSC, GFXShaderConstBuffer *shaderConsts)
  • sgData: The scene graph data related to how the lights will be used.
  • lightPositionSC: The shader constant for the position paramter.
  • lightDiffuseSC: The shader constant for the diffuse paramter.
  • lightAmbientSC: The shader constant for the ambient paramter.
  • lightInvRadiusSqSC: The shader constant for the light inverse radius paramter.
  • lightSpotDirSC: The shader constant for the spot light direction paramter.
  • lightSpotAngleSC: The shader constant for the spot light angle paramter.
  • shaderConsts: The shader consts for the buffer.

Returns

No return value.


Examples
// From AdvancedLightManager::setLightInfo
// Update the forward shading light constants.
_update4LightConsts( sgData,
                        lsc->mLightPositionSC,
                        lsc->mLightDiffuseSC,
                        lsc->mLightAmbientSC,
                        lsc->mLightInvRadiusSqSC,
                        lsc->mLightSpotDirSC,
                        lsc->mLightSpotAngleSC,
                        shaderConsts );

getAllUnsortedLights( Vector * )
Will append all of the registered lights to the "Vector *" variable passed in.

Syntax

getAllUnsortedLights(Vector *list)
  • list: A vector of "LightInfo" pointers that will have the registered lights added to it.

Returns

No return value.


Examples
// From SceneLighting::light
LIGHTMGR->getAllUnsortedLights(&mLights);

unregisterAllLights()
Will clear out all of the special lights and registered lights.

Syntax

unregisterAllLights()

Returns

No return value.


Examples
// Unregister all the lights in the light manager.
LIGHTMGR->unregisterAllLights();

unregisterLocalLight( LightInfo * )
Empty function.

Syntax

Not used.

Returns

No return value.


Examples

None.


registerLocalLight( LightInfo * )
Empty function.

Syntax

Not used.

Returns

No return value.


Examples

None.


unregisterGlobalLight( LightInfo * )
Will remove the passed in light from the registered lights. If the light passed in is the sun, then it will clear the suns special light also.

Syntax

unregisterGlobalLight(LightInfo *light)
  • light: The light to be registered from mRegisteredLights.

Returns

No return value.


Examples
lightManager->unregisterGlobalLight( mLight );

registerGlobalLight( LightInfo *, SimObject * )
If the light is not already registered, then the light will be added to the registered lights. If it already added, a AssertFatal will be thrown.

Syntax

registerGlobalLight(LightInfo *light, SimObject *obj )
  • light: The light to be registered to mRegisteredLights.
  • obj: Not used.

Returns

No return value.


Examples
// From inside of Item::registerLights
lightManager->registerGlobalLight( mLight, this );

registerGlobalLights( const Frustum *, bool )

Register the lights depending if there is a Frustum or if there is static lighting. If there is no frustum or there is static lighting, then there will be no light culling. If there is a frustum or there is no static lighting, then cull the lights using the frustum.

After the decision for light culling or not, it will have the lights register themselves.



Syntax

registerGlobalLights(const Frustum *frustum, bool staticLighting )
  • frustrum: The frustum to be used for light culling.
  • staticLighting: Whether or not static lighting is being processed.

Returns

No return value.


Examples
// Get the lights for rendering the scene.
LIGHTMGR->registerGlobalLights( &sceneState->getFrustum(), false);

setSpecialLight( LightManager::SpecialLightTypesEnum, LightInfo * )

Register the light with the LightManager and set the light to one of the special light types for the LightManager.



Syntax

setSpecialLight(LightManager::SpecialLightTypesEnum type, LightInfo *light )
  • type: The special light type.
  • light: The light to apply the type to.

Returns

No return value.


Examples
// Set the sunlight. 
mLightManager->setSpecialLight( LightManager::slSunLightType, theSun );

getSpecialLight( LightManager::SpecialLightTypesEnum , bool )

Will return the special light based upon the type passed in if it is available. If it is not available, and the useDefault is set to true then it will return the result of getDefaultLight(). In the event that the special light is not found and useDefault is false, the function will return false.



Syntax

getSpecialLight(LightManager::SpecialLightTypesEnum type, bool useDefault )
  • type: The special light type to find.
  • useDefault: If the special light based up the light is not found, it will return the default light from getDefaultLight(). useDefault is set to true by default.

Returns
  • LightInfo *: The LightInfo * of the special light.

Examples
// Get the sunlight. 
LightInfo *sunLight = mLightManager->getSpecialLight( LightManager::slSunLightType );

getDefaultLight()

Will return the sun if it is registered, as it is always the default light. However, if the sun has not been registered yet then it will create a dummy special light.



Syntax

getDefaultLight()

Returns
  • LightInfo *: The LightInfo * of the default light.

Examples
// Get the default light, which will be the sun if it is registered
mLightManager->getDefaultLight();

deactivate()

Will check to see if the LightManager has been already been deactived and that it is the active light manager. If it is passes those two checks, it will call it's deactivate callback and then unregister all of the lights associated with LightManager (via unregiserAllLights(), detailed below).



Syntax

deactivate()

Returns

No return value.


Examples
// Deactivate the light manager
mLightManager->deactivate();

activate( SceneGraph *)

Will activate the LightManager if it is not already activate (in which case an AssertFatal will be thrown) and call the callback for activating the light manager.



Syntax

activate(SceneGraph *sceneManager);
  • sceneManager: The SceneGraph that will be used to activate rendering passes and the post effect fog if there is a prepass.

Returns

No return value.


Examples
// From inside of "SceneGraph::_setLightManager( LightManager *lm )" located in 
// sceneGraph.cpp
mLightManager->activate( this );

initLightFields()

A static function that will traverse the LightManagerMap and will call each LightManager's _initLightFields function. Since _initLightFields is a pure virtual function, it will call the derived classes _initLightFields.



Syntax

initLightFields()

Returns

No return value.


Examples
LightManager::initLightFields();

getLightManagerNames( String * )

A static function that will create a String containing all of the LightManager names from the LightManagerMap.



Syntax

getLightManagerNames(String *outString);
  • outString: The string that will be constructed based upon the available LightManger names from the LightManagerMap.

Returns

No return value.


Examples
If the LightManagerMap had two LightManager's inside of it, one being 
"Advanced Lighting" and the other "Basic Lighting" then outString will be 
"Advanced Lighting    Basic Lighting". The spacing between "Advanced Lighting" 
and "Basic Lighting" is a tab ("\\t").

findByName( const char * )

A static function that traverses the LightManagerMap for the LightManager with the name passed in. If no LightManager in the LightManagerMap contains that name, it will return NULL.



Syntax

findByName(const char *name);
  • name: The name of the LightManager to find.

Returns
  • LightManager*: The LightManager found in the LightManagerMap with the name passed in.

Examples
// Find the LightManager with the name "Advanced Lighting"
LightManager::findByName( "Advanced Lighting" )

_getLightManagers()

Returns the static LightManagerMap.



Syntax

_getLightManagers()

Returns
  • LightManagerMap

Examples
// Retrieve the LightManagerMap, example is from LightManagerMap::findByName
LightManagerMap &lightManagers = _getLightManagers();

~LightManager()

Will safely delete the default light and Available Scene Lighting Interfaces. It will also remove its self from the LightManagerMap.



Syntax

~LightManager()

Returns

No return value.


Examples
This function is called implicitly at the destruction of LightManager.

LightManager( const char *, const char * )

Initializes the class variables to the default values.



Syntax

LightManager(const char *name, const char * id);
  • name: The name of the LightManager.
  • id: The id of the LightManager, often an abbreviation of the name.

Returns

No return value.


Examples
// The LightManager being given the name "Advanced Lighting" and the id of "ADVLM"
LightManager( "Advanced Lighting", "ADVLM" )