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 */ 00027 00033 #ifndef KX_NEARSENSOR_H 00034 #define KX_NEARSENSOR_H 00035 00036 #include "KX_TouchSensor.h" 00037 #include "KX_ClientObjectInfo.h" 00038 00039 class KX_Scene; 00040 struct PHY_CollData; 00041 00042 class KX_NearSensor : public KX_TouchSensor 00043 { 00044 Py_Header 00045 protected: 00046 float m_Margin; 00047 float m_ResetMargin; 00048 00049 KX_ClientObjectInfo* m_client_info; 00050 public: 00051 KX_NearSensor(class SCA_EventManager* eventmgr, 00052 class KX_GameObject* gameobj, 00053 float margin, 00054 float resetmargin, 00055 bool bFindMaterial, 00056 const STR_String& touchedpropname, 00057 PHY_IPhysicsController* ctrl); 00058 /* 00059 public: 00060 KX_NearSensor(class SCA_EventManager* eventmgr, 00061 class KX_GameObject* gameobj, 00062 double margin, 00063 double resetmargin, 00064 bool bFindMaterial, 00065 const STR_String& touchedpropname, 00066 class KX_Scene* scene); 00067 */ 00068 virtual ~KX_NearSensor(); 00069 virtual void SynchronizeTransform(); 00070 virtual CValue* GetReplica(); 00071 virtual void ProcessReplica(); 00072 virtual void SetPhysCtrlRadius(); 00073 virtual bool Evaluate(); 00074 00075 virtual void ReParent(SCA_IObject* parent); 00076 virtual bool NewHandleCollision(void* obj1,void* obj2, 00077 const PHY_CollData * coll_data); 00078 virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2); 00079 virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2) { return false; }; 00080 virtual sensortype GetSensorType() { return ST_NEAR; } 00081 00082 #ifdef WITH_PYTHON 00083 00084 /* --------------------------------------------------------------------- */ 00085 /* Python interface ---------------------------------------------------- */ 00086 /* --------------------------------------------------------------------- */ 00087 00088 //No methods 00089 00090 //This method is used to make sure the distance does not exceed the reset distance 00091 static int CheckResetDistance(void *self, const PyAttributeDef*) 00092 { 00093 KX_NearSensor* sensor = reinterpret_cast<KX_NearSensor*>(self); 00094 00095 if (sensor->m_Margin > sensor->m_ResetMargin) 00096 sensor->m_ResetMargin = sensor->m_Margin; 00097 00098 sensor->SetPhysCtrlRadius(); 00099 00100 return 0; 00101 } 00102 00103 #endif // WITH_PYTHON 00104 00105 }; 00106 00107 #endif //KX_NEARSENSOR_H 00108