NL3D::CLightTrav Class Reference

#include <light_trav.h>

Inheritance diagram for NL3D::CLightTrav:

NL3D::CTraversal

Detailed Description

The light traversal. The purpose of this traversal is to compute lighting on lightable objects.

Lightable objects can be CTransform only.

NB: see CScene for 3d conventions (orthonormal basis...)

Author:
Lionel Berenguier

Nevrax France

Date:
2000

Definition at line 60 of file light_trav.h.

Public Member Functions

 CLightTrav (bool bSmallScene)
 Constructor.

LightingList. Filled during clip traversal.
void addLightedModel (CTransform *m)
 Add a model to the list of lighted models. DOESN'T CHECK if already inserted.

void clearLightedList ()
 Clear the list of lighted models.

void reserveLightedList (uint numModels)
 Add a model to the list of lighted models. DOESN'T CHECK if already inserted.

LightingList. Add a PointLightModel to the list.
void addPointLightModel (CPointLightModel *pl)
void traverse ()

Data Fields

CLightingManager LightingManager
 The lightingManager, where objects/lights are inserted, and modelContributions are computed.

bool LightingSystemEnabled
CSceneScene

Private Attributes

uint32 _CurrentNumVisibleModels
CFastPtrList< CPointLightModel_DynamicLightList
std::vector< CTransform * > _LightedList


Constructor & Destructor Documentation

NL3D::CLightTrav::CLightTrav bool  bSmallScene  ) 
 

Constructor.

Definition at line 45 of file light_trav.cpp.

References _LightedList, and LightingSystemEnabled.

00045                                        : LightingManager(bSmallScene)
00046 {
00047         _LightedList.resize(1024);
00048         _CurrentNumVisibleModels= 0;
00049 
00050         LightingSystemEnabled= false;
00051 }


Member Function Documentation

void NL3D::CLightTrav::addLightedModel CTransform m  )  [inline]
 

Add a model to the list of lighted models. DOESN'T CHECK if already inserted.

Definition at line 77 of file light_trav.h.

References _LightedList.

Referenced by NL3D::CClipTrav::clipSkeletonShadowMaps(), and NL3D::CTransform::traverseClip().

void NL3D::CLightTrav::addPointLightModel CPointLightModel pl  ) 
 

Definition at line 61 of file light_trav.cpp.

References _DynamicLightList, NL3D::CPointLightModel::_PointLightNode, and NL3D::CFastPtrList< CPointLightModel >::insert().

Referenced by NL3D::CPointLightModel::initModel().

00062 {
00063         _DynamicLightList.insert(pl, &pl->_PointLightNode);
00064 }

void NL3D::CLightTrav::clearLightedList  ) 
 

Clear the list of lighted models.

Definition at line 54 of file light_trav.cpp.

Referenced by NL3D::CClipTrav::traverse().

00055 {
00056         _CurrentNumVisibleModels= 0;
00057 }

void NL3D::CLightTrav::reserveLightedList uint  numModels  ) 
 

Add a model to the list of lighted models. DOESN'T CHECK if already inserted.

Definition at line 124 of file light_trav.cpp.

References _LightedList, and uint.

Referenced by NL3D::CScene::createModel().

00125 {
00126         // enlarge only.
00127         if(numModels>_LightedList.size())
00128                 _LightedList.resize(numModels);
00129 }

void NL3D::CLightTrav::traverse  ) 
 

Definition at line 68 of file light_trav.cpp.

References _DynamicLightList, _LightedList, NL3D::CFastPtrList< CPointLightModel >::begin(), NL3D::CLightingManager::clearDynamicLights(), H_AUTO, LightingManager, LightingSystemEnabled, NL3D::CFastPtrList< CPointLightModel >::size(), and uint.

Referenced by NL3D::CScene::render().

