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
00028 #ifndef _ODE_ODECPP_H_
00029 #define _ODE_ODECPP_H_
00030 #ifdef __cplusplus
00031
00032 #include <ode/error.h>
00033
00034
00035 class dWorld {
00036 dWorldID _id;
00037
00038 dWorld (dWorld &) { dDebug (0,"bad"); }
00039 void operator= (dWorld &) { dDebug (0,"bad"); }
00040
00041 public:
00042 dWorld()
00043 { _id = dWorldCreate(); }
00044 ~dWorld()
00045 { dWorldDestroy (_id); }
00046 dWorldID id()
00047 { return _id; }
00048
00049 void setGravity (dReal x, dReal y, dReal z)
00050 { dWorldSetGravity (_id,x,y,z); }
00051 void getGravity (dVector3 g)
00052 { dWorldGetGravity (_id,g); }
00053 void step (dReal stepsize)
00054 { dWorldStep (_id,stepsize); }
00055 };
00056
00057
00058 class dBody {
00059 dBodyID _id;
00060
00061 dBody (dBody &) { dDebug (0,"bad"); }
00062 void operator= (dBody &) { dDebug (0,"bad"); }
00063
00064 public:
00065 dBody()
00066 { _id = 0; }
00067 dBody (dWorld &world)
00068 { _id = dBodyCreate (world.id()); }
00069 ~dBody()
00070 { dBodyDestroy (_id); }
00071 void create (dWorld &world)
00072 { if (_id) dBodyDestroy (_id); _id = dBodyCreate (world.id()); }
00073 dBodyID id()
00074 { return _id; }
00075
00076 void setData (void *data)
00077 { dBodySetData (_id,data); }
00078 void *getData()
00079 { return dBodyGetData (_id); }
00080
00081 void setPosition (dReal x, dReal y, dReal z)
00082 { dBodySetPosition (_id,x,y,z); }
00083 void setRotation (const dMatrix3 R)
00084 { dBodySetRotation (_id,R); }
00085 void setQuaternion (const dQuaternion q)
00086 { dBodySetQuaternion (_id,q); }
00087 void setLinearVel (dReal x, dReal y, dReal z)
00088 { dBodySetLinearVel (_id,x,y,z); }
00089 void setAngularVel (dReal x, dReal y, dReal z)
00090 { dBodySetAngularVel (_id,x,y,z); }
00091
00092 const dReal * getPosition()
00093 { return dBodyGetPosition (_id); }
00094 const dReal * getRotation()
00095 { return dBodyGetRotation (_id); }
00096 const dReal * getQuaternion()
00097 { return dBodyGetQuaternion (_id); }
00098 const dReal * getLinearVel()
00099 { return dBodyGetLinearVel (_id); }
00100 const dReal * getAngularVel()
00101 { return dBodyGetAngularVel (_id); }
00102
00103 void setMass (const dMass *mass)
00104 { dBodySetMass (_id,mass); }
00105 void getMass (dMass *mass)
00106 { dBodyGetMass (_id,mass); }
00107
00108 void addForce (dReal fx, dReal fy, dReal fz)
00109 { dBodyAddForce (_id, fx, fy, fz); }
00110 void addTorque (dReal fx, dReal fy, dReal fz)
00111 { dBodyAddTorque (_id, fx, fy, fz); }
00112 void addRelForce (dReal fx, dReal fy, dReal fz)
00113 { dBodyAddRelForce (_id, fx, fy, fz); }
00114 void addRelTorque (dReal fx, dReal fy, dReal fz)
00115 { dBodyAddRelTorque (_id, fx, fy, fz); }
00116 void addForceAtPos (dReal fx, dReal fy, dReal fz,
00117 dReal px, dReal py, dReal pz)
00118 { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); }
00119 void addRelForceAtPos (dReal fx, dReal fy, dReal fz,
00120 dReal px, dReal py, dReal pz)
00121 { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); }
00122 void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz,
00123 dReal px, dReal py, dReal pz)
00124 { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); }
00125
00126 void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result)
00127 { dBodyGetRelPointPos (_id, px, py, pz, result); }
00128 void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result)
00129 { dBodyGetRelPointVel (_id, px, py, pz, result); }
00130
00131 int isConnectedTo (const dBody &b)
00132 { return dAreConnected (_id,b._id); }
00133 };
00134
00135
00136 class dJointGroup {
00137 dJointGroupID _id;
00138
00139 dJointGroup (dJointGroup &) { dDebug (0,"bad"); }
00140 void operator= (dJointGroup &) { dDebug (0,"bad"); }
00141
00142 public:
00143 dJointGroup()
00144 { _id = 0; }
00145 dJointGroup (int max_size)
00146 { _id = dJointGroupCreate (max_size); }
00147 ~dJointGroup()
00148 { dJointGroupDestroy (_id); }
00149 void create (int max_size)
00150 { if (_id) dJointGroupDestroy (_id); _id = dJointGroupCreate (max_size); }
00151 dJointGroupID id()
00152 { return _id; }
00153
00154 void empty()
00155 { dJointGroupEmpty (_id); }
00156 };
00157
00158
00159 class dJoint {
00160 dJointID _id;
00161
00162 dJoint (dJoint &) { dDebug (0,"bad"); }
00163 void operator= (dJoint &) { dDebug (0,"bad"); }
00164
00165 public:
00166 dJoint()
00167 { _id = 0; }
00168 ~dJoint()
00169 { dJointDestroy (_id); }
00170 dJointID id()
00171 { return _id; }
00172
00173 void createBall (dWorld &world, dJointGroup *group=0) {
00174 if (_id) dJointDestroy (_id);
00175 _id = dJointCreateBall (world.id(), group ? group->id() : 0);
00176 }
00177 void createHinge (dWorld &world, dJointGroup *group=0) {
00178 if (_id) dJointDestroy (_id);
00179 _id = dJointCreateHinge (world.id(), group ? group->id() : 0);
00180 }
00181 void createSlider (dWorld &world, dJointGroup *group=0) {
00182 if (_id) dJointDestroy (_id);
00183 _id = dJointCreateSlider (world.id(), group ? group->id() : 0);
00184 }
00185 void createContact (dWorld &world, dJointGroup *group, dContact *contact) {
00186 if (_id) dJointDestroy (_id);
00187 _id = dJointCreateContact (world.id(), group ? group->id() : 0, contact);
00188 }
00189
00190 void attach (dBody &body1, dBody &body2)
00191 { dJointAttach (_id, body1.id(), body2.id()); }
00192
00193 void setBallAnchor (dReal x, dReal y, dReal z)
00194 { dJointSetBallAnchor (_id, x, y, z); }
00195 void setHingeAnchor (dReal x, dReal y, dReal z)
00196 { dJointSetHingeAnchor (_id, x, y, z); }
00197
00198 void setHingeAxis (dReal x, dReal y, dReal z)
00199 { dJointSetHingeAxis (_id, x, y, z); }
00200 void setSliderAxis (dReal x, dReal y, dReal z)
00201 { dJointSetSliderAxis (_id, x, y, z); }
00202
00203 void getBallAnchor (dVector3 result)
00204 { dJointGetBallAnchor (_id, result); }
00205 void getHingeAnchor (dVector3 result)
00206 { dJointGetHingeAnchor (_id, result); }
00207
00208 void getHingeAxis (dVector3 result)
00209 { dJointGetHingeAxis (_id, result); }
00210 void getSliderAxis (dVector3 result)
00211 { dJointGetSliderAxis (_id, result); }
00212 };
00213
00214
00215 class dSpace {
00216 dSpaceID _id;
00217
00218 dSpace (dSpace &) { dDebug (0,"bad"); }
00219 void operator= (dSpace &) { dDebug (0,"bad"); }
00220
00221 public:
00222 dSpace ()
00223 { _id = dHashSpaceCreate(); }
00224 ~dSpace()
00225 { dSpaceDestroy (_id); }
00226 dSpaceID id()
00227 { return _id; }
00228 void collide (void *data, dNearCallback *callback)
00229 { dSpaceCollide (_id,data,callback); }
00230 };
00231
00232
00233 class dGeom {
00234 dGeomID _id;
00235
00236 dGeom (dGeom &) { dDebug (0,"bad"); }
00237 void operator= (dGeom &) { dDebug (0,"bad"); }
00238
00239 public:
00240 dGeom()
00241 { _id = 0; }
00242 ~dGeom()
00243 { dGeomDestroy (_id); }
00244 dGeomID id()
00245 { return _id; }
00246
00247 void createSphere (dSpace &space, dReal radius) {
00248 if (_id) dGeomDestroy (_id);
00249 _id = dCreateSphere (space.id(),radius);
00250 }
00251
00252 void createBox (dSpace &space, dReal lx, dReal ly, dReal lz) {
00253 if (_id) dGeomDestroy (_id);
00254 _id = dCreateBox (space.id(),lx,ly,lz);
00255 }
00256
00257 void createPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d) {
00258 if (_id) dGeomDestroy (_id);
00259 _id = dCreatePlane (space.id(),a,b,c,d);
00260 }
00261
00262 void createCCylinder (dSpace &space, dReal radius, dReal length) {
00263 if (_id) dGeomDestroy (_id);
00264 _id = dCreateCCylinder (space.id(),radius,length);
00265 }
00266
00267 void destroy() {
00268 if (_id) dGeomDestroy (_id);
00269 _id = 0;
00270 }
00271
00272 int getClass()
00273 { return dGeomGetClass (_id); }
00274
00275 dReal sphereGetRadius()
00276 { return dGeomSphereGetRadius (_id); }
00277
00278 void boxGetLengths (dVector3 result)
00279 { dGeomBoxGetLengths (_id,result); }
00280
00281 void planeGetParams (dVector4 result)
00282 { dGeomPlaneGetParams (_id,result); }
00283
00284 void CCylinderGetParams (dReal *radius, dReal *length)
00285 { dGeomCCylinderGetParams (_id,radius,length); }
00286
00287 void setData (void *data)
00288 { dGeomSetData (_id,data); }
00289
00290 void *getData()
00291 { return dGeomGetData (_id); }
00292
00293 void setBody (dBody &b)
00294 { dGeomSetBody (_id,b.id()); }
00295 void setBody (dBodyID b)
00296 { dGeomSetBody (_id,b); }
00297
00298 dBodyID getBody()
00299 { return dGeomGetBody (_id); }
00300
00301 void setPosition (dReal x, dReal y, dReal z)
00302 { dGeomSetPosition (_id,x,y,z); }
00303
00304 void setRotation (const dMatrix3 R)
00305 { dGeomSetRotation (_id,R); }
00306
00307 const dReal * getPosition()
00308 { return dGeomGetPosition (_id); }
00309
00310 const dReal * getRotation()
00311 { return dGeomGetRotation (_id); }
00312 };
00313
00314
00315 #endif
00316 #endif