# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CLightingManager Class Reference

Owned by CLightingTrav. More...

#include <lighting_manager.h>

List of all members.

Public Methods

 CLightingManager ()
 Constructor. More...

void computeModelLightContributions (CTransform *model, CLightContribution &lightContrib, ILogicInfo *logicInfo=NULL)
 get the description of nearsest lights viewed for this model. More...

Parameters
void setMaxLightContribution (uint nlights)
 set the max number of point light that can influence a model. More...

uint getMaxLightContribution () const
void setNoAttLightRadius (float noAttLightRadius)
 Advanced. More...

float getNoAttLightRadius () const
void setOutOfAttLightInfFactor (float outOfAttLightInfFactor)
 Advanced. More...

float getOutOfAttLightInfFactor () const
void setLightTransitionThreshold (float lightTransitionThreshold)
 Advanced. More...

float getLightTransitionThreshold () const
Dynamic Lights localisation.
void clearDynamicLights ()
 clear for the pass all the lights. More...

void addDynamicLight (CPointLight *light)
 temp add a dynamic light to the manager. More...

const std::vector< CPointLight * > & getAllDynamicLightList () const
 retrieve (for this pass only) list of all pointLights visible in scene. More...

Static Lighted Objects Localisation. Used for lights to touch nearest static models.
CQGItLightedModel eraseStaticLightedModel (CQGItLightedModel ite)
 erase a lighted object to the _StaticLightedModelQuadGrid. More...

CQGItLightedModel insertStaticLightedModel (CTransform *model)
 insert a lighted object to the _StaticLightedModelQuadGrid. More...


Private Methods

void getDynamicPointLightList (const CVector &worldPos, std::vector< CPointLightInfluence > &lightList)
 get the list of dynamic light viewed from a position. append to lightList. More...


Private Attributes

CQuadGrid< CTransform * > _StaticLightedModelQuadGrid [NL3D_QUADGRID_LIGHT_NUM_LEVEL]
CQuadGrid< CPointLightInfo_LightQuadGrid [NL3D_QUADGRID_LIGHT_NUM_LEVEL]
float _LightQuadGridRadiusLimit [NL3D_QUADGRID_LIGHT_NUM_LEVEL]
std::vector< CPointLight * > _DynamicLightList
Parameters.
uint _MaxLightContribution
float _NoAttLightRadius
float _OutOfAttLightInfFactor
float _LightTransitionThreshold


Detailed Description

Owned by CLightingTrav.

This class compute modelContributions. It gets which dynamic light may influence a model, ask to ILogicInfo the contribution of staticLights then decides which light are best suitable to influence the model.

Author:
Lionel Berenguier , Nevrax France
Date:
2001

Definition at line 60 of file lighting_manager.h.


Constructor & Destructor Documentation

NL3D::CLightingManager::CLightingManager  
 

Constructor.

Definition at line 63 of file lighting_manager.cpp.

References _LightQuadGrid, _LightQuadGridRadiusLimit, _LightTransitionThreshold, _NoAttLightRadius, _OutOfAttLightInfFactor, _StaticLightedModelQuadGrid, NL3D_DEFAULT_LIGHT_TRANSITION_THRESHOLD, NL3D_DEFAULT_NOATT_LIGHT_RADIUS, NL3D_DEFAULT_OUT_OF_ATT_LIGHT_INF_FACTOR, NL3D_LIGHT_QUAD_GRID_ELTSIZE, NL3D_LIGHT_QUAD_GRID_FACTOR, NL3D_LIGHT_QUAD_GRID_RADIUS_LIMIT, NL3D_LIGHT_QUAD_GRID_SIZE, NL3D_QUADGRID_LIGHT_NUM_LEVEL, and setMaxLightContribution.


Member Function Documentation

void NL3D::CLightingManager::addDynamicLight CPointLight   light
 

temp add a dynamic light to the manager.

light is added to the _LightQuadGrid. This method calls CTransform::resetLighting() for all models around the light.

Additionaly light are added to a list (a vector of pointer), see getDynamicLightList()

