Blender  V2.59
SCA_IObject.h
Go to the documentation of this file.
00001 /*
00002  * $Id: SCA_IObject.h 35063 2011-02-22 10:33:14Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00036 #ifndef SCA_IOBJECT_H
00037 #define SCA_IOBJECT_H
00038 
00039 #include "Value.h"
00040 #include <vector>
00041 
00042 class SCA_IObject;
00043 class SCA_ISensor;
00044 class SCA_IController;
00045 class SCA_IActuator;
00046 
00047 #ifdef WITH_PYTHON
00048 template<class T> T PyVecTo(PyObject*);
00049 #endif
00050 
00051 typedef std::vector<SCA_ISensor *>       SCA_SensorList;
00052 typedef std::vector<SCA_IController *>   SCA_ControllerList;
00053 typedef std::vector<SCA_IActuator *>     SCA_ActuatorList;
00054 typedef std::vector<SCA_IObject *>               SCA_ObjectList;
00055 
00056 class SCA_IObject :     public CValue
00057 {
00058         
00059         Py_Header;
00060         
00061 protected:
00062         friend class KX_StateActuator;
00063         friend class SCA_IActuator;
00064         friend class SCA_IController;
00065         SCA_SensorList         m_sensors;
00066         SCA_ControllerList     m_controllers;
00067         SCA_ActuatorList       m_actuators;
00068         SCA_ActuatorList       m_registeredActuators;   // actuators that use a pointer to this object
00069         SCA_ObjectList             m_registeredObjects;         // objects that hold reference to this object
00070 
00071         // SG_Dlist: element of objects with active actuators
00072         //           Head: SCA_LogicManager::m_activeActuators
00073         // SG_QList: Head of active actuators list on this object
00074         //           Elements: SCA_IActuator
00075         SG_QList                           m_activeActuators;
00076         // SG_Dlist: element of list os lists with active controllers
00077         //           Head: SCA_LogicManager::m_activeControllers
00078         // SG_QList: Head of active controller list on this object
00079         //           Elements: SCA_IController
00080         SG_QList                           m_activeControllers;
00081         // SG_Dlist: element of list of lists of active controllers
00082         //           Head: SCA_LogicManager::m_activeControllers
00083         // SG_QList: Head of active bookmarked controller list globally
00084         //           Elements: SCA_IController with bookmark option
00085         static SG_QList            m_activeBookmarkedControllers;
00086 
00087         static class MT_Point3 m_sDummy;
00088 
00092         bool m_ignore_activity_culling;
00093 
00097         bool m_suspended;
00098 
00102         unsigned int                    m_initState;
00103 
00107         unsigned int                    m_state;
00108 
00112         SG_QList*                               m_firstState;
00113 
00114 public:
00115         
00116         SCA_IObject();
00117         virtual ~SCA_IObject();
00118 
00119         SCA_ControllerList& GetControllers()
00120         {
00121                 return m_controllers;
00122         }
00123         SCA_SensorList& GetSensors()
00124         {
00125                 return m_sensors;
00126         }
00127         SCA_ActuatorList& GetActuators()
00128         {
00129                 return m_actuators;
00130         }
00131         SG_QList& GetActiveActuators()
00132         {
00133                 return m_activeActuators;
00134         }
00135 
00136         void AddSensor(SCA_ISensor* act);
00137         void ReserveSensor(int num)
00138         {
00139                 m_sensors.reserve(num);
00140         }
00141         void AddController(SCA_IController* act);
00142         void ReserveController(int num)
00143         {
00144                 m_controllers.reserve(num);
00145         }
00146         void AddActuator(SCA_IActuator* act);
00147         void ReserveActuator(int num)
00148         {
00149                 m_actuators.reserve(num);
00150         }
00151         void RegisterActuator(SCA_IActuator* act);
00152         void UnregisterActuator(SCA_IActuator* act);
00153         
00154         void RegisterObject(SCA_IObject* objs);
00155         void UnregisterObject(SCA_IObject* objs);
00161         virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; }
00162 
00163         SCA_ISensor* FindSensor(const STR_String& sensorname);
00164         SCA_IActuator* FindActuator(const STR_String& actuatorname);
00165         SCA_IController* FindController(const STR_String& controllername);
00166 
00167         void SetCurrentTime(float currentTime) {}
00168 
00169         virtual void ReParentLogic();
00170         
00174         void SetIgnoreActivityCulling(bool b)
00175         {
00176                 m_ignore_activity_culling = b;
00177         }
00178 
00183         bool GetIgnoreActivityCulling()
00184         {
00185                 return m_ignore_activity_culling;
00186         }
00187 
00191         void Suspend(void);
00192         
00196         void Resume(void);
00197 
00201         void SetInitState(unsigned int initState) { m_initState = initState; }
00202 
00206         void ResetState(void) { SetState(m_initState); }
00207 
00211         void SetState(unsigned int state);
00212 
00216         unsigned int GetState(void)     { return m_state; }
00217 
00218 //      const class MT_Point3&  ConvertPythonPylist(PyObject* pylist);
00219 
00220         virtual int GetGameObjectType() {return -1;}
00221         
00222         typedef enum ObjectTypes {
00223                 OBJ_ARMATURE=0,
00224                 OBJ_CAMERA=1,
00225                 OBJ_LIGHT=2,
00226         }ObjectTypes;
00227 
00228 };
00229 
00230 #endif //SCA_IOBJECT_H
00231