#include <clip_trav.h>
Inheritance diagram for NL3D::CClipTrav:
Models should use the CTransform->clip() method to implement their models, or completly redefine the traverseClip() method.
USER RULES: Before using traverse() on a clip traversal, you should:
NB: see CScene for 3d conventions (orthonormal basis...)
Nevrax France
Definition at line 84 of file clip_trav.h.
Cluster system related methods. | |
void | addVisibleCluster (CCluster *cluster) |
Add a visible cluster to the list. | |
bool | fullSearch (std::vector< CCluster * > &result, CInstanceGroup *pIG, const CVector &pos) |
bool | getClusterVisibilityTracking () |
Check the activation of cluster visibility tracking. | |
const std::vector< CCluster * > & | getVisibleClusters () |
void | setClusterVisibilityTracking (bool track) |
Set cluster tracking on/off (ie storage of thje visible cluster during clip traversal). | |
bool | _TrackClusterVisibility |
Add a visible cluster to the list. | |
std::vector< CCluster * > | _VisibleClusters |
Add a visible cluster to the list. | |
Public Member Functions | |
CClipTrav () | |
Constructor. | |
const CQuadGridClipManager * | getQuadGridClipManager () const |
void | registerCluster (CCluster *pCluster) |
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). | |
void | setQuadGridClipManager (CQuadGridClipManager *mgr) |
Setup the render traversal (else traverse() won't work). | |
void | traverse () |
traverse | |
void | unregisterCluster (CCluster *pCluster) |
~CClipTrav () | |
Visible List mgt. Those visible modles are updated each traverse(). | |
void | addVisibleModel (CTransform *model) |
void | reserveVisibleList (uint numModels) |
Data Fields | |
CQuadGrid< CCluster * > | Accel |
CCamera * | Camera |
sint64 | CurrentDate |
bool | ForceNoFrustumClip |
CCluster * | RootCluster |
CScene * | Scene |
FOR MODEL TRAVERSAL ONLY. (Read only) | |
Those variables are valid only in traverse*(). | |
std::vector< CPlane > | ViewPyramid |
Vision Pyramid (6 normalized planes) in the view basis. | |
std::vector< CPlane > | WorldFrustumPyramid |
Vision Pyramid (6 normalized planes) in the world basis. NB: NOT modified by the ClusterSystem. | |
std::vector< CPlane > | WorldPyramid |
Vision Pyramid in the world basis. NB: may be modified by the ClusterSystem. | |
Protected Member Functions | |
void | update () |
update the dependent information. | |
Private Member Functions | |
void | clipSkeletonShadowMaps () |
void | loadBalanceSkeletonCLod () |
Private Attributes | |
uint32 | _CurrentNumVisibleModels |
CQuadGridClipManager * | _QuadGridClipManager |
std::vector< CSkeletonKey > | _TmpSortSkeletons |
std::vector< CTransform * > | _VisibleList |
Friends | |
class | CTransform |
|
Constructor.
Definition at line 55 of file clip_trav.cpp. References _QuadGridClipManager, Accel, NL3D::CQuadGrid< CCluster * >::create(), and ForceNoFrustumClip.
00055 : ViewPyramid(6), WorldPyramid(6) 00056 { 00057 _VisibleList.resize(1024); 00058 _CurrentNumVisibleModels= 0; 00059 CurrentDate = 0; 00060 Accel.create (64, 16.0f); 00061 00062 ForceNoFrustumClip= false; 00063 _QuadGridClipManager= NULL; 00064 } |
|
Definition at line 67 of file clip_trav.cpp.
00068 { 00069 } |
|
Add a visible cluster to the list.
Definition at line 106 of file clip_trav.cpp. References _VisibleClusters. Referenced by NL3D::CCluster::recursTraverseClip().
00107 { 00108 _VisibleClusters.push_back(cluster); 00109 } |
|
Definition at line 105 of file clip_trav.h. References NL3D::CTransform::_IndexInVisibleList. Referenced by NL3D::CParticleSystemModel::insertInVisibleList(), and NL3D::CTransform::traverseClip().
00106 { 00107 model->_IndexInVisibleList= _CurrentNumVisibleModels; 00108 _VisibleList[_CurrentNumVisibleModels]= model; 00109 _CurrentNumVisibleModels++; 00110 } |
|
Definition at line 532 of file clip_trav.cpp. References NL3D::CTransform::_AncestorSkeletonModel, NL3D::CLightTrav::addLightedModel(), NL3D::CShadowMapManager::addShadowCaster(), NL3D::CAnimDetailTrav::addVisibleModel(), NL3D::CTransform::canCastShadowMap(), NLMISC::CBSphere::Center, NL3D::CFadeShadowMapSort::Dist, NL3D::CShadowMap::DistanceFade, NL3D::CScene::getAnimDetailTrav(), NL3D::CScene::getEllapsedTime(), NL3D::CScene::getLightTrav(), NLMISC::CMatrix::getPos(), NL3D::CScene::getRenderTrav(), NL3D::CTransform::getShadowMap(), NL3D::CSkeletonModel::getShadowMap(), NL3D::CScene::getShadowMapDistFadeEnd(), NL3D::CScene::getShadowMapDistFadeStart(), NL3D::CRenderTrav::getShadowMapManager(), NL3D::CScene::getShadowMapMaxCasterAround(), NL3D::CScene::getShadowMapMaxCasterInScreen(), NL3D::CScene::getShadowMapMaxDepth(), NL3D::CScene::getSkeletonModelListBegin(), NL3D::CScene::getSkeletonModelListEnd(), NL3D::CTransform::getWorldMatrix(), H_AUTO, NL3D::CShadowMap::InScreenFadeAccum, NL3D::CTransform::isAnimDetailable(), NL3D::CTransform::isClipVisible(), NL3D::CTransform::isGeneratingShadowMap(), NL3D::CTransform::isHrcVisible(), NL3D::CTransform::isLightable(), NL3D::CScene::ItSkeletonModelList, min, NL3D::CFadeShadowMapSort::Model, NL3D_SMM_FADE_SPEED, nlassert, NL3D::CShadowMap::processFades(), NLMISC::CBSphere::Radius, NL3D::CShadowMapManager::selectShadowMapsToGenerate(), NL3D::CShadowMap::TemporalInScreenFade, NL3D::CShadowMap::TemporalOutScreenFade, uint, and WorldFrustumPyramid. Referenced by traverse().
00533 { 00534 H_AUTO( NL3D_TravClip_SkeletonShadow ); 00535 00536 CScene::ItSkeletonModelList itSkel; 00537 00538 float dFade= NL3D_SMM_FADE_SPEED * Scene->getEllapsedTime(); 00539 float distFadeStart= Scene->getShadowMapDistFadeStart(); 00540 float distFadeEnd= Scene->getShadowMapDistFadeEnd(); 00541 float OODeltaDistFade; 00542 if(distFadeEnd-distFadeStart>0) 00543 OODeltaDistFade= 1.0f/(distFadeEnd-distFadeStart); 00544 else 00545 OODeltaDistFade= 1000000; 00546 uint maxCastInScreen= Scene->getShadowMapMaxCasterInScreen(); 00547 uint maxCastAround= Scene->getShadowMapMaxCasterAround(); 00548 00549 // **** First select Skeleton ShadowMap to Render 00550 00551 // Lod Skeletons that will cast ShadowMaps. 00552 static std::vector<CFadeShadowMapSort> aroundCastSkeletons; 00553 static std::vector<CFadeShadowMapSort> screenCastSkeletons; 00554 aroundCastSkeletons.clear(); 00555 screenCastSkeletons.clear(); 00556 00557 // For all skeleton casters 00558 for(itSkel= Scene->getSkeletonModelListBegin(); itSkel!=Scene->getSkeletonModelListEnd(); itSkel++) 00559 { 00560 CSkeletonModel *sm= *itSkel; 00561 00562 // if the sm cast shadow 00563 if( sm->canCastShadowMap() ) 00564 { 00565 CShadowMap *shadowMap= sm->getShadowMap(); 00566 nlassert( shadowMap ); 00567 00568 // Is a Root Sm ?? Other Skeletons ShadowMaps are not render since the 00569 // Ancestor Skeleton render all of his sons. Additionally, no-op if this skeleton is hidden in HRC!! 00570 if( sm->_AncestorSkeletonModel==NULL && sm->isHrcVisible() ) 00571 { 00572 bool visible= false; 00573 // if we are already visible, then its ok, we either don't need to test. 00574 if(sm->isClipVisible()) 00575 visible= true; 00576 else 00577 { 00578 // TODO_SHADOW: Select a better "Skeleton Sphere". It depends also on Sticked objects/Skeletons. 00579 // Build the sphere around the skeleton that can receive shadow. 00580 CBSphere sphere; 00581 // Suppose an Object sphere of 3 meter radius, centered on Skeleton Pos. 00582 const float objectRadius= 3.f; 00583 sphere.Center= sm->getWorldMatrix().getPos(); 00584 // Add to this spehre the max Depth extent. 00585 // NB: works because suppose that the Shadow BBox include the Skeleton Center. 00586 sphere.Radius= objectRadius + Scene->getShadowMapMaxDepth(); 00587 00588 // Clip This sphere against the Frustum. 00589 visible= true; 00590 for(uint i=0;i<WorldFrustumPyramid.size();i++) 00591 { 00592 // if SpherMax OUT return false. 00593 float d= WorldFrustumPyramid[i]*sphere.Center; 00594 if(d>sphere.Radius) 00595 { 00596 visible= false; 00597 break; 00598 } 00599 } 00600 } 00601 00602 // If the ShadowMap is visible, add it to the List Of ShadowMap to Render. 00603 if(visible) 00604 Scene->getRenderTrav().getShadowMapManager().addShadowCaster(sm); 00605 00606 // update Fading. 00607 CFadeShadowMapSort fsms; 00608 fsms.Model= sm; 00609 fsms.Dist= (sm->getWorldMatrix().getPos() - CamPos).norm(); 00610 // lod In and Out. 00611 aroundCastSkeletons.push_back(fsms); 00612 if(visible) 00613 screenCastSkeletons.push_back(fsms); 00614 // Compute normal Distance fading. 00615 shadowMap->DistanceFade= (fsms.Dist-distFadeStart)*OODeltaDistFade; 00616 // Increment the TemporalFadeOut by default (see below) 00617 shadowMap->TemporalOutScreenFade+= dFade; 00618 // if !visible, increment the InScreenFadeAccum 00619 if(!visible) 00620 shadowMap->InScreenFadeAccum+= dFade; 00621 } 00622 // If the skeleton is not visible, or if temporary bound to a AncestorSkeletonModel 00623 else 00624 { 00625 // Increment the TemporalFadeOut. Because since will be hidden (or sticked) 00626 // for a long time, allow the process to free texture. 00627 shadowMap->TemporalOutScreenFade+= dFade; 00628 // Since not visible, increment the InScreenFadeAccum 00629 shadowMap->InScreenFadeAccum+= dFade; 00630 } 00631 } 00632 } 00633 00634 // **** Load Balance Skeletons that cast ShadowMaps around, 00635 00636 sort(aroundCastSkeletons.begin(), aroundCastSkeletons.end()); 00637 sort(screenCastSkeletons.begin(), screenCastSkeletons.end()); 00638 00639 // For All Around nearest Casters, decrement their fadeOutScreen 00640 uint numNearCast= min((uint)aroundCastSkeletons.size(), maxCastAround); 00641 uint i; 00642 for(i=0;i<numNearCast;i++) 00643 { 00644 CTransform *model= aroundCastSkeletons[i].Model; 00645 CShadowMap *shadowMap= model->getShadowMap(); 00646 // Decrement the fade. *2 because default incremented above. 00647 shadowMap->TemporalOutScreenFade-= 2*dFade; 00648 } 00649 00650 // For InScreen Casters, increment or decrement their fadeInScreen. Also resolve InScreenFadeAccum. 00651 numNearCast= min((uint)screenCastSkeletons.size(), maxCastInScreen); 00652 // nearest: decrement fadeInScreen, and remove accum 00653 for(i=0;i<numNearCast;i++) 00654 { 00655 CShadowMap *shadowMap= screenCastSkeletons[i].Model->getShadowMap(); 00656 // Decrement the fade. 00657 shadowMap->TemporalInScreenFade-= dFade + shadowMap->InScreenFadeAccum; 00658 // Since visible and resolved, reset accum 00659 shadowMap->InScreenFadeAccum= 0; 00660 } 00661 // farthest: increment fadeInScreen, and append accum 00662 for(i=numNearCast;i<screenCastSkeletons.size();i++) 00663 { 00664 CShadowMap *shadowMap= screenCastSkeletons[i].Model->getShadowMap(); 00665 // Increment the fade. 00666 shadowMap->TemporalInScreenFade+= dFade + shadowMap->InScreenFadeAccum; 00667 // Since visible and resolved, reset accum 00668 shadowMap->InScreenFadeAccum= 0; 00669 } 00670 00671 00672 // clamp values, and release texture where appropriated 00673 for(itSkel= Scene->getSkeletonModelListBegin(); itSkel!=Scene->getSkeletonModelListEnd(); itSkel++) 00674 { 00675 CSkeletonModel *sm= *itSkel; 00676 // if the sm cast shadow (whatever displayed or not) 00677 if( sm->canCastShadowMap() ) 00678 { 00679 CShadowMap *shadowMap= sm->getShadowMap(); 00680 shadowMap->processFades(); 00681 } 00682 } 00683 00684 // **** Use the rendered Skeletons ShadowMap to select the Ones that will be generated this Frame. 00685 Scene->getRenderTrav().getShadowMapManager().selectShadowMapsToGenerate(Scene); 00686 00687 00688 /* **** Then for All Skeleton not visibles but that will generate their shadowMap, 00689 we must compute the LightTraversal(for ShadowLight direction) and AnimDetailTraversal (for bone 00690 animation) 00691 We MUST NOT flag the skeleton as Visible, and we MUST NOT insert in LoadBalancing 00692 (since won't be rendered) 00693 NB: Do nothing for Sons of the Ancestor Skeleton because: 00694 1/ light do nothing with them (see std clip) 00695 2/ animDetail will be called recursively (see std clip and CSkeletonModel::traverseAnimDetail()) 00696 */ 00697 for(itSkel= Scene->getSkeletonModelListBegin(); itSkel!=Scene->getSkeletonModelListEnd(); itSkel++) 00698 { 00699 CSkeletonModel *sm= *itSkel; 00700 // compute its shadowMap this frame? and not visible? 00701 if(sm->isGeneratingShadowMap() && !sm->isClipVisible() ) 00702 { 00703 nlassert(sm->_AncestorSkeletonModel==NULL); 00704 // Add it only to the lightTrav and AnimDetailTrav 00705 if( sm->isLightable() ) 00706 Scene->getLightTrav().addLightedModel(sm); 00707 if( sm->isAnimDetailable() ) 00708 Scene->getAnimDetailTrav().addVisibleModel(sm); 00709 } 00710 } 00711 } |
|
Retreive a list of cluster for witch the position is inside. Definition at line 72 of file clip_trav.cpp. References NL3D::CInstanceGroup::_ClusterInstances, and uint32. Referenced by traverse().
00073 { 00074 uint32 i, j; 00075 00076 for (i = 0; i < pIG->_ClusterInstances.size(); ++i) 00077 { 00078 for (j = 0; j < pIG->_ClusterInstances[i]->Children.size(); ++j) 00079 { 00080 if (fullSearch (result, pIG->_ClusterInstances[i]->Children[j]->Group, pos)) 00081 return true; 00082 } 00083 } 00084 00085 for (i = 0; i < pIG->_ClusterInstances.size(); ++i) 00086 { 00087 if (pIG->_ClusterInstances[i]->isIn(pos)) 00088 result.push_back (pIG->_ClusterInstances[i]); 00089 } 00090 if (result.size() > 0) 00091 return true; 00092 return false; 00093 } |
|
Check the activation of cluster visibility tracking.
Definition at line 101 of file clip_trav.cpp. References _TrackClusterVisibility. Referenced by NL3D::CCluster::recursTraverseClip().
00102 { 00103 return _TrackClusterVisibility; 00104 } |
|
Definition at line 100 of file clip_trav.h. References _QuadGridClipManager. Referenced by NL3D::CSceneUser::profileQuadGridClipManager().
00100 {return _QuadGridClipManager;} |
|
Return the list of cluster visible after the clip traversal You must activate the cluster tracking to obtain a result. Definition at line 113 of file clip_trav.cpp. References _VisibleClusters.
00114 { 00115 return _VisibleClusters; 00116 } |
|
Definition at line 457 of file clip_trav.cpp. References _TmpSortSkeletons, NL3D::CSkeletonModel::computeDisplayLodCharacterPriority(), NL3D::CScene::getMaxSkeletonsInNotCLodForm(), NL3D::CScene::getSkeletonModelListBegin(), NL3D::CScene::getSkeletonModelListEnd(), NL3D::CScene::ItSkeletonModelList, min, NLMISC::OptFastFloor(), NL3D::CClipTrav::CSkeletonKey::Priority, NL3D::CSkeletonModel::setDisplayLodCharacterFlag(), NL3D::CClipTrav::CSkeletonKey::SkeletonModel, and uint. Referenced by traverse().
00458 { 00459 CScene::ItSkeletonModelList itSkel; 00460 _TmpSortSkeletons.clear(); 00461 00462 // **** compute CLod priority of each skeleton, 00463 for(itSkel= Scene->getSkeletonModelListBegin(); itSkel!=Scene->getSkeletonModelListEnd(); itSkel++) 00464 { 00465 CSkeletonModel *sm= *itSkel; 00466 float pr= sm->computeDisplayLodCharacterPriority(); 00467 // If valid priority (CLOd enabled, and skeleton visible) 00468 if(pr>0) 00469 { 00470 // if the priority is >1, then display as CLod 00471 if(pr>1) 00472 sm->setDisplayLodCharacterFlag(true); 00473 // else load balance. 00474 else 00475 { 00476 CSkeletonKey key; 00477 // don't bother OptFastFloor precision. NB: 0<pr<=1 here. 00478 key.Priority= OptFastFloor(pr*0xFFFFFF00); 00479 key.SkeletonModel= sm; 00480 _TmpSortSkeletons.push_back(key); 00481 } 00482 } 00483 } 00484 00485 // **** sort by priority in ascending order 00486 uint nMaxSkelsInNotCLodForm= Scene->getMaxSkeletonsInNotCLodForm(); 00487 // Optim: need it only if too many skels 00488 if(_TmpSortSkeletons.size()>nMaxSkelsInNotCLodForm) 00489 { 00490 sort(_TmpSortSkeletons.begin(), _TmpSortSkeletons.end()); 00491 } 00492 00493 // **** set CLod flag 00494 uint n= min(nMaxSkelsInNotCLodForm, (uint)_TmpSortSkeletons.size()); 00495 uint i; 00496 // The lowest priority are displayed in std form 00497 for(i=0;i<n;i++) 00498 { 00499 _TmpSortSkeletons[i].SkeletonModel->setDisplayLodCharacterFlag(false); 00500 } 00501 // the other are displayed in CLod form 00502 for(i=n;i<_TmpSortSkeletons.size();i++) 00503 { 00504 _TmpSortSkeletons[i].SkeletonModel->setDisplayLodCharacterFlag(true); 00505 } 00506 00507 } |
|
Definition at line 433 of file clip_trav.cpp. References Accel, NL3D::CCluster::AccelIt, NL3D::CCluster::getBBox(), NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), and NL3D::CQuadGrid< CCluster * >::insert(). Referenced by NL3D::CInstanceGroup::addToSceneWhenAllShapesLoaded(), and NL3D::CCluster::traverseHrc().
00434 { 00435 pCluster->AccelIt = Accel.insert (pCluster->getBBox().getMin(), pCluster->getBBox().getMax(), pCluster); 00436 } |
|
Definition at line 511 of file clip_trav.cpp. References uint. Referenced by NL3D::CScene::createModel().
00512 { 00513 // enlarge only. 00514 if(numModels>_VisibleList.size()) 00515 _VisibleList.resize(numModels); 00516 } |
|
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 } |
|
Set cluster tracking on/off (ie storage of thje visible cluster during clip traversal).
Definition at line 96 of file clip_trav.cpp. References _TrackClusterVisibility.
00097 { 00098 _TrackClusterVisibility = track; 00099 } |
|
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 } |
|
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().
|
|
Setup the render traversal (else traverse() won't work).
Definition at line 427 of file clip_trav.cpp. References _QuadGridClipManager. Referenced by NL3D::CScene::release(), and NL3D::CScene::render().
00428 { 00429 _QuadGridClipManager= mgr; 00430 } |
|
traverse Flag all cluster to know if they are in camera or not. Definition at line 120 of file clip_trav.cpp. References NL3D::CHrcTrav::_MovingObjects, _QuadGridClipManager, _VisibleClusters, Accel, NL3D::CQuadGrid< CCluster * >::begin(), Camera, NL3D::CLightTrav::clearLightedList(), NL3D::CRenderTrav::clearRenderList(), NL3D::CLoadBalancingTrav::clearVisibleList(), NL3D::CAnimDetailTrav::clearVisibleList(), NL3D::CTransform::clipAddChild(), NL3D::CTransform::clipDelChild(), NL3D::CTransform::clipGetNumParents(), NL3D::CTransform::clipGetParent(), clipSkeletonShadowMaps(), NL3D::CQuadGrid< CCluster * >::end(), fullSearch(), NL3D::CTransformShape::getAABBox(), NL3D::CScene::getAnimDetailTrav(), NLMISC::CAABBox::getCenter(), NL3D::CTransform::getClusterSystem(), NLMISC::CAABBox::getHalfSize(), NL3D::CScene::getHrcTrav(), NL3D::CScene::getLightTrav(), NL3D::CScene::getLoadBalancingTrav(), NL3D::CScene::getRenderTrav(), NL3D::CScene::getRoot(), NL3D::CScene::getSkeletonModelListBegin(), NL3D::CScene::getSkeletonModelListEnd(), NL3D::CTransform::getWorldMatrix(), NL3D::CCluster::Group, H_AFTER, H_AUTO, H_BEFORE, NL3D::CTransform::isCluster(), NL3D::CCluster::isIn(), NL3D::CTransform::isQuadGridClipEnabled(), NL3D::CScene::ItSkeletonModelList, NL3D::CQuadGridClipManager::linkModel(), loadBalanceSkeletonCLod(), NL3D_CLIP_PLANE_BOTTOM, NL3D_CLIP_PLANE_FAR, NL3D_CLIP_PLANE_LEFT, NL3D_CLIP_PLANE_NEAR, NL3D_CLIP_PLANE_RIGHT, NL3D_CLIP_PLANE_TOP, NLMISC::CVector::norm(), RootCluster, s, NL3D::CQuadGrid< CCluster * >::select(), NL3D::CScene::SonsOfAncestorSkeletonModelGroup, NL3D::CRootModel::traverseClip(), NL3D::CTransform::traverseClip(), uint, uint32, NL3D::CQuadGridClipManager::updateClustersFromCamera(), NL3D::CSkeletonModel::updateSkinRenderLists(), ViewPyramid, WorldFrustumPyramid, and WorldPyramid. Referenced by NL3D::CScene::render().
00121 { 00122 H_AUTO( NL3D_TravClip ); 00123 00124 // The root must exist 00125 CTransform *sceneRoot= Scene->getRoot(); 00126 00127 // Increment the current date of the traversal 00128 ++CurrentDate; 00129 // Update Clip infos. 00130 CTravCameraScene::update(); 00131 00132 // Compute pyramid in view basis. 00133 CVector pfoc(0,0,0); 00134 CVector lb(Left, Near, Bottom ); 00135 CVector lt(Left, Near, Top ); 00136 CVector rb(Right, Near, Bottom ); 00137 CVector rt(Right, Near, Top ); 00138 00139 CVector lbFar(Left, Far, Bottom); 00140 CVector ltFar(Left, Far, Top ); 00141 CVector rbFar(Right, Far, Bottom); 00142 CVector rtFar(Right, Far, Top ); 00143 00144 uint32 i, j; 00145 00146 ViewPyramid[NL3D_CLIP_PLANE_NEAR].make(lt, lb, rt); 00147 ViewPyramid[NL3D_CLIP_PLANE_FAR].make(lbFar, ltFar, rtFar); 00148 00149 if(Perspective) 00150 { 00151 ViewPyramid[NL3D_CLIP_PLANE_LEFT].make(pfoc, lt, lb); 00152 ViewPyramid[NL3D_CLIP_PLANE_TOP].make(pfoc, rt, lt); 00153 ViewPyramid[NL3D_CLIP_PLANE_RIGHT].make(pfoc, rb, rt); 00154 ViewPyramid[NL3D_CLIP_PLANE_BOTTOM].make(pfoc, lb, rb); 00155 } 00156 else 00157 { 00158 ViewPyramid[NL3D_CLIP_PLANE_LEFT].make(lt, ltFar, lbFar); 00159 ViewPyramid[NL3D_CLIP_PLANE_TOP].make(lt, rtFar, ltFar); 00160 ViewPyramid[NL3D_CLIP_PLANE_RIGHT].make(rt, rbFar, rtFar); 00161 ViewPyramid[NL3D_CLIP_PLANE_BOTTOM].make(lb, lbFar, rbFar); 00162 } 00163 00164 // Compute pyramid in World basis. 00165 // The vector transformation M of a plane p is computed as p*M-1. 00166 // Here, ViewMatrix== CamMatrix-1. Hence the following formula. 00167 for (i = 0; i < 6; i++) 00168 { 00169 WorldPyramid[i]= ViewPyramid[i]*ViewMatrix; 00170 } 00171 00172 // bkup this pyramid (because this one may be modified by the cluster system). 00173 WorldFrustumPyramid= WorldPyramid; 00174 00175 00176 // update the QuadGridClipManager. 00177 if(_QuadGridClipManager) 00178 { 00179 _QuadGridClipManager->updateClustersFromCamera(CamPos); 00180 } 00181 00182 H_BEFORE( NL3D_TravClip_ClearLists ); 00183 00184 // Clear the traversals list. 00185 Scene->getAnimDetailTrav().clearVisibleList(); 00186 Scene->getLoadBalancingTrav().clearVisibleList(); 00187 Scene->getLightTrav().clearLightedList(); 00188 Scene->getRenderTrav().clearRenderList(); 00189 00190 H_AFTER( NL3D_TravClip_ClearLists ); 00191 00192 00193 H_BEFORE( NL3D_TravClip_ResetVisible ); 00194 00195 /* For all objects marked visible in preceding render, reset _Visible state here. 00196 NB: must reset _Visible State to false because sometimes traverseClip() are even not executed 00197 (Cluster clip, QuadGridClipManager clip...). 00198 And somes models read this _Visible state. eg: Skins/StickedObjects test the Visible state of 00199 their _AncestorSkeletonModel. 00200 */ 00201 for (i=0;i<_CurrentNumVisibleModels;i++) 00202 { 00203 // if the model still exists (see ~CTransform()) 00204 if( _VisibleList[i] ) 00205 { 00206 // disable his visibility. 00207 _VisibleList[i]->_Visible= false; 00208 // let him know that it is no more in the list. 00209 _VisibleList[i]->_IndexInVisibleList= -1; 00210 } 00211 } 00212 // Clear The visible List. 00213 _CurrentNumVisibleModels= 0; 00214 // Clear the visible cluster list. 00215 _VisibleClusters.clear(); 00216 00217 H_AFTER( NL3D_TravClip_ResetVisible ); 00218 00219 // Found where is the camera 00220 //======================== 00221 00222 H_BEFORE( NL3D_TravClip_FindCameraCluster); 00223 00224 // Found the cluster where the camera is 00225 static vector<CCluster*> vCluster; 00226 00227 vCluster.clear(); 00228 sceneRoot->clipDelChild(RootCluster); 00229 00230 // In which cluster is the camera ? 00231 CQuadGrid<CCluster*>::CIterator itAcc; 00232 if (Camera->getClusterSystem() == (CInstanceGroup*)-1) 00233 { 00234 fullSearch(vCluster, RootCluster->Group, CamPos); 00235 for (i = 0; i < vCluster.size(); ++i) 00236 sceneRoot->clipAddChild(vCluster[i]); 00237 } 00238 else 00239 { 00240 bool bInWorld = true; 00241 Accel.select (CamPos, CamPos); 00242 itAcc = Accel.begin(); 00243 while (itAcc != Accel.end()) 00244 { 00245 CCluster *pCluster = *itAcc; 00246 if (pCluster->Group == Camera->getClusterSystem()) 00247 if (pCluster->isIn (CamPos)) 00248 { 00249 sceneRoot->clipAddChild(pCluster); 00250 vCluster.push_back (pCluster); 00251 bInWorld = false; 00252 } 00253 ++itAcc; 00254 } 00255 00256 if (bInWorld) 00257 { 00258 sceneRoot->clipAddChild(RootCluster); 00259 vCluster.push_back (RootCluster); 00260 } 00261 } 00262 00264 for(i=0;i<vCluster.size();i++) 00265 { 00266 vCluster[i]->setCameraIn(true); 00267 } 00268 00269 00270 H_AFTER( NL3D_TravClip_FindCameraCluster); 00271 00272 // Manage Moving Objects 00273 //===================== 00274 00275 H_BEFORE( NL3D_TravClip_MovingObjects); 00276 00277 // Unlink the moving objects from their clusters 00278 CHrcTrav &hrcTrav= Scene->getHrcTrav(); 00279 for (i = 0; i < hrcTrav._MovingObjects.size(); ++i) 00280 { 00281 CTransformShape *pTfmShp = hrcTrav._MovingObjects[i]; 00282 00283 static vector<CTransform*> vModels; 00284 vModels.clear(); 00285 uint numClipParents= pTfmShp->clipGetNumParents(); 00286 for(j=0;j<numClipParents;j++) 00287 { 00288 CTransform *pFather = pTfmShp->clipGetParent(j); 00289 00290 // Does the father is a cluster ?? 00291 if ( pFather->isCluster() ) 00292 { 00293 vModels.push_back (pFather); 00294 } 00295 } 00296 // Remove me from all clusters 00297 for (j = 0; j < vModels.size(); ++j) 00298 { 00299 vModels[j]->clipDelChild(pTfmShp); 00300 } 00301 // Remove me from Root Too 00302 sceneRoot->clipDelChild(pTfmShp); 00303 00304 // NB: only the SonsOfAncestorSkeletonModelGroup may still be here. 00305 } 00306 00307 // Affect the moving objects to their clusters 00308 for (i = 0; i < hrcTrav._MovingObjects.size(); ++i) 00309 { 00310 CTransformShape *pTfmShp = hrcTrav._MovingObjects[i]; 00311 00312 bool bInWorld = true; 00313 CAABBox box; 00314 pTfmShp->getAABBox (box); 00315 // Transform the box in the world 00316 CVector c = box.getCenter(); 00317 CVector p = box.getCenter()+box.getHalfSize(); 00318 const CMatrix &wm = pTfmShp->getWorldMatrix(); 00319 c = wm * c; 00320 p = wm * p; 00321 float s = (p - c).norm(); 00322 00323 Accel.select (c+CVector(s,s,s), c+CVector(-s,-s,-s)); 00324 itAcc = Accel.begin(); 00325 while (itAcc != Accel.end()) 00326 { 00327 CCluster *pCluster = *itAcc; 00328 if (pCluster->Group == pTfmShp->getClusterSystem()) 00329 if (pCluster->isIn (c,s)) 00330 { 00331 pCluster->clipAddChild(pTfmShp); 00332 bInWorld = false; 00333 } 00334 ++itAcc; 00335 } 00336 00337 // Moving object in the world -> link to root or to the CQuadGridClipManager. 00338 if (bInWorld) 00339 { 00340 if( _QuadGridClipManager && pTfmShp->isQuadGridClipEnabled() ) 00341 { 00342 // try to insert in the best cluster of the _QuadGridClipManager. 00343 if(!_QuadGridClipManager->linkModel(pTfmShp)) 00344 // if fails, link to "root". 00345 RootCluster->clipAddChild(pTfmShp); 00346 } 00347 else 00348 { 00349 RootCluster->clipAddChild(pTfmShp); 00350 } 00351 } 00352 } 00353 00354 H_AFTER( NL3D_TravClip_MovingObjects); 00355 00356 // Clip the graph. 00357 //===================== 00358 00359 H_BEFORE( NL3D_TravClip_Traverse); 00360 00361 00362 // Traverse the graph. 00363 sceneRoot->traverseClip(); 00364 00365 00366 // Unlink the cluster where we are 00367 for (i = 0; i < vCluster.size(); ++i) 00368 { 00369 // reset Camera In Flag. 00370 vCluster[i]->setCameraIn(false); 00371 00372 // remove from Clip Root 00373 sceneRoot->clipDelChild(vCluster[i]); 00374 } 00375 00376 H_AFTER( NL3D_TravClip_Traverse); 00377 00378 // Load Balance the Skeleton CLod state here. 00379 // ========================= 00380 /* Can't do it in LoadBalancingTrav because sons with _AncestorSkeletonModel!=NULL may be hiden if a skeleton 00381 is displayed in CLod mode. 00382 So must do it here, then clip all sons of AncestoreSkeletonModelGroup. 00383 */ 00384 H_BEFORE( NL3D_TravClip_LoadBalanceCLod); 00385 loadBalanceSkeletonCLod(); 00386 H_AFTER( NL3D_TravClip_LoadBalanceCLod); 00387 00388 H_BEFORE( NL3D_TravClip_SkeletonClip); 00389 00390 // At the end of the clip traverse, must update clip for Objects which have a skeleton ancestor 00391 // ========================= 00392 // those are linked to the SonsOfAncestorSkeletonModelGroup, so traverse it now. 00393 if (Scene->SonsOfAncestorSkeletonModelGroup) 00394 Scene->SonsOfAncestorSkeletonModelGroup->traverseClip(); 00395 00396 // For All Skeletons, clip their ShadowMap possible projection against the frustum only. 00397 // ========================= 00398 /* 00399 Done here, because can't do in clip() in case of a skeleton in a cluster 00400 (We insert in cluster with the SkeletonModel BBox, not the SkeletonModel + Shadow BBox). 00401 */ 00402 clipSkeletonShadowMaps(); 00403 00404 // Update Here the Skin render Lists of All visible Skeletons 00405 // ========================= 00406 /* 00407 Done here, because AnimDetail and Render need correct lists. NB: important to do it 00408 before Render Traversal, because updateSkinRenderLists() may change the transparency flag!! 00409 NB: can't do it in any traverse() because must be sure that it is done 00410 (traverseHRC not called if SonOfAncestorSkeletonModel, and traverseClip not called if in a cluster). 00411 NB: must do even if clipped because: 00412 1/ maybe used for generateShadow() (through the ancestorSkeletonModel) 00413 2/ the cost of method is 0 all the time (but when true changes) 00414 */ 00415 CScene::ItSkeletonModelList itSkel; 00416 for(itSkel= Scene->getSkeletonModelListBegin(); itSkel!=Scene->getSkeletonModelListEnd(); itSkel++) 00417 { 00418 CSkeletonModel *sm= *itSkel; 00419 sm->updateSkinRenderLists(); 00420 } 00421 00422 H_AFTER( NL3D_TravClip_SkeletonClip); 00423 } |
|
Definition at line 439 of file clip_trav.cpp. References Accel, NL3D::CQuadGrid< CCluster * >::begin(), NL3D::CQuadGrid< CCluster * >::end(), NL3D::CQuadGrid< CCluster * >::erase(), and NL3D::CQuadGrid< CCluster * >::selectAll(). Referenced by NL3D::CInstanceGroup::removeFromScene().
|
|
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().
|
|
Definition at line 166 of file clip_trav.h. |
|
Definition at line 168 of file clip_trav.h. Referenced by NL3D::CTransform::~CTransform(). |
|
Definition at line 170 of file clip_trav.h. Referenced by CClipTrav(), getQuadGridClipManager(), setQuadGridClipManager(), and traverse(). |
|
Definition at line 183 of file clip_trav.h. Referenced by loadBalanceSkeletonCLod(). |
|
Add a visible cluster to the list.
Definition at line 133 of file clip_trav.h. Referenced by getClusterVisibilityTracking(), and setClusterVisibilityTracking(). |
|
Add a visible cluster to the list.
Definition at line 134 of file clip_trav.h. Referenced by addVisibleCluster(), getVisibleClusters(), and traverse(). |
|
Definition at line 167 of file clip_trav.h. Referenced by NL3D::CTransform::~CTransform(). |
|
Definition at line 156 of file clip_trav.h. Referenced by NL3D::CInstanceGroup::addToSceneWhenAllShapesLoaded(), CClipTrav(), NL3D::CScene::findCameraClusterSystemFromRay(), registerCluster(), traverse(), NL3D::CCluster::traverseHrc(), and unregisterCluster(). |
|
Definition at line 75 of file trav_scene.h. Referenced by NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender(). |
|
Definition at line 154 of file clip_trav.h. Referenced by NL3D::CScene::render(), and traverse(). |
|
Definition at line 80 of file trav_scene.h. Referenced by NL3D::CLandscapeModel::clipAndRenderLandscape(), NL3D::CTravCameraScene::CTravCameraScene(), and NL3D::CTravCameraScene::update(). |
|
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(). |
|
|
Definition at line 151 of file clip_trav.h. Referenced by NL3D::CParticleSystemModel::traverseAnimDetail(), NL3D::CTransform::traverseClip(), NL3D::CParticleSystemModel::traverseClip(), and NL3D::CLandscapeModel::traverseClip(). |
|
Definition at line 75 of file trav_scene.h. Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender(). |
|
for CQuadGridClipClusterClip only. This flag means models traversed do not need to clip, they are sure to be visible. Definition at line 161 of file clip_trav.h. Referenced by CClipTrav(), NL3D::CTransformShape::clip(), and NL3D::CQuadGridClipClusterQTreeNode::clip(). |
|
Definition at line 75 of file trav_scene.h. Referenced by NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender(). |
|
Definition at line 75 of file trav_scene.h. Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender(). |
|
Definition at line 76 of file trav_scene.h. Referenced by NL3D::CTravCameraScene::setFrustum(). |
|
Definition at line 75 of file trav_scene.h. Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CTravCameraScene::setFrustum(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender(). |
|
Definition at line 153 of file clip_trav.h. Referenced by NL3D::CScene::initDefaultRoots(), NL3D::CQuadGridClipClusterListDist::resetSons(), and traverse(). |
|
Definition at line 55 of file trav_scene.h. Referenced by NL3D::CScene::CScene(), NL3D::CMeshMRMSkinnedGeom::profileSceneRender(), NL3D::CMeshMRMGeom::profileSceneRender(), and NL3D::CMeshGeom::profileSceneRender(). |
|
Definition at line 75 of file trav_scene.h. Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender(). |
|
Definition at line 78 of file trav_scene.h. Referenced by NL3D::CWaterModel::computeClippedPoly(), NL3D::CParticleSystemModel::doAnimate(), NL3D::CWaterModel::traverseRender(), and NL3D::CFlareModel::traverseRender(). |
|
Vision Pyramid (6 normalized planes) in the view basis.
Definition at line 145 of file clip_trav.h. Referenced by traverse(). |
|
Vision Pyramid (6 normalized planes) in the world basis. NB: NOT modified by the ClusterSystem.
Definition at line 147 of file clip_trav.h. Referenced by NL3D::CLandscapeModel::clipAndRenderLandscape(), clipSkeletonShadowMaps(), NL3D::CWaterModel::computeClippedPoly(), NL3D::CWaterModel::computeSimpleClippedPoly(), NL3D::CScene::render(), traverse(), and NL3D::CLandscapeModel::traverseClip(). |
|
Vision Pyramid in the world basis. NB: may be modified by the ClusterSystem.
Definition at line 149 of file clip_trav.h. Referenced by NL3D::CTransformShape::clip(), NL3D::CQuadGridClipClusterQTreeNode::clip(), NL3D::CCluster::recursTraverseClip(), traverse(), NL3D::CParticleSystemModel::traverseClip(), and NL3D::CLandscapeModel::traverseClip(). |