|
Blender
V2.59
|
00001 /* 00002 * $Id: KX_IPhysicsController.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 00034 #ifndef __KX_IPHYSICSCONTROLLER_H 00035 #define __KX_IPHYSICSCONTROLLER_H 00036 00037 #include "SG_Controller.h" 00038 #include "MT_Vector3.h" 00039 #include "MT_Point3.h" 00040 #include "MT_Transform.h" 00041 #include "MT_Matrix3x3.h" 00042 00043 struct KX_ClientObjectInfo; 00044 00052 class KX_IPhysicsController : public SG_Controller 00053 00054 { 00055 protected: 00056 bool m_bDyna; 00057 bool m_bSensor; 00058 bool m_bCompound; 00059 bool m_suspendDynamics; 00060 void* m_userdata; 00061 public: 00062 KX_IPhysicsController(bool dyna,bool sensor,bool compound, void* userdata); 00063 virtual ~KX_IPhysicsController(); 00064 00065 00066 virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0; 00067 virtual void SetObject (SG_IObject* object)=0; 00068 virtual void setMargin (float collisionMargin)=0; 00069 00070 virtual void RelativeTranslate(const MT_Vector3& dloc,bool local)=0; 00071 virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local)=0; 00072 virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0; 00073 virtual void ApplyForce(const MT_Vector3& force,bool local)=0; 00074 virtual MT_Vector3 GetLinearVelocity()=0; 00075 virtual MT_Vector3 GetAngularVelocity()=0; 00076 virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0; 00077 virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0; 00078 virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0; 00079 virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0; 00080 00081 virtual void getOrientation(MT_Quaternion& orn)=0; 00082 virtual void setOrientation(const MT_Matrix3x3& orn)=0; 00083 virtual void SetTransform()=0; 00084 //virtual void setOrientation(const MT_Quaternion& orn)=0; 00085 virtual void setPosition(const MT_Point3& pos)=0; 00086 virtual void setScaling(const MT_Vector3& scaling)=0; 00087 virtual MT_Scalar GetMass()=0; 00088 virtual void SetMass(MT_Scalar newmass)=0; 00089 00090 virtual float GetLinVelocityMin()=0; 00091 virtual void SetLinVelocityMin(float newmass)=0; 00092 virtual float GetLinVelocityMax()=0; 00093 virtual void SetLinVelocityMax(float newmass)=0; 00094 00095 virtual MT_Vector3 GetLocalInertia()=0; 00096 virtual MT_Vector3 getReactionForce()=0; 00097 virtual void setRigidBody(bool rigid)=0; 00098 virtual void AddCompoundChild(KX_IPhysicsController* child) = 0; 00099 virtual void RemoveCompoundChild(KX_IPhysicsController* child) = 0; 00100 00101 virtual void SuspendDynamics(bool ghost=false)=0; 00102 virtual void RestoreDynamics()=0; 00103 00104 virtual SG_Controller* GetReplica(class SG_Node* destnode)=0; 00105 00106 void SetDyna(bool isDynamic) { 00107 m_bDyna = isDynamic; 00108 } 00109 00110 void SetSensor(bool isSensor) { 00111 m_bSensor = isSensor; 00112 } 00113 00114 bool IsDyna(void) { 00115 return m_bDyna; 00116 } 00117 00118 bool IsSensor(void) { 00119 return m_bSensor; 00120 } 00121 00122 bool IsCompound(void) { 00123 return m_bCompound; 00124 } 00125 00126 virtual MT_Scalar GetRadius()=0; 00127 virtual void SetSumoTransform(bool nondynaonly)=0; 00128 // todo: remove next line ! 00129 virtual void SetSimulatedTime(double time)=0; 00130 00131 // call from scene graph to update 00132 virtual bool Update(double time)=0; 00133 void* GetUserData() { return m_userdata;} 00134 00135 00136 #ifdef WITH_CXX_GUARDEDALLOC 00137 public: 00138 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IPhysicsController"); } 00139 void operator delete( void *mem ) { MEM_freeN(mem); } 00140 #endif 00141 }; 00142 00143 #endif //__KX_IPHYSICSCONTROLLER_H 00144