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