basic/universe/Entity.cpp

Go to the documentation of this file.
00001 #include <assert.h>
00002 #include <math\Matrix4x4.h>
00003 #include <stdio.h>
00004 #include "Universe\Entity.h"
00005 
00006 Entity::Entity (FrameManager* frameManager)
00007 : 
00008         baseFrame( 0 ) ,
00009     name(NULL),
00010         frameManager( frameManager )
00011 {
00012         this->SetName( "" ) ;
00013 }
00014 
00015 Entity::Entity (const Entity& right)
00016 : 
00017     baseFrame( right.baseFrame ),
00018     name(NULL),
00019     frameManager( right.frameManager )
00020   //## end Entity::Entity%925324843.initialization
00021 {
00022   //## begin Entity::Entity%925324843.body preserve=yes
00023         this->SetName( right.GetName() ) ;
00024   //## end Entity::Entity%925324843.body
00025 }
00026 
00027 
00028 Entity::~Entity()
00029 {
00030   //## begin Entity::~Entity%.body preserve=yes
00031         baseFrame = 0 ;
00032         frameManager = NULL ;
00033         delete[] name ;
00034         name = NULL ;
00035   //## end Entity::~Entity%.body
00036 }
00037 
00038 
00039 
00040 //## Other Operations (implementation)
00041 void Entity::SetBaseFrame (const unsigned int baseFrame)
00042 {
00043   //## begin Entity::SetBaseFrame%925235861.body preserve=yes
00044         this->baseFrame = baseFrame ;
00045   //## end Entity::SetBaseFrame%925235861.body
00046 }
00047 
00048 void Entity::SetFrameManager (FrameManager* frameManager)
00049 {
00050   //## begin Entity::SetFrameManager%925503316.body preserve=yes
00051         this->frameManager = frameManager ;
00052   //## end Entity::SetFrameManager%925503316.body
00053 }
00054 
00055 Matrix4x4 Entity::GetTransform () const
00056 {
00057   //## begin Entity::GetTransform%926014529.body preserve=yes
00058         assert( frameManager != NULL ) ;
00059         return frameManager->GetTransformRelative( baseFrame, 0 ) ;
00060   //## end Entity::GetTransform%926014529.body
00061 }
00062 
00063 unsigned int Entity::BaseFrame () const
00064 {
00065   //## begin Entity::BaseFrame%926807003.body preserve=yes
00066         static char copyright[] = "copyright 1999 ian gipson SFU engineering" ;
00067         return baseFrame ;
00068   //## end Entity::BaseFrame%926807003.body
00069 }
00070 
00071 void Entity::SetName (const char* name)
00072 {
00073   //## begin Entity::SetName%961125353.body preserve=yes
00074         delete[] this->name ;
00075         this->name = new char[ strlen( name ) + 1 ] ;
00076         strcpy( this->name, name ) ;
00077   //## end Entity::SetName%961125353.body
00078 }
00079 
00080 const char* Entity::GetName () const
00081 {
00082   //## begin Entity::GetName%961125354.body preserve=yes
00083         return this->name ;
00084   //## end Entity::GetName%961125354.body
00085 }
00086 
00087 // Additional Declarations
00088   //## begin Entity%37195CDA01B8.declarations preserve=yes
00089 bool Entity::DeserializeEntity( IfstreamWithComments& is )
00090 {
00091         //check the header for #entity
00092         char line[ 256 ] = "" ;
00093         is.GetSolidLine( line, 256 ) ;
00094         if( stricmp( line, "#entity" ) != 0 )
00095         {
00096                 return false;
00097         }
00098         
00099         is.GetSolidLine( line, 256 ) ;
00100         while( stricmp( line, "#end_entity" ) != 0 )
00101         {
00102                 char keyWord[ 256 ] = "" ;
00103         ::sscanf( line, "%s", &keyWord[ 0 ] ) ;
00104 
00105                 if( stricmp( keyWord, "#name") == 0 )
00106                 {
00107                         char name[ 256 ] = "" ;
00108             ::sscanf( line, "%s%s", &keyWord[ 0 ], &name[ 0 ] ) ;
00109                         this->SetName( name ) ;
00110                 }
00111         else
00112         {
00113         }
00114                 is.GetSolidLine( line, 256 );
00115         assert( stricmp( line, "#end_entity" ) == 0 );
00116         }
00117         return true;
00118 }
00119   //## end Entity%37195CDA01B8.declarations
00120 //## begin module%37195CDA01B8.epilog preserve=yes
00121 //## end module%37195CDA01B8.epilog

Generated on Sat Apr 1 21:30:35 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO