NL3D::CIGSurfaceLight Class Reference

#include <ig_surface_light.h>


Detailed Description

Class owned by CInstanceGroup to get StaticLightSetup for dynamic models. It owns a map of SurfaceIdent -> CSurfaceLightGrid
Author:
Lionel Berenguier

Nevrax France

Date:
2002

Definition at line 48 of file ig_surface_light.h.

Public Types

typedef TRetrieverGridMap::iterator ItRetrieverGridMap
typedef std::map< uint32,
CRetrieverLightGrid
TRetrieverGridMap

Public Member Functions

void build (const TRetrieverGridMap &retrieverGridMap, float cellSize, const std::vector< uint > &plRemap)
 CIGSurfaceLight ()
 Constructor. A CIGSurfaceLight MUST be owned by an CInstanceGroup (nlassert(_Owner!=NULL));.

void clear ()
 clear.

float getCellSize () const
float getOOCellSize () const
const TRetrieverGridMapgetRetrieverGridMap () const
bool getStaticLightSetup (uint retrieverIdentifier, sint surfaceId, const CVector &localPos, std::vector< CPointLightInfluence > &pointLightList, uint8 &sunContribution, NLMISC::CRGBA &localAmbient)
void serial (NLMISC::IStream &f)
void setOwner (CInstanceGroup *owner)

Private Attributes

float _CellSize
float _OOCellSize
CInstanceGroup_Owner
TRetrieverGridMap _RetrieverGridMap

Friends

class CSurfaceLightGrid


Member Typedef Documentation

typedef TRetrieverGridMap::iterator NL3D::CIGSurfaceLight::ItRetrieverGridMap
 

Definition at line 63 of file ig_surface_light.h.

Referenced by build(), and getStaticLightSetup().

typedef std::map<uint32, CRetrieverLightGrid> NL3D::CIGSurfaceLight::TRetrieverGridMap
 

Definition at line 62 of file ig_surface_light.h.

Referenced by NL3D::CInstanceGroup::build(), build(), and getRetrieverGridMap().


Constructor & Destructor Documentation

NL3D::CIGSurfaceLight::CIGSurfaceLight  ) 
 

Constructor. A CIGSurfaceLight MUST be owned by an CInstanceGroup (nlassert(_Owner!=NULL));.

Definition at line 35 of file ig_surface_light.cpp.

References _CellSize, and _OOCellSize.

00036 {
00037         _Owner= NULL;
00038         _CellSize= 1;
00039         _OOCellSize= 1;
00040 }


Member Function Documentation

void NL3D::CIGSurfaceLight::build const TRetrieverGridMap retrieverGridMap,
float  cellSize,
const std::vector< uint > &  plRemap
 

build. called by CInstanceLighter.

Parameters:
retrieverGridMap is the gridMap builded by CInstanceLighter
cellSize is the size in meter of a cell
plRemap is the array returned by CInstanceGroup::build() to remap indices

Definition at line 50 of file ig_surface_light.cpp.

References _CellSize, _OOCellSize, _RetrieverGridMap, NL3D::CSurfaceLightGrid::Cells, ItRetrieverGridMap, NL3D::CSurfaceLightGrid::CCellCorner::Light, NL3D::CSurfaceLightGrid::CCellCorner::LocalAmbientId, nlassert, NLMISC::CObjectVector< CCellCorner >::size(), TRetrieverGridMap, and uint.

Referenced by NL3D::CInstanceGroup::build().

00052 {
00053         _RetrieverGridMap= retrieverGridMap;
00054         nlassert(cellSize>0);
00055         _CellSize= cellSize;
00056         _OOCellSize= 1.f/_CellSize;
00057 
00058         // remap indices.
00059         ItRetrieverGridMap      it;
00060         for(it= _RetrieverGridMap.begin(); it!=_RetrieverGridMap.end(); it++)
00061         {
00062                 // For all grids of this retriever
00063                 for(uint iGrid= 0; iGrid<it->second.Grids.size(); iGrid++)
00064                 {
00065                         CSurfaceLightGrid       &grid= it->second.Grids[iGrid];
00066 
00067                         // For all cells of this grid.
00068                         for(uint iCell= 0; iCell<grid.Cells.size(); iCell++)
00069                         {
00070                                 CSurfaceLightGrid::CCellCorner  &cell= grid.Cells[iCell];
00071 
00072                                 // For all point light id.
00073                                 for(uint lid= 0; lid<CSurfaceLightGrid::NumLightPerCorner; lid++)
00074                                 {
00075                                         if(cell.Light[lid] == 0xFF)
00076                                                 break;
00077                                         else
00078                                                 cell.Light[lid]= plRemap[cell.Light[lid]];
00079                                 }
00080 
00081                                 // remap ambient light
00082                                 if(cell.LocalAmbientId!=0xFF)
00083                                         cell.LocalAmbientId= plRemap[cell.LocalAmbientId];
00084                         }
00085                 }
00086         }
00087 }

void NL3D::CIGSurfaceLight::clear  ) 
 

clear.

Definition at line 90 of file ig_surface_light.cpp.

References _CellSize, _OOCellSize, and _RetrieverGridMap.

Referenced by NL3D::CInstanceGroup::build(), and NL3D::CInstanceGroup::serial().

