NL3D::CLoadBalancingTrav Class Reference

#include <load_balancing_trav.h>

Inheritance diagram for NL3D::CLoadBalancingTrav:

NL3D::CTravCameraScene NL3D::CTraversal

Detailed Description

The LoadBalancing traversal. It needs a camera setup (see CTravCameraScene).

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

Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 120 of file load_balancing_trav.h.

LoadBalancing mgt.

typedef CLoadBalancingGroup::TPolygonBalancingMode TPolygonBalancingMode
float getGroupNbFaceAsked (const std::string &group) const
uint getGroupNbFaceWanted (const std::string &group)
float getNbFaceAsked () const
 Get the last face count asked from the instances before reduction. Sum of all groups.

void setGroupNbFaceWanted (const std::string &group, uint nFaces)
TPolygonBalancingMode PolygonBalancingMode

Public Member Functions

void addVisibleModel (CTransform *model)
void clearVisibleList ()
 CLoadBalancingTrav ()
 Constructor.

CLoadBalancingGroupgetDefaultGroup ()
uint getLoadPass ()
CLoadBalancingGroupgetOrCreateGroup (const std::string &group)
void reserveVisibleList (uint numModels)
void setCamMatrix (const NLMISC::CMatrix &camMatrix)
 Setup the camera matrix (a translation/rotation matrix).

void setFrustum (float width, float height, float znear, float zfar, bool perspective=true)
 Setup the camera mode as a perspective/ortho camera. NB: znear and zfar must be >0 (if perspective).

void setFrustum (float left, float right, float bottom, float top, float znear, float zfar, bool perspective=true)
 Setup the camera mode as a perspective/ortho camera. NB: znear and zfar must be >0 (if perspective).

ITrav/ITravScene Implementation.
void traverse ()

Data Fields

CSceneScene

Protected Member Functions

void update ()
 update the dependent information.


Private Types

typedef TGroupMap::iterator ItGroupMap
typedef std::map< std::string,
CLoadBalancingGroup
TGroupMap

Private Member Functions

void traverseVisibilityList ()

Private Attributes

uint32 _CurrentNumVisibleModels
CLoadBalancingGroup_DefaultGroup
TGroupMap _GroupMap
uint _LoadPass
float _SumNbFacePass0
std::vector< CTransform * > _VisibleList


Member Typedef Documentation

typedef TGroupMap::iterator NL3D::CLoadBalancingTrav::ItGroupMap [private]
 

Definition at line 202 of file load_balancing_trav.h.

Referenced by getOrCreateGroup(), and traverse().

typedef std::map<std::string, CLoadBalancingGroup> NL3D::CLoadBalancingTrav::TGroupMap [private]
 

Definition at line 201 of file load_balancing_trav.h.

typedef CLoadBalancingGroup::TPolygonBalancingMode NL3D::CLoadBalancingTrav::TPolygonBalancingMode
 

Definition at line 138 of file load_balancing_trav.h.


Constructor & Destructor Documentation

NL3D::CLoadBalancingTrav::CLoadBalancingTrav  ) 
 

Constructor.

Definition at line 136 of file load_balancing_trav.cpp.

References _GroupMap, and PolygonBalancingMode.

00137 {
00138         PolygonBalancingMode= CLoadBalancingGroup::PolygonBalancingOff;
00139 
00140         // Add the default group and make it default
00141         _GroupMap["Default"].Name= "Default";
00142         _GroupMap["Default"]._DefaultGroup= true;
00143 
00144         // set the DefaultGroup ptr.
00145         _DefaultGroup= &_GroupMap["Default"];
00146 
00147         // prepare some space
00148         _VisibleList.resize(1024);
00149         _CurrentNumVisibleModels= 0;
00150 }


Member Function Documentation

void NL3D::CLoadBalancingTrav::addVisibleModel CTransform model  )  [inline]
 

Definition at line 178 of file load_balancing_trav.h.

Referenced by NL3D::CParticleSystemModel::insertInVisibleList(), and NL3D::CTransform::traverseClip().

00179         {
00180                 _VisibleList[_CurrentNumVisibleModels]= model;
00181                 _CurrentNumVisibleModels++;
00182         }

void NL3D::CLoadBalancingTrav::clearVisibleList  ) 
 

Definition at line 154 of file load_balancing_trav.cpp.

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

