|
Blender
V2.59
|
00001 /* 00002 * $Id: KX_MouseFocusSensor.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_MOUSEFOCUSSENSOR 00036 #define __KX_MOUSEFOCUSSENSOR 00037 00038 #include "SCA_MouseSensor.h" 00039 00040 class KX_RayCast; 00041 00049 class KX_MouseFocusSensor : public SCA_MouseSensor 00050 { 00051 00052 Py_Header; 00053 00054 public: 00055 00056 KX_MouseFocusSensor(class SCA_MouseManager* eventmgr, 00057 int startx, 00058 int starty, 00059 short int mousemode, 00060 int focusmode, 00061 bool bTouchPulse, 00062 KX_Scene* kxscene, 00063 KX_KetsjiEngine* kxengine, 00064 SCA_IObject* gameobj); 00065 00066 virtual ~KX_MouseFocusSensor() { ; }; 00067 virtual CValue* GetReplica() { 00068 CValue* replica = new KX_MouseFocusSensor(*this); 00069 // this will copy properties and so on... 00070 replica->ProcessReplica(); 00071 return replica; 00072 }; 00073 00074 virtual void Replace_IScene(SCA_IScene *val) 00075 { 00076 m_kxscene= static_cast<KX_Scene *>(val); 00077 }; 00078 00079 00083 virtual bool Evaluate(); 00084 virtual void Init(); 00085 00086 virtual bool IsPositiveTrigger() { 00087 bool result = m_positive_event; 00088 if (m_invert) result = !result; 00089 return result; 00090 }; 00091 00092 bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); 00093 bool NeedRayCast(KX_ClientObjectInfo* client) { return true; } 00094 00095 const MT_Point3& RaySource() const; 00096 const MT_Point3& RayTarget() const; 00097 const MT_Point3& HitPosition() const; 00098 const MT_Vector3& HitNormal() const; 00099 const MT_Vector2& HitUV() const; 00100 00101 #ifdef WITH_PYTHON 00102 00103 /* --------------------------------------------------------------------- */ 00104 /* Python interface ---------------------------------------------------- */ 00105 /* --------------------------------------------------------------------- */ 00106 00107 /* attributes */ 00108 static PyObject* pyattr_get_ray_source(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00109 static PyObject* pyattr_get_ray_target(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00110 static PyObject* pyattr_get_ray_direction(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00111 static PyObject* pyattr_get_hit_object(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00112 static PyObject* pyattr_get_hit_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00113 static PyObject* pyattr_get_hit_normal(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00114 static PyObject* pyattr_get_hit_uv(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); 00115 00116 #endif // WITH_PYTHON 00117 00118 /* --------------------------------------------------------------------- */ 00119 SCA_IObject* m_hitObject; 00120 void* m_hitObject_Last; /* only use for comparison, never access */ 00121 00122 private: 00126 int m_focusmode; 00127 00131 bool m_mouse_over_in_previous_frame; 00132 00136 bool m_bTouchPulse; 00137 00141 bool m_positive_event; 00142 00146 bool ParentObjectHasFocusCamera(KX_Camera *cam); 00147 00151 bool ParentObjectHasFocus(void); 00152 00156 MT_Point3 m_hitPosition; 00157 00161 MT_Point3 m_prevTargetPoint; 00162 00166 MT_Point3 m_prevSourcePoint; 00167 00171 MT_Vector3 m_hitNormal; 00172 00176 MT_Vector2 m_hitUV; 00177 00181 KX_Scene* m_kxscene; 00182 00185 KX_KetsjiEngine* m_kxengine; 00186 }; 00187 00188 #endif //__KX_MOUSESENSOR 00189