Blender  V2.59
KX_RaySensor.h
Go to the documentation of this file.
00001 /*
00002  * $Id: KX_RaySensor.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_RAYSENSOR_H
00036 #define __KX_RAYSENSOR_H
00037 
00038 #include "SCA_ISensor.h"
00039 #include "MT_Point3.h"
00040 #include "SCA_IScene.h" /* only for scene replace */
00041 #include "KX_Scene.h" /* only for scene replace */
00042 
00043 struct KX_ClientObjectInfo;
00044 class KX_RayCast;
00045 
00046 class KX_RaySensor : public SCA_ISensor
00047 {
00048         Py_Header;
00049         STR_String              m_propertyname;
00050         bool                    m_bFindMaterial;
00051         bool                    m_bXRay;
00052         float                   m_distance;
00053         class KX_Scene* m_scene;
00054         bool                    m_bTriggered;
00055         int                             m_axis;
00056         bool                    m_rayHit;
00057         float                   m_hitPosition[3];
00058         SCA_IObject*    m_hitObject;
00059         float                   m_hitNormal[3];
00060         float                   m_rayDirection[3];
00061 
00062 public:
00063         KX_RaySensor(class SCA_EventManager* eventmgr,
00064                                         SCA_IObject* gameobj,
00065                                         const STR_String& propname,
00066                                         bool bFindMaterial,
00067                                         bool bXRay,
00068                                         double distance,
00069                                         int axis,
00070                                         class KX_Scene* ketsjiScene);
00071         virtual ~KX_RaySensor();
00072         virtual CValue* GetReplica();
00073 
00074         virtual bool Evaluate();
00075         virtual bool IsPositiveTrigger();
00076         virtual void Init();
00077 
00078         bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
00079         bool NeedRayCast(KX_ClientObjectInfo* client);
00080 
00081         virtual void            Replace_IScene(SCA_IScene *val) 
00082         {       
00083                 m_scene= static_cast<KX_Scene *>(val); 
00084         }
00085 
00086         //Python Interface
00087         enum RayAxis {
00088                 KX_RAY_AXIS_POS_Y = 0,
00089                 KX_RAY_AXIS_POS_X,
00090                 KX_RAY_AXIS_POS_Z,
00091                 KX_RAY_AXIS_NEG_X,
00092                 KX_RAY_AXIS_NEG_Y,
00093                 KX_RAY_AXIS_NEG_Z
00094         };
00095         
00096 #ifdef WITH_PYTHON
00097 
00098         /* Attributes */
00099         static PyObject* pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00100         
00101 #endif // WITH_PYTHON
00102 
00103 };
00104 
00105 #endif //__KX_RAYSENSOR_H
00106