00155 {
00156         _CurrentNumVisibleModels= 0;
00157 }

CLoadBalancingGroup* NL3D::CLoadBalancingTrav::getDefaultGroup  )  [inline]
 

Definition at line 168 of file load_balancing_trav.h.

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

00168 {return _DefaultGroup;}

float NL3D::CLoadBalancingTrav::getGroupNbFaceAsked const std::string &  group  )  const
 

Get the last face count asked from the instances before reduction. only for the given group return 0 if the Group does not exist.

Definition at line 258 of file load_balancing_trav.cpp.

References _GroupMap.

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

00259 {
00260         TGroupMap::const_iterator       it;
00261         it= _GroupMap.find(group);
00262         if(it==_GroupMap.end())
00263                 return 0;
00264         else
00265                 return it->second.getNbFaceAsked();
00266 }

uint NL3D::CLoadBalancingTrav::getGroupNbFaceWanted const std::string &  group  ) 
 

Get the number of faces wanted for a LoadBlancingGroup. The Group is created if did not exist.

Definition at line 251 of file load_balancing_trav.cpp.

References NL3D::CLoadBalancingGroup::getNbFaceWanted(), getOrCreateGroup(), and uint.

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

00252 {
00253         // get/create if needed, and get.
00254         return getOrCreateGroup(group)->getNbFaceWanted();
00255 }

uint NL3D::CLoadBalancingTrav::getLoadPass  )  [inline]
 

Definition at line 166 of file load_balancing_trav.h.

References _LoadPass, and uint.

Referenced by NL3D::CTransformShape::traverseLoadBalancing(), and NL3D::CMeshMultiLodInstance::traverseLoadBalancing().

00166 {return _LoadPass;}

float NL3D::CLoadBalancingTrav::getNbFaceAsked  )  const
 

Get the last face count asked from the instances before reduction. Sum of all groups.

Definition at line 220 of file load_balancing_trav.cpp.

References _SumNbFacePass0.

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

00221 {
00222         return _SumNbFacePass0;
00223 }

CLoadBalancingGroup * NL3D::CLoadBalancingTrav::getOrCreateGroup const std::string &  group  ) 
 

Definition at line 227 of file load_balancing_trav.cpp.

References _GroupMap, and ItGroupMap.

Referenced by getGroupNbFaceWanted(), setGroupNbFaceWanted(), and NL3D::CTransform::setLoadBalancingGroup().

00228 {
00229         // find
00230         ItGroupMap      it;
00231         it= _GroupMap.find(group);
00232         // if not exist, create.
00233         if(it==_GroupMap.end())
00234         {
00235                 // create and set name.
00236                 it= _GroupMap.insert(make_pair(group, CLoadBalancingGroup())).first;
00237                 it->second.Name= group;
00238         }
00239 
00240         return &(it->second);
00241 }

void NL3D::CLoadBalancingTrav::reserveVisibleList uint  numModels  ) 
 

Definition at line 270 of file load_balancing_trav.cpp.

References uint.

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

00271 {
00272         // enlarge only.
00273         if(numModels>_VisibleList.size())
00274                 _VisibleList.resize(numModels);
00275 }

void NL3D::CTravCameraScene::setCamMatrix const NLMISC::CMatrix camMatrix  )  [inline, inherited]
 

Setup the camera matrix (a translation/rotation matrix).

Definition at line 102 of file trav_scene.h.

References NL3D::CTravCameraScene::CamMatrix.

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

00103         {
00104                 CamMatrix= camMatrix;
00105         }

void NL3D::CTravCameraScene::setFrustum float  width,
float  height,
float  znear,
float  zfar,
bool  perspective = true
[inline, inherited]
 

Setup the camera mode as a perspective/ortho camera. NB: znear and zfar must be >0 (if perspective).

Definition at line 97 of file trav_scene.h.

References height, NL3D::CTravCameraScene::setFrustum(), and width.

00098         {
00099                 setFrustum(-width/2, width/2, -height/2, height/2, znear, zfar, perspective);
00100         }

void NL3D::CTravCameraScene::setFrustum float  left,
float  right,
float  bottom,
float  top,
float  znear,
float  zfar,
bool  perspective = true
[inline, inherited]
 

Setup the camera mode as a perspective/ortho camera. NB: znear and zfar must be >0 (if perspective).

Definition at line 86 of file trav_scene.h.

