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 #ifndef BODY_HH
00028 #define BODY_HH
00029
00030 #include <ode/ode.h>
00031 #include "Vector.hh"
00032
00033 #include "GL/gl.h"
00034
00035
00036 class World;
00037 class Geom;
00038
00039
00042 class Body
00043 {
00045 public: Body( const World *world, const char *bodyName = NULL, bool dummy = false );
00046
00048 public: virtual ~Body();
00049
00050
00051 private: void AttachGeom( Geom *geom );
00052
00053
00054 private: void DetachGeom( Geom *geom );
00055
00056
00057 public: void UpdateCoM();
00058
00059
00060 public: int GetNumGeoms() {return this->geomCount;}
00061 public: Geom **GetGeoms() {return this->geoms;}
00062
00063
00064 public: void Enable(bool enable);
00065
00067 public: GzPose GetPose( void ) const;
00068
00070 public: GzVector GetPosition( void ) const;
00071
00073 public: GzQuatern GetRotation( void ) const;
00074
00076 public: void SetPose( GzPose pose );
00077
00079 public: void SetPosition( GzVector pos );
00080
00082 public: void SetRotation( GzQuatern rot );
00083
00084
00085 public: GzPose GetCoMPose( void ) const;
00086
00087
00088 public: GzVector GetLinearVel( void ) const;
00089
00090
00091 public: GzQuatern GetAngularVel( void ) const;
00092
00094 public: void SetLinearVel( GzVector vel );
00095
00097 public: void SetAngularVel( GzVector vel );
00098
00099
00100 public: dBodyID GetBodyId() const;
00101
00102
00103 public: dSpaceID GetSpaceId() const;
00104
00106 public: void SetGravityMode(bool enabled);
00107
00108 public: int GetGravityMode();
00109
00110
00111 public: void SetFiniteRotationAxis(double x,double y,double z);
00112 public: void SetFiniteRotationMode(int mode);
00113
00114
00115 public: void SetPickId( GLuint id );
00116
00117
00118 public: GzVector GetTorque(void);
00119
00121 public: GzVector GetForce(void);
00122
00124 public: void SetForce( GzVector f );
00125
00126 public: void SetTorque( double x, double y, double z);
00127
00128 public: void AddForce( double x, double y, double z);
00129 public: void AddTorque( double x, double y, double z);
00130 public: void AddRelForce( double x, double y, double z);
00131 public: void AddRelTorque( double x, double y, double z);
00132
00133 public: void AddForceAtPos( double x, double y, double z,
00134 double pos_x,double pos_y,double pos_z);
00135 public: void AddForceAtRelPos( double x, double y, double z,
00136 double pos_x,double pos_y,double pos_z);
00137
00138
00139 public: char *bodyName;
00140
00141
00142 protected: dWorldID worldId;
00143
00144
00145 protected: dBodyID bodyId;
00146
00147
00148 private: GzPose comPose;
00149
00150
00151 protected: GzPose dummyPose;
00152
00153
00154 private: int geomCount, geomMaxCount;
00155 private: Geom **geoms;
00156
00157
00158 protected: dMass mass;
00159
00160
00161 friend class Geom;
00162 friend class BaseGeom;
00163 friend class Camera;
00164 };
00165
00166
00167
00168 #endif
00169