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_SUMOPHYSICSCONTROLLER_H
30 #define __KX_SUMOPHYSICSCONTROLLER_H
32 #include "PHY_IPhysicsController.h"
35 Physics Controller, a special kind of Scene Graph Transformation Controller.
36 It get's callbacks from Sumo in case a transformation change took place.
37 Each time the scene graph get's updated, the controller get's a chance
38 in the 'Update' method to reflect changed.
41 #include "SumoPhysicsController.h"
42 #include "KX_IPhysicsController.h"
44 class KX_SumoPhysicsController : public KX_IPhysicsController,
45 public SumoPhysicsController
51 KX_SumoPhysicsController(
52 class SM_Scene* sumoScene,
53 class SM_Object* sumoObj,
54 class PHY_IMotionState* motionstate
56 : KX_IPhysicsController(dyna,false,NULL) ,
57 SumoPhysicsController(sumoScene,/*solidscene,*/sumoObj,motionstate,dyna)
60 virtual ~KX_SumoPhysicsController();
62 void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
63 virtual void SetObject (SG_IObject* object);
64 virtual void setMargin (float collisionMargin);
66 void RelativeTranslate(const MT_Vector3& dloc,bool local);
67 void RelativeRotate(const MT_Matrix3x3& drot,bool local);
68 void ApplyTorque(const MT_Vector3& torque,bool local);
69 void ApplyForce(const MT_Vector3& force,bool local);
70 MT_Vector3 GetLinearVelocity();
71 MT_Vector3 GetAngularVelocity() // to keep compiler happy
72 { return MT_Vector3(0.0,0.0,0.0); }
73 MT_Vector3 GetVelocity(const MT_Point3& pos);
74 void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
75 void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
76 void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
79 void SuspendDynamics(bool);
80 void RestoreDynamics();
81 virtual void AddCompoundChild(KX_IPhysicsController* child) { }
82 virtual void RemoveCompoundChild(KX_IPhysicsController* child) { }
84 virtual void getOrientation(MT_Quaternion& orn);
85 virtual void setOrientation(const MT_Matrix3x3& orn);
87 virtual void setPosition(const MT_Point3& pos);
88 virtual void setScaling(const MT_Vector3& scaling);
89 virtual MT_Scalar GetMass();
90 virtual void SetMass(MT_Scalar newmass);
91 virtual MT_Vector3 GetLocalInertia();
92 virtual MT_Scalar GetRadius();
93 virtual MT_Vector3 getReactionForce();
94 virtual void setRigidBody(bool rigid);
97 virtual SG_Controller* GetReplica(class SG_Node* destnode);
100 void SetSumoTransform(bool nondynaonly);
101 // todo: remove next line !
102 virtual void SetSimulatedTime(double time);
104 // call from scene graph to update
105 virtual bool Update(double time);
112 // intentionally empty
116 #endif //__KX_SUMOPHYSICSCONTROLLER_H