References NL3D::CTravCameraScene::Bottom, NL3D::CTravCameraScene::Far, NL3D::CTravCameraScene::Near, NL3D::CTravCameraScene::Perspective, and NL3D::CTravCameraScene::Right.

Referenced by NL3D::CTravCameraScene::CTravCameraScene(), NL3D::CScene::render(), and NL3D::CTravCameraScene::setFrustum().

00087         {
00088                 Left= left;
00089                 Right= right;
00090                 Bottom= bottom;
00091                 Top= top;
00092                 Near= znear;
00093                 Far= zfar;
00094                 Perspective= perspective;
00095         }

void NL3D::CLoadBalancingTrav::setGroupNbFaceWanted const std::string &  group,
uint  nFaces
 

Set the number of faces wanted for a LoadBlancingGroup. The Group is created if did not exist.

Definition at line 244 of file load_balancing_trav.cpp.

References getOrCreateGroup(), NL3D::CLoadBalancingGroup::setNbFaceWanted(), and uint.

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

00245 {
00246         // get/create if needed, and assign.
00247         getOrCreateGroup(group)->setNbFaceWanted(nFaces);
00248 }

void NL3D::CLoadBalancingTrav::traverse  ) 
 

Definition at line 161 of file load_balancing_trav.cpp.

References _GroupMap, _LoadPass, _SumNbFacePass0, H_AUTO, ItGroupMap, PolygonBalancingMode, and traverseVisibilityList().

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

00162 {
00163         H_AUTO( NL3D_TravLoadBalancing );
00164 
00165         CTravCameraScene::update();
00166 
00167         // Reset each group.
00168         //================
00169         ItGroupMap      it= _GroupMap.begin();
00170         for(;it!=_GroupMap.end();it++)
00171         {
00172                 // reset _NbFacePass0.
00173                 it->second._NbFacePass0= 0;
00174         }
00175 
00176 
00177         // Traverse the graph 2 times.
00178 
00179         // 1st pass, count NBFaces drawed.
00180         //================
00181         _LoadPass= 0;
00182         // count _NbFacePass0.
00183         traverseVisibilityList();
00184 
00185 
00186         // Reset _SumNbFacePass0
00187         _SumNbFacePass0= 0;
00188         // For each group
00189         it= _GroupMap.begin();
00190         for(;it!=_GroupMap.end();it++)
00191         {
00192                 // compute ratio and smooth
00193                 it->second.computeRatioAndSmooth(PolygonBalancingMode);
00194                 // update _SumNbFacePass0
00195                 _SumNbFacePass0+= it->second.getNbFaceAsked();
00196         }
00197 
00198 
00199         // 2nd pass, compute Faces that will be drawed.
00200         //================
00201         _LoadPass= 1;
00202         traverseVisibilityList();
00203 
00204 }

void NL3D::CLoadBalancingTrav::traverseVisibilityList  )  [private]
 

Definition at line 208 of file load_balancing_trav.cpp.

References NL3D::CTransform::traverseLoadBalancing(), and uint.

Referenced by traverse().

00209 {
00210         // Traverse all nodes of the visibility list.
00211         for(uint i=0; i<_CurrentNumVisibleModels; i++)
00212         {
00213                 CTransform      *model= _VisibleList[i];
00214                 model->traverseLoadBalancing();
00215         }
00216 }

void NL3D::CTravCameraScene::update  )  [inline, protected, inherited]
 

update the dependent information.

Definition at line 122 of file trav_scene.h.

References NL3D::CTravCameraScene::CamLook, NL3D::CTravCameraScene::CamMatrix, NL3D::CTravCameraScene::CamPos, NLMISC::CMatrix::getPos(), NLMISC::CMatrix::inverted(), and NLMISC::CMatrix::mulVector().

00123         {
00124                 ViewMatrix= CamMatrix.inverted();
00125                 CamPos= CamMatrix.getPos();
00126                 CamLook= CamMatrix.mulVector(NLMISC::CVector::J);
00127         }


Field Documentation

uint32 NL3D::CLoadBalancingTrav::_CurrentNumVisibleModels [private]
 

Definition at line 207 of file load_balancing_trav.h.

CLoadBalancingGroup* NL3D::CLoadBalancingTrav::_DefaultGroup [private]
 

Definition at line 200 of file load_balancing_trav.h.

