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