00069 {
00070         H_AUTO( NL3D_TravLight );
00071 
00072         uint i;
00073 
00074 
00075         // If lighting System disabled, skip
00076         if(!LightingSystemEnabled)
00077                 return;
00078 
00079         /* for each visible lightable transform, reset them only if they have MergedPointLight.
00080                 NB: dynamic objetcs don't need it because already done in traverseHRC() 
00081                 (but don't worry, reset state is flagged, so resetLighting() no op...)
00082                 This is important only for static object (freezeHRC()).
00083                 Why? because we are not sure the MergedPointLight does not represent moving DynamicPointLights.
00084                 Actually, it surely does. Because most of the static light setup return<=2 lights, and MaxLightContribution 
00085                 is typically==3. So any additional light may surely be a dynamic one.
00086                 NB: this may not be usefull since dynamicLights resetLighting() of all models in range. But this is important
00087                 when the dynamic light leave the model quiclky! (because don't dirt the model).
00088                 NB: this is also usefull only if there is no dynamic light but the ones merged in MergedPointLight. 
00089                 Because dynamic always reset their old attached models (see below). This still can arise if for example 
00090                 _MaxLightContribution=2 and there is a FrozenStaticLightSetup of 2 lights....
00091         */
00092         for(i=0; i<_CurrentNumVisibleModels; i++ )
00093         {
00094                 // if the model has a MergedPointLight, reset him (NB: already done for dynamics models) 
00095                 if(_LightedList[i]->useMergedPointLight())
00096                 {
00097                         _LightedList[i]->resetLighting();
00098                 }
00099         }
00100 
00101 
00102         // clear the quadGrid of dynamicLights
00103         LightingManager.clearDynamicLights();
00104 
00105         // for each lightModel, process her: recompute position, resetLightedModels(), and append to the quadGrid.
00106         CPointLightModel        **pLight= _DynamicLightList.begin();
00107         uint    numPls= _DynamicLightList.size();
00108         for(;numPls>0;numPls--, pLight++)
00109         {
00110                 (*pLight)->traverseLight();
00111         }
00112 
00113         // for each visible lightable transform
00114         for(i=0; i<_CurrentNumVisibleModels; i++ )
00115         {
00116                 // traverse(), to recompute light contribution (if needed).
00117                 _LightedList[i]->traverseLight();
00118         }
00119 
00120 }


Field Documentation

uint32 NL3D::CLightTrav::_CurrentNumVisibleModels [private]
 

Definition at line 105 of file light_trav.h.

CFastPtrList<CPointLightModel> NL3D::CLightTrav::_DynamicLightList [private]
 

Definition at line 108 of file light_trav.h.

Referenced by addPointLightModel(), and traverse().

std::vector<CTransform*> NL3D::CLightTrav::_LightedList [private]
 

Definition at line 104 of file light_trav.h.

Referenced by addLightedModel(), CLightTrav(), reserveLightedList(), and traverse().

CLightingManager NL3D::CLightTrav::LightingManager
 

The lightingManager, where objects/lights are inserted, and modelContributions are computed.

Definition at line 97 of file light_trav.h.

Referenced by NL3D::CLandscapeModel::clipAndRenderLandscape(), NL3D::CScene::getLightTransitionThreshold(), NL3D::CScene::getMaxLightContribution(), NL3D::CScene::setLightTransitionThreshold(), NL3D::CScene::setMaxLightContribution(), traverse(), NL3D::CTransform::traverseLight(), NL3D::CPointLightModel::traverseLight(), NL3D::CTransform::unfreezeHRC(), NL3D::CTransform::update(), and NL3D::CTransform::~CTransform().

bool NL3D::CLightTrav::LightingSystemEnabled
 

Definition at line 94 of file light_trav.h.

Referenced by CLightTrav(), NL3D::CScene::enableLightingSystem(), and traverse().

CScene* NL3D::CTraversal::Scene [inherited]
 

Definition at line 55 of file trav_scene.h.

Referenced by NL3D::CScene::CScene(), NL3D::CMeshMRMSkinnedGeom::profileSceneRender(), NL3D::CMeshMRMGeom::profileSceneRender(), and NL3D::CMeshGeom::profileSceneRender().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:49:33 2004 for NeL by doxygen 1.3.6