00091 {
00092         _RetrieverGridMap.clear();
00093         _CellSize= 1;
00094         _OOCellSize= 1;
00095 }

float NL3D::CIGSurfaceLight::getCellSize  )  const [inline]
 

Definition at line 98 of file ig_surface_light.h.

References _CellSize.

00098 {return _CellSize;}

float NL3D::CIGSurfaceLight::getOOCellSize  )  const [inline]
 

Definition at line 99 of file ig_surface_light.h.

References _OOCellSize.

Referenced by NL3D::CSurfaceLightGrid::getStaticLightSetup().

00099 {return _OOCellSize;}

const TRetrieverGridMap& NL3D::CIGSurfaceLight::getRetrieverGridMap  )  const [inline]
 

Definition at line 102 of file ig_surface_light.h.

References _RetrieverGridMap, and TRetrieverGridMap.

Referenced by NL3D::CIGSurfaceLightBuild::buildPLDebugMesh().

00102 {return _RetrieverGridMap;}

bool NL3D::CIGSurfaceLight::getStaticLightSetup uint  retrieverIdentifier,
sint  surfaceId,
const CVector localPos,
std::vector< CPointLightInfluence > &  pointLightList,
uint8 sunContribution,
NLMISC::CRGBA localAmbient
 

Get StaticLightSetup Infos from the grid

Parameters:
retrieverIdentifier value returned by CGlobalRetriever::getLocalRetrieverId(globalPos).
surfaceId the id of the surface in the LocalRetriever
localPos position to retrieve info. Position local to the LocalRetriever!! ie gp.LocalPosition.Estimated
pointLightList list of pointlight to append pointLight influecnes
Returns:
false if retrieverIdentifier / surfaceId is not found. In this case pointLightList is not modified, and sunContribution is set to 255, and localAmbient is set to 0

Definition at line 121 of file ig_surface_light.cpp.

References _RetrieverGridMap, NL3D::CIGSurfaceLight::CRetrieverLightGrid::Grids, ItRetrieverGridMap, nlassert, NLMISC::CRGBA::set(), sint, NLMISC::CObjectVector< CSurfaceLightGrid >::size(), uint, and uint8.

Referenced by NL3D::CInstanceGroup::getStaticLightSetup().

00123 {
00124         nlassert(_Owner);
00125 
00126         // default
00127         sunContribution= 255;
00128         localAmbient.set(0,0,0,0);
00129 
00130         ItRetrieverGridMap      it;
00131         it= _RetrieverGridMap.find(retrieverIdentifier);
00132         // If bad ident
00133         if(it==_RetrieverGridMap.end())
00134                 return false;
00135         CRetrieverLightGrid             &rlg= it->second;
00136         // if bad surfaceId
00137         if(surfaceId<0 || surfaceId>= (sint)rlg.Grids.size())
00138                 return false;
00139 
00140         // Else, ok, get it.
00141         rlg.Grids[surfaceId].getStaticLightSetup(localPos, pointLightList, sunContribution, *this, localAmbient);
00142         return true;
00143 }

void NL3D::CIGSurfaceLight::serial NLMISC::IStream f  ) 
 

Definition at line 98 of file ig_surface_light.cpp.

References _CellSize, _OOCellSize, _RetrieverGridMap, NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), and sint.

00099 {
00100         /*
00101         Version 1:
00102                 - The retriever grid map is now a map<uint,CRetrieverLightGrid>. Discard compatibility but.
00103         */
00104         sint    ver= f.serialVersion(1);
00105 
00106         f.serial(_CellSize);
00107         f.serial(_OOCellSize);
00108         if(ver<1)
00109         {
00110                 std::map<std::string, CRetrieverLightGrid>              oldFormatRetrieverGridMap;
00111                 f.serialCont(oldFormatRetrieverGridMap);
00112                 _RetrieverGridMap.clear();
00113         }
00114         else
00115         {
00116                 f.serialCont(_RetrieverGridMap);
00117         }
00118 }

void NL3D::CIGSurfaceLight::setOwner CInstanceGroup owner  ) 
 

Definition at line 43 of file ig_surface_light.cpp.

References nlassert.

Referenced by NL3D::CInstanceGroup::CInstanceGroup().

00044 {
00045         nlassert(owner!=NULL);
00046         _Owner= owner;
00047 }


Friends And Related Function Documentation

friend class CSurfaceLightGrid [friend]
 

Definition at line 106 of file ig_surface_light.h.


Field Documentation

float NL3D::CIGSurfaceLight::_CellSize [private]
 

Definition at line 110 of file ig_surface_light.h.

Referenced by build(), CIGSurfaceLight(), clear(), getCellSize(), and serial().

float NL3D::CIGSurfaceLight::_OOCellSize [private]
 

Definition at line 111 of file ig_surface_light.h.

Referenced by build(), CIGSurfaceLight(), clear(), getOOCellSize(), and serial().

CInstanceGroup* NL3D::CIGSurfaceLight::_Owner [private]
 

Definition at line 109 of file ig_surface_light.h.

Referenced by NL3D::CSurfaceLightGrid::getStaticLightSetup().

TRetrieverGridMap NL3D::CIGSurfaceLight::_RetrieverGridMap [private]
 

Definition at line 112 of file ig_surface_light.h.

Referenced by build(), clear(), getRetrieverGridMap(), getStaticLightSetup(), and serial().


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