Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_PHYSICS_JOINT_H__
00009 #define __SP_PHYSICS_JOINT_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_PHYSICS
00015
00016
00017 #include "Base/spDimensionVector3D.hpp"
00018 #include "Base/spDimensionMatrix4.hpp"
00019
00020
00021 namespace sp
00022 {
00023 namespace physics
00024 {
00025
00026
00027 class RigidBody;
00028 class PhysicsBaseObject;
00029
00031 enum EPhysicsJoints
00032 {
00033 JOINT_BALL,
00034 JOINT_HINGE,
00035 JOINT_SLIDER,
00036 JOINT_CORKSCREW,
00037 JOINT_UNIVERSAL,
00038 };
00039
00040 struct SPhysicsJointConstruct
00041 {
00042 SPhysicsJointConstruct()
00043 {
00044 }
00045 SPhysicsJointConstruct(
00046 const dim::vector3df &Pnt) :
00047 PointA(Pnt),
00048 PointB(Pnt)
00049 {
00050 }
00051 SPhysicsJointConstruct(
00052 const dim::vector3df &Pnt, const dim::vector3df &Dir) :
00053 PointA (Pnt),
00054 PointB (Pnt),
00055 DirectionA (Dir),
00056 DirectionB (Dir)
00057 {
00058 DirectionA.normalize();
00059 DirectionB.normalize();
00060 }
00061 SPhysicsJointConstruct(
00062 const dim::vector3df &PntA, const dim::vector3df &PntB,
00063 const dim::vector3df &DirA, const dim::vector3df &DirB) :
00064 PointA (PntA),
00065 PointB (PntB),
00066 DirectionA (DirA),
00067 DirectionB (DirB)
00068 {
00069 DirectionA.normalize();
00070 DirectionB.normalize();
00071 }
00072 SPhysicsJointConstruct(
00073 const dim::matrix4f TransA, const dim::matrix4f TransB) :
00074 TransformA(TransA), TransformB(TransB)
00075 {
00076 }
00077 ~SPhysicsJointConstruct()
00078 {
00079 }
00080
00081
00082 dim::vector3df PointA, PointB;
00083 dim::vector3df DirectionA, DirectionB;
00084 dim::matrix4f TransformA, TransformB;
00085 };
00086
00087
00093 class SP_EXPORT PhysicsJoint
00094 {
00095
00096 public:
00097
00098 virtual ~PhysicsJoint();
00099
00100
00101
00102 virtual void setPosition(const dim::vector3df &Position) = 0;
00103 virtual dim::vector3df getPosition() const = 0;
00104
00105 virtual void translate(const dim::vector3df &Direction);
00106
00107
00108 virtual void setLimit(bool Enable) = 0;
00109 virtual bool getLimit() const = 0;
00110
00112 virtual void setLimit(f32 Min, f32 Max, bool Enable = true) = 0;
00113 virtual void getLimit(f32 &Min, f32 &Max) const = 0;
00114
00123 virtual void setMotor(bool Enable, f32 MotorPower = 100.0f) = 0;
00124 virtual bool getMotor() const = 0;
00125
00126 virtual void runMotor(f32 Velocity) = 0;
00127
00129 virtual f32 getLinearValue() const = 0;
00130
00131
00132
00134 inline EPhysicsJoints getType() const
00135 {
00136 return Type_;
00137 }
00138
00140 inline PhysicsBaseObject* getFirstObject() const
00141 {
00142 return ObjectA_;
00143 }
00145 inline PhysicsBaseObject* getSecondObject() const
00146 {
00147 return ObjectB_;
00148 }
00149
00150 protected:
00151
00152 PhysicsJoint(
00153 const EPhysicsJoints Type, PhysicsBaseObject* ObjectA, PhysicsBaseObject* ObjectB
00154 );
00155
00156
00157
00158 EPhysicsJoints Type_;
00159
00160 PhysicsBaseObject* ObjectA_;
00161 PhysicsBaseObject* ObjectB_;
00162
00163 };
00164
00165
00166 }
00167
00168 }
00169
00170
00171 #endif
00172
00173 #endif
00174
00175
00176
00177