Bevel Factor Mapping
[blender.git] / source / gameengine / Physics / common / PHY_IPhysicsController.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file PHY_IPhysicsController.h
29  *  \ingroup phys
30  */
31
32 #ifndef __PHY_IPHYSICSCONTROLLER_H__
33 #define __PHY_IPHYSICSCONTROLLER_H__
34
35 #include "PHY_IController.h"
36
37 class PHY_IMotionState;
38 class PHY_IPhysicsEnvironment;
39
40 class MT_Vector3;
41 class MT_Point3;
42 class MT_Matrix3x3;
43
44 /**
45  * PHY_IPhysicsController is the abstract simplified Interface to a physical object.
46  * It contains the IMotionState and IDeformableMesh Interfaces.
47  */
48 class PHY_IPhysicsController : public PHY_IController
49 {
50
51         public:
52                 virtual ~PHY_IPhysicsController(){};
53                 /**
54                  * SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
55                  */
56                 virtual bool            SynchronizeMotionStates(float time)=0;
57                 /**
58                  * WriteMotionStateToDynamics ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
59                  */
60                 
61                 virtual void            WriteMotionStateToDynamics(bool nondynaonly)=0;
62                 virtual void            WriteDynamicsToMotionState()=0;
63                 virtual class PHY_IMotionState* GetMotionState() = 0;
64                 // controller replication
65                 virtual void            PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)=0;
66                 virtual void            SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0;
67
68                 // kinematic methods
69                 virtual void            RelativeTranslate(const MT_Vector3& dloc,bool local)=0;
70                 virtual void            RelativeRotate(const MT_Matrix3x3&,bool local)=0;
71                 virtual MT_Matrix3x3    GetOrientation()=0;
72                 virtual void            SetOrientation(const MT_Matrix3x3& orn)=0;
73                 virtual void            SetPosition(const MT_Vector3& pos)=0;
74                 virtual void            GetPosition(MT_Vector3& pos) const=0;
75                 virtual void            SetScaling(const MT_Vector3& scale)=0;
76                 virtual void            SetTransform()=0;
77
78                 virtual MT_Scalar       GetMass()=0;
79                 virtual void            SetMass(MT_Scalar newmass)=0;
80
81                 // physics methods
82                 virtual void            ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0;
83                 virtual void            ApplyTorque(const MT_Vector3& torque,bool local)=0;
84                 virtual void            ApplyForce(const MT_Vector3& force,bool local)=0;
85                 virtual void            SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
86                 virtual void            SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0;
87                 virtual void            ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
88
89                 virtual void            SuspendDynamics(bool ghost=false)=0;
90                 virtual void            RestoreDynamics()=0;
91
92                 virtual void            SetActive(bool active)=0;
93
94                 // reading out information from physics
95                 virtual MT_Vector3      GetLinearVelocity()=0;
96                 virtual MT_Vector3      GetAngularVelocity()=0;
97                 virtual MT_Vector3      GetVelocity(const MT_Point3& pos)=0;
98                 virtual MT_Vector3      GetLocalInertia()=0;
99
100                 // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
101                 virtual void            SetRigidBody(bool rigid)=0;
102
103                 virtual PHY_IPhysicsController* GetReplica() {return 0;}
104                 virtual PHY_IPhysicsController* GetReplicaForSensors() {return 0;}
105
106                 virtual void    CalcXform() =0;
107                 virtual void SetMargin(float margin) =0;
108                 virtual float GetMargin() const=0;
109                 virtual float GetRadius() const=0;
110                 virtual void  SetRadius(float margin) = 0;
111
112                 virtual float GetLinVelocityMin() const=0;
113                 virtual void  SetLinVelocityMin(float val) = 0;
114                 virtual float GetLinVelocityMax() const=0;
115                 virtual void  SetLinVelocityMax(float val) = 0;
116                 
117                 MT_Vector3      GetWorldPosition(MT_Vector3& localpos);
118
119                 // Shape control
120                 virtual void    AddCompoundChild(PHY_IPhysicsController* child) = 0;
121                 virtual void    RemoveCompoundChild(PHY_IPhysicsController* child) = 0;
122
123
124                 virtual bool IsDynamic() = 0;
125                 virtual bool IsCompound() = 0;
126
127
128 #ifdef WITH_CXX_GUARDEDALLOC
129         MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsController")
130 #endif
131 };
132
133 #endif  /* __PHY_IPHYSICSCONTROLLER_H__ */