Definition at line 144 of file lighting_manager.cpp.

References _DynamicLightList, _LightQuadGrid, _LightQuadGridRadiusLimit, _NoAttLightRadius, _StaticLightedModelQuadGrid, and NL3D_QUADGRID_LIGHT_NUM_LEVEL.

void NL3D::CLightingManager::clearDynamicLights  
 

clear for the pass all the lights.

Definition at line 130 of file lighting_manager.cpp.

References _DynamicLightList, _LightQuadGrid, and NL3D_QUADGRID_LIGHT_NUM_LEVEL.

void NL3D::CLightingManager::computeModelLightContributions CTransform   model,
CLightContribution   lightContrib,
ILogicInfo   logicInfo = NULL
 

get the description of nearsest lights viewed for this model.

Dynamic lights are parsed to get list of lights, and ILogicInfo->getStaticLightDesc() is parsed too. Then, maxLights are returned, which may be a blended result of max influence light.

NB: model->_LightContribution is filled with real contributions of lights. NB: model is append to the _LightedModelList of each contributed light NB: this list is valid until model->isNeedUpdateLighting() is true.

Definition at line 249 of file lighting_manager.cpp.

References _LightTransitionThreshold, _MaxLightContribution, _OutOfAttLightInfFactor, NLMISC::clamp, getDynamicPointLightList, NL3D_MAX_LIGHT_CONTRIBUTION, and NL3D::OptFastFloor.

CLightingManager::CQGItLightedModel NL3D::CLightingManager::eraseStaticLightedModel CQGItLightedModel    ite
 

erase a lighted object to the _StaticLightedModelQuadGrid.

must do it at deletion of the model or when it leaves freeHRC state. NB: default CQGItLightedModel (ie NULL) can be passed in.

Returns:
quadgrid.end(), ie NULL iterator.

Definition at line 210 of file lighting_manager.cpp.

References _StaticLightedModelQuadGrid, and NL3D_QUADGRID_LIGHT_NUM_LEVEL.

const std::vector<CPointLight*>& NL3D::CLightingManager::getAllDynamicLightList   const [inline]
 

retrieve (for this pass only) list of all pointLights visible in scene.

Definition at line 126 of file lighting_manager.h.

References _DynamicLightList.

void NL3D::CLightingManager::getDynamicPointLightList const CVector &    worldPos,
std::vector< CPointLightInfluence > &    lightList
[private]
 

get the list of dynamic light viewed from a position. append to lightList.

Definition at line 460 of file lighting_manager.cpp.

References _LightQuadGrid, and NL3D_QUADGRID_LIGHT_NUM_LEVEL.

Referenced by computeModelLightContributions.

float NL3D::CLightingManager::getLightTransitionThreshold   const [inline]
 

Definition at line 109 of file lighting_manager.h.

References _LightTransitionThreshold.

uint NL3D::CLightingManager::getMaxLightContribution   const [inline]
 

Definition at line 84 of file lighting_manager.h.

References _MaxLightContribution.

float NL3D::CLightingManager::getNoAttLightRadius   const [inline]
 

Definition at line 91 of file lighting_manager.h.

References _NoAttLightRadius.

float NL3D::CLightingManager::getOutOfAttLightInfFactor   const [inline]
 

Definition at line 98 of file lighting_manager.h.

References _OutOfAttLightInfFactor.

CLightingManager::CQGItLightedModel NL3D::CLightingManager::insertStaticLightedModel CTransform   model
 

insert a lighted object to the _StaticLightedModelQuadGrid.

must not be inserted before must do it only for static objects, ie when freeHRC state is validated (see CTransform::update()) NB: only lightable models with no AncestorSkeletonModel should be inserted

Definition at line 224 of file lighting_manager.cpp.

References _StaticLightedModelQuadGrid, and NL3D_QUADGRID_LIGHT_NUM_LEVEL.

void NL3D::CLightingManager::setLightTransitionThreshold float    lightTransitionThreshold
 

Advanced.

