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 MODEL_HH
00028 #define MODEL_HH
00029
00030 #include <ode/ode.h>
00031 #include "Vector.hh"
00032
00033 #include "GL/gl.h"
00034
00035
00036 class World;
00037 class WorldFile;
00038 class WorldFileNode;
00039 class Body;
00040 class Geom;
00041 class Joint;
00042 class HingeJoint;
00043
00044
00045 class Model
00046 {
00047
00048 public: Model( World *world );
00049
00050
00051 public: virtual ~Model();
00052
00053
00054 public: virtual int Load( WorldFile *file, WorldFileNode *node ) = 0;
00055
00056
00057 public: virtual int Init( WorldFile *file, WorldFileNode *node ) = 0;
00058
00059
00060 public: virtual int Fini() = 0;
00061
00062
00063 public: virtual void Update( double step ) = 0;
00064
00065
00066 public: GzPose GetPose();
00067
00068
00069 public: void SetPose( GzPose pose );
00070
00071
00072 public: void SetParent(Model *parent, Body *parentBody);
00073
00074
00075 public: void Attach();
00076
00077
00078 public: void Detach();
00079
00080
00081
00082 protected: void AddBody(Body *body, bool canonical = false);
00083
00084
00085
00086 public: Body *GetBody(const char *bodyName = NULL);
00087
00088
00089 public: int GetNumBodies() {return this->bodyCount;}
00090 public: Body **GetBodies() {return this->bodies;}
00091
00092
00093 public: void SetId(const char* id);
00094
00095
00096 public: const char* GetId() const {return this->id;}
00097
00098
00099 public: void SetName(const char *name);
00100
00101
00102 public: const char* GetName();
00103
00104
00105 public: void SetPickId( GLuint id );
00106
00107
00108 public: GLuint GetPickId() const {return this->pickId;}
00109
00110
00111 public: World *world;
00112
00113
00114 public: WorldFileNode *node;
00115
00116
00117 public: Model *parent;
00118
00119
00120 public: Body *parentBody;
00121
00123 public: GzPose initPose;
00124
00125
00126 private: char *id;
00127
00128
00129 private: char *name;
00130
00131
00132 public: HingeJoint *joint;
00133
00134
00135 public: GzPose relPose;
00136
00137
00138 public: bool fixed;
00139
00140
00141 public: dSpaceID modelSpaceId;
00142
00143
00144 private: int bodyCount, bodyMaxCount;
00145 private: Body **bodies;
00146
00147
00148 private: Body *canonicalBody;
00149
00150
00151 private: int jointCount, jointMaxCount;
00152 private: Joint **joints;
00153
00154 private: GLuint pickId;
00155 private: static GLuint pickIdMaster;
00156 };
00157
00158 #endif
00159