00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #ifndef __SO3BODY_H__
00036 #define __SO3BODY_H__
00037
00038 #include "..\SCOLBasic\SO3Std.h"
00039 #include "SO3Shape.h"
00040
00041 namespace SO3
00042 {
00043
00044 class SBody
00045 {
00046 public:
00047 protected:
00048 OgreNewt::Body* O3Body;
00049 SShape* mShape;
00050 SNode* mNode;
00051 SScene* mScene;
00052
00053 Ogre::Real mMass;
00054
00055 Ogre::Vector3 force;
00056 Ogre::Vector3 torque;
00057 Ogre::Vector3 constantForce;
00058 Ogre::Vector3 constantTorque;
00059 Ogre::Vector3 localForce;
00060 Ogre::Vector3 globalForce;
00061 Ogre::Vector3 globalLocationForce;
00062 Ogre::Vector3 localLocationForce;
00063
00064 private:
00065 OgreNewt::UpVector* mUpJoint;
00066
00067 public:
00070 SBody(SNode* node, SShape* shape);
00071
00074 ~SBody();
00075
00078 void BodyAddForceCallback(OgreNewt::Body * body ,float timeStep, int threadIndex);
00079
00082 bool BodyBuoyancyCallback( int colID, OgreNewt::Body* me, const Ogre::Quaternion& orient, const Ogre::Vector3& pos, Ogre::Plane& plane );
00083
00086 OgreNewt::Body* getOgreNewtBodyPointer();
00087
00090 Ogre::Real GetMass();
00091
00094 bool GetFreezeState();
00095
00098
00099
00102
00103
00106 Ogre::Vector3 GetCenterOfMass();
00107
00110 Ogre::Vector3 GetForce();
00111
00114 Ogre::Vector3 GetTorque();
00115
00118 Ogre::Vector3 GetLocalForce();
00119
00122 Ogre::Vector3 GetGlobalForce();
00123
00126 Ogre::Vector3 GetGlobalLocationForce();
00127
00130 Ogre::Vector3 GetLocalLocationForce();
00131
00134
00135
00138
00139
00142 void SetMass(Ogre::Real mMass);
00143
00146 void SetMassMatrix(Ogre::Real mass, Ogre::Vector3 inertial);
00147
00150 void SetMaterialID(OgreNewt::MaterialID* mMatID);
00151
00154 const OgreNewt::MaterialID* GetMaterialID();
00155
00158 void SetFreezeState(bool state);
00159
00162 void SetForce(Ogre::Vector3 mForce);
00163
00166 void SetTorque(Ogre::Vector3 mTorque);
00167
00170 void SetOmega(Ogre::Vector3 omega);
00171
00174 Ogre::Vector3 GetOmega();
00175
00178 void SetConstantForce(Ogre::Vector3 mForce);
00179
00182 void SetConstantTorque(Ogre::Vector3 mTorque);
00183
00186 void AddConstantForce(Ogre::Vector3 mForce);
00187
00190 void AddConstantTorque(Ogre::Vector3 mTorque);
00191
00194 Ogre::Vector3 GetConstantForce();
00195
00198 Ogre::Vector3 GetConstantTorque();
00199
00202 void SetLocalForce(Ogre::Vector3 mLocalForce);
00203
00206 void SetGlobalForce(Ogre::Vector3 mGlobalForce);
00207
00210 void SetGlobalLocationForce(Ogre::Vector3 mGlobalLocationForce);
00211
00214 void SetLocalLocationForce(Ogre::Vector3 mLocalLocationForce);
00215
00218 void SetBuoyancyForce(SBody* fluidBody);
00219
00222 void SetPositionOrientation(Ogre::Vector3 mDerivedPos, Ogre::Quaternion mDerivedOrientation);
00223
00226 void UpdatePositionOrientation();
00227
00230 void SetMatrix(Ogre::Vector3 mDerivedPos, Ogre::Quaternion mDerivedOrientation);
00231
00234 void SetVelocity(Ogre::Vector3 velocity);
00235
00238 Ogre::Vector3 GetVelocity();
00239
00242 void UpdateMatrix();
00243
00246 void AddImpulse(Ogre::Vector3 delta, Ogre::Vector3 pos);
00247
00250 void SetUpJoint(Ogre::Vector3 vec);
00251
00254 void RemoveUpJoint();
00255
00258 void SetAngularDamping(Ogre::Vector3 vec);
00259
00262 Ogre::Vector3 GetAngularDamping();
00263
00266 void SetCenterOfMass(Ogre::Vector3 vec);
00267
00270 void SetLinearDamping(Ogre::Real ang);
00271
00274 Ogre::Real GetLinearDamping();
00275
00278 void SetAutoSleep(bool enable);
00279
00282 bool GetAutoSleep();
00283
00286 void SetContinuousCollisionMode(bool enable);
00287
00290 bool GetContinuousCollisionMode();
00291
00294 void GetInvMass(Ogre::Real &mass, Ogre::Vector3 &inertia);
00295
00298 void GetMassMatrix(Ogre::Real &mass, Ogre::Vector3 &inertia);
00299
00302 bool GetSleepState();
00303
00306 void GetPositionOrientation(Ogre::Vector3 &pos, Ogre::Quaternion &orient);
00307
00310 void SetType(int value);
00311
00314 int GetType();
00315
00318 SNode* GetParentNode();
00319
00320 protected:
00321 private:
00322 SBody();
00323 };
00324
00325 }
00326
00327 #endif