Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

SG_Node.cpp

Go to the documentation of this file.
00001 #include "SG_Node.h"
00002 
00003 SG_Node::SG_Node(void* clientobj,void* clientinfo,SG_Callbacks callbacks)
00004 :SG_Spatial(clientobj,clientinfo,callbacks)

00005 {
00006 
00007 }
00008 
00009 SG_Node::~SG_Node()

00010 {
00011 
00012 }
00013 
00014 SG_IObject*     SG_Node::GetSGReplica()

00015 {
00016         SG_Node* replica = new SG_Node(*this);
00017         SG_Spatial::ProcessSGReplica(replica);
00018         ProcessSGReplica(replica);
00019         
00020         return replica;
00021 }
00022 void SG_Node::ProcessSGReplica(SG_IObject* replica)

00023 {
00024         
00025         if (m_children.begin() != m_children.end())
00026         {
00027                 // if this node has children, the replica has too, so clear and clone children
00028                 SG_Node* replicanode = (SG_Node*)replica;
00029                 replicanode->ClearSGChildren();
00030         
00031                 SpatialList::iterator childit;
00032                 for (childit = m_children.begin();!(childit==m_children.end());++childit)
00033                 {
00034                         replicanode->AddChild((SG_Spatial*)(*childit)->GetSGReplica());
00035                 }
00036         }
00037 }
00038 
00039 void    SG_Node::Destruct()

00040 {
00041         SG_Spatial::Destruct();
00042 
00043         if (m_children.begin() != m_children.end())
00044         {
00045                 SpatialList::iterator childit;
00046                 for (childit = m_children.begin();!(childit==m_children.end());++childit)
00047                 {
00048                         ((SG_Spatial*)  (*childit))->Destruct();
00049                 }
00050         }
00051 }
00052 
00053 void    SG_Node::AddChild(SG_Spatial* child)

00054 {
00055         m_children.push_back(child);
00056         child->m_SGparent = this; // this way ?
00057 }
00058 
00059 void    SG_Node::UpdateWorldData(double time)

00060 {
00061         SG_Spatial::UpdateWorldData(time);
00062 
00063         // update children's worlddata
00064         for (SpatialList::iterator it = m_children.begin();!(it==m_children.end());++it)
00065         {
00066                 (*it)->UpdateWorldData(time);
00067         }
00068 }
00069 
00070 SpatialList& SG_Node::GetSGChildren()

00071 {
00072         return this->m_children;
00073 }
00074 
00075 void    SG_Node::ClearSGChildren()

00076 {
00077         m_children.clear();
00078 }

Generated at Thu Feb 1 13:03:12 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000