When a model is influenced by more light than allowed, or when it reach the limits of the light (attenuationEnd), the light can be darkened according to some threshold. The resultLightColor begin to fade when distModelToLight== attEnd- threshold*(attEnd-attBegin). when distModelToLight== 0, resultLightColor==Black. By default, this value is 0.1f. Setting higher values will smooth transition but will generally darken the global effects of lights. NB: clamp(value, 0, 1);

Definition at line 121 of file lighting_manager.cpp.

References _LightTransitionThreshold, and NLMISC::clamp.

void NL3D::CLightingManager::setMaxLightContribution uint    nlights
 

set the max number of point light that can influence a model.

NB: clamped by NL3D_MAX_LIGHT_CONTRIBUTION Default is 3. NB: the sun contribution is not taken into account

Definition at line 98 of file lighting_manager.cpp.

References _MaxLightContribution, min, and NL3D_MAX_LIGHT_CONTRIBUTION.

Referenced by CLightingManager.

void NL3D::CLightingManager::setNoAttLightRadius float    noAttLightRadius
 

Advanced.

When a light has no attenuation, it's still inserted in a quadgrid with some radius and won't influence models beyond. You can setup this radius with this method. Default is 1000m. NB: nlassert(noAttLightRadius>0);

Definition at line 105 of file lighting_manager.cpp.

References _NoAttLightRadius, and nlassert.

void NL3D::CLightingManager::setOutOfAttLightInfFactor float    outOfAttLightInfFactor
 

Advanced.

When a model is out of [AttBegin, AttEnd] of a light, the computed influence of the light used to choose "best lights" is not constant, and is a function of distance multiplied by a factor you can setup here. Default is 0.1f and is good for lights with att like (50, 100) (arbitrary).

Definition at line 113 of file lighting_manager.cpp.

References _OutOfAttLightInfFactor.


Member Data Documentation

std::vector<CPointLight*> NL3D::CLightingManager::_DynamicLightList [private]
 

Definition at line 181 of file lighting_manager.h.

Referenced by addDynamicLight, clearDynamicLights, and getAllDynamicLightList.

CQuadGrid<CPointLightInfo> NL3D::CLightingManager::_LightQuadGrid[NL3D_QUADGRID_LIGHT_NUM_LEVEL] [private]
 

Definition at line 177 of file lighting_manager.h.

Referenced by addDynamicLight, clearDynamicLights, CLightingManager, and getDynamicPointLightList.

float NL3D::CLightingManager::_LightQuadGridRadiusLimit[NL3D_QUADGRID_LIGHT_NUM_LEVEL] [private]
 

Definition at line 179 of file lighting_manager.h.

Referenced by addDynamicLight, and CLightingManager.

float NL3D::CLightingManager::_LightTransitionThreshold [private]
 

Definition at line 188 of file lighting_manager.h.

Referenced by CLightingManager, computeModelLightContributions, getLightTransitionThreshold, and setLightTransitionThreshold.

uint NL3D::CLightingManager::_MaxLightContribution [private]
 

Definition at line 185 of file lighting_manager.h.

Referenced by computeModelLightContributions, getMaxLightContribution, and setMaxLightContribution.

float NL3D::CLightingManager::_NoAttLightRadius [private]
 

Definition at line 186 of file lighting_manager.h.

Referenced by addDynamicLight, CLightingManager, getNoAttLightRadius, and setNoAttLightRadius.

float NL3D::CLightingManager::_OutOfAttLightInfFactor [private]
 

Definition at line 187 of file lighting_manager.h.

Referenced by CLightingManager, computeModelLightContributions, getOutOfAttLightInfFactor, and setOutOfAttLightInfFactor.

CQuadGrid<CTransform*> NL3D::CLightingManager::_StaticLightedModelQuadGrid[NL3D_QUADGRID_LIGHT_NUM_LEVEL] [private]
 

Definition at line 176 of file lighting_manager.h.

Referenced by addDynamicLight, CLightingManager, eraseStaticLightedModel, and insertStaticLightedModel.


The documentation for this class was generated from the following files: