4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
29 #ifndef __KX_IPHYSICSCONTROLLER_H
30 #define __KX_IPHYSICSCONTROLLER_H
32 #include "SG_Controller.h"
33 #include "MT_Vector3.h"
34 #include "MT_Point3.h"
35 #include "MT_Transform.h"
36 #include "MT_Matrix3x3.h"
38 struct KX_ClientObjectInfo;
41 Physics Controller, a special kind of Scene Graph Transformation Controller.
42 It get's callbacks from Physics in case a transformation change took place.
43 Each time the scene graph get's updated, the controller get's a chance
44 in the 'Update' method to reflect changed.
47 class KX_IPhysicsController : public SG_Controller
53 bool m_suspendDynamics;
56 KX_IPhysicsController(bool dyna,bool compound, void* userdata);
57 virtual ~KX_IPhysicsController();
60 virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0;
61 virtual void SetObject (SG_IObject* object)=0;
62 virtual void setMargin (float collisionMargin)=0;
64 virtual void RelativeTranslate(const MT_Vector3& dloc,bool local)=0;
65 virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local)=0;
66 virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0;
67 virtual void ApplyForce(const MT_Vector3& force,bool local)=0;
68 virtual MT_Vector3 GetLinearVelocity()=0;
69 virtual MT_Vector3 GetAngularVelocity()=0;
70 virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0;
71 virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
72 virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0;
73 virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
75 virtual void getOrientation(MT_Quaternion& orn)=0;
76 virtual void setOrientation(const MT_Matrix3x3& orn)=0;
77 //virtual void setOrientation(const MT_Quaternion& orn)=0;
78 virtual void setPosition(const MT_Point3& pos)=0;
79 virtual void setScaling(const MT_Vector3& scaling)=0;
80 virtual MT_Scalar GetMass()=0;
81 virtual void SetMass(MT_Scalar newmass)=0;
82 virtual MT_Vector3 GetLocalInertia()=0;
83 virtual MT_Vector3 getReactionForce()=0;
84 virtual void setRigidBody(bool rigid)=0;
85 virtual void AddCompoundChild(KX_IPhysicsController* child) = 0;
86 virtual void RemoveCompoundChild(KX_IPhysicsController* child) = 0;
88 virtual void SuspendDynamics(bool ghost=false)=0;
89 virtual void RestoreDynamics()=0;
91 virtual SG_Controller* GetReplica(class SG_Node* destnode)=0;
93 void SetDyna(bool isDynamic) {
101 bool IsCompound(void) {
105 virtual MT_Scalar GetRadius()=0;
106 virtual void SetSumoTransform(bool nondynaonly)=0;
107 // todo: remove next line !
108 virtual void SetSimulatedTime(double time)=0;
110 // call from scene graph to update
111 virtual bool Update(double time)=0;
112 void* GetUserData() { return m_userdata;}
115 #endif //__KX_IPHYSICSCONTROLLER_H