Blender V2.61 - r43446

KX_IPhysicsController.h

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