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

SCA_IObject.cpp

Go to the documentation of this file.
00001 
00002 #include "SCA_IObject.h"
00003 #include "SCA_ISensor.h"
00004 #include "SCA_IController.h"
00005 #include "SCA_IActuator.h"
00006 
00007 #include "ListValue.h"
00008 
00009 /* ------------------------------------------------------------------------- */
00010 /* Python functions                                                          */
00011 /* ------------------------------------------------------------------------- */
00012 
00013 /* Integration hooks ------------------------------------------------------- */
00014 PyTypeObject SCA_IObject::Type = {
00015         PyObject_HEAD_INIT(&PyType_Type)
00016         0,
00017         "SCA_IObject",
00018         sizeof(SCA_IObject),
00019         0,
00020         PyDestructor,
00021         0,
00022         __getattr,
00023         __setattr,
00024         0, //&MyPyCompare,
00025         __repr,
00026         0, //&cvalue_as_number,
00027         0,
00028         0,
00029         0,
00030         0
00031 };
00032 
00033 PyParentObject SCA_IObject::Parents[] = {
00034         &SCA_IObject::Type,
00035         &CValue::Type,
00036         NULL
00037 };
00038 
00039 PyMethodDef SCA_IObject::Methods[] = {
00040         //{"setOrientation", (PyCFunction) SCA_IObject::sPySetOrientation, METH_VARARGS},
00041         //{"getOrientation", (PyCFunction) SCA_IObject::sPyGetOrientation, METH_VARARGS},
00042         {NULL,NULL} //Sentinel
00043 };
00044 
00045 SCA_IObject::~SCA_IObject() {
00046         SCA_SensorList::iterator its;
00047         for (its = m_sensors.begin(); !(its == m_sensors.end()); ++its) {
00048                 ((CValue*)(*its))->Release();
00049         }
00050         SCA_ControllerList::iterator itc; 
00051         for (itc = m_controllers.begin(); !(itc == m_controllers.end()); ++itc)
00052         {
00053                 ((CValue*)(*itc))->Release();
00054         }
00055         SCA_ActuatorList::iterator ita;
00056         for (ita = m_actuators.begin(); !(ita==m_actuators.end()); ++ita) {
00057                 ((CValue*)(*ita))->Release();
00058         }
00059 
00060         //T_InterpolatorList::iterator i;
00061         //for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
00062         //      delete *i;
00063         //}
00064 }
00065 
00066 PyObject* SCA_IObject::_getattr(char* attr) {
00067         _getattr_up(CValue);
00068 }
00069 
00070 
00071 void SCA_IObject::ReParentLogic()

00072 {
00073         SCA_SensorList& oldsensors = GetSensors();
00074         
00075         int sen = 0;
00076         SCA_SensorList::iterator its;
00077         for (its = oldsensors.begin(); !(its==oldsensors.end()); ++its)
00078         {
00079                 SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica();
00080                 newsensor->ReParent(this);
00081                 oldsensors[sen++] = newsensor;
00082         }
00083 
00084         SCA_ControllerList& oldcontrollers = GetControllers();
00085         int con = 0;
00086         SCA_ControllerList::iterator itc;
00087         for (itc = oldcontrollers.begin(); !(itc==oldcontrollers.end()); ++itc)
00088         {
00089                 SCA_IController* newcontroller = (SCA_IController*)(*itc)->GetReplica();
00090                 newcontroller->ReParent(this);
00091                 oldcontrollers[con++]=newcontroller;
00092 
00093         }
00094         SCA_ActuatorList& oldactuators  = GetActuators();
00095         
00096         int act = 0;
00097         SCA_ActuatorList::iterator ita;
00098         for (ita = oldactuators.begin(); !(ita==oldactuators.end()); ++ita)
00099         {
00100                 SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica();
00101                 newactuator->ReParent(this);
00102                 newactuator->SetActive(false);
00103                 oldactuators[act++] = newactuator;
00104         }
00105                 
00106 }
00107 
00108 SCA_ISensor* SCA_IObject::FindSensor(const CCString& sensorname)

00109 {
00110         SCA_ISensor* foundsensor = NULL;
00111 
00112         for (SCA_SensorList::iterator its = m_sensors.begin();!(its==m_sensors.end());its++)
00113         {
00114                 if ((*its)->GetName() == sensorname)
00115                 {
00116                         foundsensor = (*its);
00117                         break;
00118                 }
00119         }
00120         return foundsensor;
00121 }
00122 
00123 
00124 SCA_IController* SCA_IObject::FindController(const CCString& controllername)

00125 {
00126         SCA_IController* foundcontroller = NULL;
00127 
00128         for (SCA_ControllerList::iterator itc = m_controllers.begin();!(itc==m_controllers.end());itc++)
00129         {
00130                 if ((*itc)->GetName() == controllername)
00131                 {
00132                         foundcontroller = (*itc);
00133                         break;
00134                 }       
00135         }
00136         return foundcontroller;
00137 }
00138 
00139 SCA_IActuator* SCA_IObject::FindActuator(const CCString& actuatorname)

00140 {
00141         SCA_IActuator* foundactuator = NULL;
00142 
00143         for (SCA_ActuatorList::iterator ita = m_actuators.begin();!(ita==m_actuators.end());ita++)
00144         {
00145                 if ((*ita)->GetName() == actuatorname)
00146                 {
00147                         foundactuator = (*ita);
00148                         break;
00149                 }
00150         }
00151 
00152         return foundactuator;
00153 }
00154 
00155 
00156 void SCA_IObject::SetCurrentTime(float currentTime) {
00157         //T_InterpolatorList::iterator i;
00158         //for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
00159         //      (*i)->Execute(currentTime);
00160         //}
00161 }
00162         

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