TGroupMap NL3D::CLoadBalancingTrav::_GroupMap [private]
 

Definition at line 203 of file load_balancing_trav.h.

Referenced by CLoadBalancingTrav(), getGroupNbFaceAsked(), getOrCreateGroup(), and traverse().

uint NL3D::CLoadBalancingTrav::_LoadPass [private]
 

Definition at line 190 of file load_balancing_trav.h.

Referenced by getLoadPass(), and traverse().

float NL3D::CLoadBalancingTrav::_SumNbFacePass0 [private]
 

Definition at line 193 of file load_balancing_trav.h.

Referenced by getNbFaceAsked(), and traverse().

std::vector<CTransform*> NL3D::CLoadBalancingTrav::_VisibleList [private]
 

Definition at line 206 of file load_balancing_trav.h.

float NL3D::CTravCameraScene::Bottom [inherited]
 

Definition at line 75 of file trav_scene.h.

Referenced by NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender().

NLMISC::CVector NL3D::CTravCameraScene::CamLook [inherited]
 

Definition at line 80 of file trav_scene.h.

Referenced by NL3D::CLandscapeModel::clipAndRenderLandscape(), NL3D::CTravCameraScene::CTravCameraScene(), and NL3D::CTravCameraScene::update().

NLMISC::CMatrix NL3D::CTravCameraScene::CamMatrix [inherited]
 

Definition at line 77 of file trav_scene.h.

Referenced by NL3D::CTravCameraScene::CTravCameraScene(), NL3D::CTravCameraScene::setCamMatrix(), NL3D::CWaterModel::traverseRender(), NL3D::CFlareModel::traverseRender(), and NL3D::CTravCameraScene::update().

NLMISC::CVector NL3D::CTravCameraScene::CamPos [inherited]
 

Definition at line 79 of file trav_scene.h.

Referenced by NL3D::CTransformShape::clip(), NL3D::CQuadGridClipClusterQTreeNode::clip(), NL3D::CLandscapeModel::clipAndRenderLandscape(), NL3D::CSkeletonModel::computeDisplayLodCharacterPriority(), NL3D::CTravCameraScene::CTravCameraScene(), NL3D::CWaterModel::doSimpleRender(), NL3D::CQuadGridClipClusterQTreeNode::noFrustumClip(), NL3D::CCluster::recursTraverseClip(), NL3D::CScene::render(), NL3D::CMeshMRMGeom::render(), NL3D::CMeshGeom::render(), NL3D::CSkeletonModel::renderCLod(), NL3D::CMeshMRMGeom::renderSkin(), NL3D::CMeshGeom::renderSkin(), NL3D::CShadowMapManager::selectShadowMapsToGenerate(), NL3D::CSkeletonModel::traverseAnimDetail(), NL3D::CParticleSystemModel::traverseClip(), NL3D::CTransformShape::traverseLoadBalancingPass0(), NL3D::CWaterModel::traverseRender(), and NL3D::CTravCameraScene::update().

float NL3D::CTravCameraScene::Far [inherited]
 

Definition at line 75 of file trav_scene.h.

Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender().

float NL3D::CTravCameraScene::Left [inherited]
 

Definition at line 75 of file trav_scene.h.

Referenced by NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender().

float NL3D::CTravCameraScene::Near [inherited]
 

Definition at line 75 of file trav_scene.h.

Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender().

bool NL3D::CTravCameraScene::Perspective [inherited]
 

Definition at line 76 of file trav_scene.h.

Referenced by NL3D::CTravCameraScene::setFrustum().

TPolygonBalancingMode NL3D::CLoadBalancingTrav::PolygonBalancingMode
 

Definition at line 139 of file load_balancing_trav.h.

Referenced by CLoadBalancingTrav(), NL3D::CScene::getPolygonBalancingMode(), NL3D::CScene::setPolygonBalancingMode(), and traverse().

float NL3D::CTravCameraScene::Right [inherited]
 

Definition at line 75 of file trav_scene.h.

Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender().

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().

float NL3D::CTravCameraScene::Top [inherited]
 

Definition at line 75 of file trav_scene.h.

Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender().

NLMISC::CMatrix NL3D::CTravCameraScene::ViewMatrix [inherited]
 

Definition at line 78 of file trav_scene.h.

Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CParticleSystemModel::doAnimate(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender().


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