# 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  

anim_detail_trav.cpp

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #include "std3d.h"
00027 
00028 #include "3d/anim_detail_trav.h"
00029 #include "3d/hrc_trav.h"
00030 #include "3d/transform.h"
00031 #include "3d/skeleton_model.h"
00032 #include "nel/misc/hierarchical_timer.h"
00033 #include "nel/misc/debug.h"
00034 
00035 
00036 using namespace NLMISC;
00037 
00038 
00039 namespace NL3D 
00040 {
00041 
00042 
00043 // ***************************************************************************
00044 IObs                            *CAnimDetailTrav::createDefaultObs() const
00045 {
00046         return new CDefaultAnimDetailObs;
00047 }
00048 
00049 // ***************************************************************************
00050 CAnimDetailTrav::CAnimDetailTrav()
00051 {
00052         CurrentDate=0;
00053         // prepare some space
00054         _VisibleList.reserve(1024);
00055 }
00056 
00057 // ***************************************************************************
00058 void                            CAnimDetailTrav::clearVisibleList()
00059 {
00060         _VisibleList.clear();
00061 }
00062 
00063 // ***************************************************************************
00064 void                            CAnimDetailTrav::addVisibleObs(CTransformAnimDetailObs *obs)
00065 {
00066         _VisibleList.push_back(obs);
00067 }
00068 
00069 
00070 // ***************************************************************************
00071 void                            CAnimDetailTrav::traverse()
00072 {
00073         H_AUTO( NL3D_TravAnimDetail );
00074 
00075         // Inc the date.
00076         CurrentDate++;
00077 
00078         // Traverse all nodes of the visibility list.
00079         uint    nObs= _VisibleList.size();
00080         for(uint i=0; i<nObs; i++)
00081         {
00082                 CTransformAnimDetailObs         *detailObs= _VisibleList[i];
00083                 // If this object has an ancestorSkeletonModel
00084                 CTransformHrcObs                        *hrcObs= safe_cast<CTransformHrcObs*>(detailObs->HrcObs);
00085                 if(hrcObs->_AncestorSkeletonModel)
00086                 {
00087                         // then just skip it! because it will be parsed hierarchically by the first 
00088                         // skeletonModel whith hrcObs->_AncestorSkeletonModel==NULL. (only if this one is visible)
00089                         continue;
00090                 }
00091                 else
00092                 {
00093                         // get the model
00094                         CTransform      *model= safe_cast<CTransform*>(detailObs->Model);
00095                         // If this is a skeleton model, and because hrcObs->_AncestorSkeletonModel==NULL,
00096                         // then it means that it is the Root of a hierarchy of transform that have 
00097                         // hrcObs->_AncestorSkeletonModel!=NULL.
00098                         if( model->isSkeleton() )
00099                         {
00100                                 // Then I must update hierarchically me and the sons (according to HRC hierarchy graph) of this model.
00101                                 traverseHrcRecurs(detailObs);
00102                         }
00103                         else
00104                         {
00105                                 // else, just traverse AnimDetail, an do nothing for Hrc sons
00106                                 detailObs->traverse(NULL);
00107                         }
00108                 }
00109         }
00110 }
00111 
00112 
00113 // ***************************************************************************
00114 void    CAnimDetailTrav::traverseHrcRecurs(IBaseAnimDetailObs *adObs)
00115 {
00116         // first, just doIt me
00117         adObs->traverse(NULL);
00118 
00119 
00120         // then doIt my sons in Hrc.
00121         // get the  hrc observer.
00122         IBaseHrcObs             *hrcObs= adObs->HrcObs;
00123         // for all sons in hrc.
00124         IBaseHrcObs             *sonHrcObs= static_cast<IBaseHrcObs*>(hrcObs->getFirstChild());
00125         while( sonHrcObs )
00126         {
00127                 // get the animDetailObs, and traverse it, recursively
00128                 traverseHrcRecurs(sonHrcObs->AnimDetailObs);
00129 
00130                 // brother in HRC
00131                 sonHrcObs= static_cast<IBaseHrcObs*>(hrcObs->getNextChild());
00132         }
00133 }
00134 
00135 
00136 } // NL3D