1 /************************************************************************* 2 * * 3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * 4 * All rights reserved. Email: russ@q12.org Web: www.q12.org * 5 * * 6 * This library is free software; you can redistribute it and/or * 7 * modify it under the terms of EITHER: * 8 * (1) The GNU Lesser General Public License as published by the Free * 9 * Software Foundation; either version 2.1 of the License, or (at * 10 * your option) any later version. The text of the GNU Lesser * 11 * General Public License is included with this library in the * 12 * file LICENSE.TXT. * 13 * (2) The BSD-style license that is included with this library in * 14 * the file LICENSE-BSD.TXT. * 15 * * 16 * This library is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * 19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. * 20 * * 21 *************************************************************************/ 22 23 /* C++ interface for non-collision stuff */ 24 25 26 #ifndef _ODE_ODECPP_H_ 27 #define _ODE_ODECPP_H_ 28 #ifdef __cplusplus 29 30 31 32 33 //namespace ode { 34 35 class dWorld { 36 dWorldID _id; 37 38 // intentionally undefined, don't use these 39 dWorld (const dWorld &); 40 void operator= (const dWorld &); 41 42 public: dWorld()43 dWorld() 44 { _id = dWorldCreate(); } ~dWorld()45 ~dWorld() 46 { dWorldDestroy (_id); } 47 id()48 dWorldID id() const 49 { return _id; } dWorldID()50 operator dWorldID() const 51 { return _id; } 52 setGravity(dReal x,dReal y,dReal z)53 void setGravity (dReal x, dReal y, dReal z) 54 { dWorldSetGravity (_id,x,y,z); } setGravity(const dVector3 g)55 void setGravity (const dVector3 g) 56 { setGravity (g[0], g[1], g[2]); } getGravity(dVector3 g)57 void getGravity (dVector3 g) const 58 { dWorldGetGravity (_id,g); } 59 setERP(dReal erp)60 void setERP (dReal erp) 61 { dWorldSetERP(_id, erp); } getERP()62 dReal getERP() const 63 { return dWorldGetERP(_id); } 64 setCFM(dReal cfm)65 void setCFM (dReal cfm) 66 { dWorldSetCFM(_id, cfm); } getCFM()67 dReal getCFM() const 68 { return dWorldGetCFM(_id); } 69 step(dReal stepsize)70 void step (dReal stepsize) 71 { dWorldStep (_id,stepsize); } 72 stepFast1(dReal stepsize,int maxiterations)73 void stepFast1 (dReal stepsize, int maxiterations) 74 { dWorldStepFast1 (_id,stepsize,maxiterations); } setAutoEnableDepthSF1(int depth)75 void setAutoEnableDepthSF1(int depth) 76 { dWorldSetAutoEnableDepthSF1 (_id, depth); } getAutoEnableDepthSF1()77 int getAutoEnableDepthSF1() const 78 { return dWorldGetAutoEnableDepthSF1 (_id); } 79 quickStep(dReal stepsize)80 void quickStep(dReal stepsize) 81 { dWorldQuickStep (_id, stepsize); } setQuickStepNumIterations(int num)82 void setQuickStepNumIterations(int num) 83 { dWorldSetQuickStepNumIterations (_id, num); } getQuickStepNumIterations()84 int getQuickStepNumIterations() const 85 { return dWorldGetQuickStepNumIterations (_id); } setQuickStepW(dReal over_relaxation)86 void setQuickStepW(dReal over_relaxation) 87 { dWorldSetQuickStepW (_id, over_relaxation); } getQuickStepW()88 dReal getQuickStepW() const 89 { return dWorldGetQuickStepW (_id); } 90 setAutoDisableLinearThreshold(dReal threshold)91 void setAutoDisableLinearThreshold (dReal threshold) 92 { dWorldSetAutoDisableLinearThreshold (_id,threshold); } getAutoDisableLinearThreshold()93 dReal getAutoDisableLinearThreshold() const 94 { return dWorldGetAutoDisableLinearThreshold (_id); } setAutoDisableAngularThreshold(dReal threshold)95 void setAutoDisableAngularThreshold (dReal threshold) 96 { dWorldSetAutoDisableAngularThreshold (_id,threshold); } getAutoDisableAngularThreshold()97 dReal getAutoDisableAngularThreshold() const 98 { return dWorldGetAutoDisableAngularThreshold (_id); } setAutoDisableSteps(int steps)99 void setAutoDisableSteps (int steps) 100 { dWorldSetAutoDisableSteps (_id,steps); } getAutoDisableSteps()101 int getAutoDisableSteps() const 102 { return dWorldGetAutoDisableSteps (_id); } setAutoDisableTime(dReal time)103 void setAutoDisableTime (dReal time) 104 { dWorldSetAutoDisableTime (_id,time); } getAutoDisableTime()105 dReal getAutoDisableTime() const 106 { return dWorldGetAutoDisableTime (_id); } setAutoDisableFlag(int do_auto_disable)107 void setAutoDisableFlag (int do_auto_disable) 108 { dWorldSetAutoDisableFlag (_id,do_auto_disable); } getAutoDisableFlag()109 int getAutoDisableFlag() const 110 { return dWorldGetAutoDisableFlag (_id); } 111 getLinearDampingThreshold()112 dReal getLinearDampingThreshold() const 113 { return dWorldGetLinearDampingThreshold(_id); } setLinearDampingThreshold(dReal threshold)114 void setLinearDampingThreshold(dReal threshold) 115 { dWorldSetLinearDampingThreshold(_id, threshold); } getAngularDampingThreshold()116 dReal getAngularDampingThreshold() const 117 { return dWorldGetAngularDampingThreshold(_id); } setAngularDampingThreshold(dReal threshold)118 void setAngularDampingThreshold(dReal threshold) 119 { dWorldSetAngularDampingThreshold(_id, threshold); } getLinearDamping()120 dReal getLinearDamping() const 121 { return dWorldGetLinearDamping(_id); } setLinearDamping(dReal scale)122 void setLinearDamping(dReal scale) 123 { dWorldSetLinearDamping(_id, scale); } getAngularDamping()124 dReal getAngularDamping() const 125 { return dWorldGetAngularDamping(_id); } setAngularDamping(dReal scale)126 void setAngularDamping(dReal scale) 127 { dWorldSetAngularDamping(_id, scale); } setDamping(dReal linear_scale,dReal angular_scale)128 void setDamping(dReal linear_scale, dReal angular_scale) 129 { dWorldSetDamping(_id, linear_scale, angular_scale); } 130 getMaxAngularSpeed()131 dReal getMaxAngularSpeed() const 132 { return dWorldGetMaxAngularSpeed(_id); } setMaxAngularSpeed(dReal max_speed)133 void setMaxAngularSpeed(dReal max_speed) 134 { dWorldSetMaxAngularSpeed(_id, max_speed); } 135 setContactSurfaceLayer(dReal depth)136 void setContactSurfaceLayer(dReal depth) 137 { dWorldSetContactSurfaceLayer (_id, depth); } getContactSurfaceLayer()138 dReal getContactSurfaceLayer() const 139 { return dWorldGetContactSurfaceLayer (_id); } 140 impulseToForce(dReal stepsize,dReal ix,dReal iy,dReal iz,dVector3 force)141 void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz, 142 dVector3 force) 143 { dWorldImpulseToForce (_id,stepsize,ix,iy,iz,force); } 144 }; 145 146 147 class dBody { 148 dBodyID _id; 149 // intentionally undefined, don't use these 150 dBody (const dBody &); 151 void operator= (const dBody &); 152 153 public: dBody()154 dBody() 155 { _id = 0; } dBody(dWorldID world)156 dBody (dWorldID world) 157 { _id = dBodyCreate (world); } dBody(dWorld & world)158 dBody (dWorld& world) 159 { _id = dBodyCreate (world.id()); } ~dBody()160 ~dBody() 161 { if (_id) dBodyDestroy (_id); } 162 create(dWorldID world)163 void create (dWorldID world) { 164 if (_id) dBodyDestroy (_id); 165 _id = dBodyCreate (world); 166 } create(dWorld & world)167 void create (dWorld& world) { 168 create(world.id()); 169 } 170 id()171 dBodyID id() const 172 { return _id; } dBodyID()173 operator dBodyID() const 174 { return _id; } 175 setData(void * data)176 void setData (void *data) 177 { dBodySetData (_id,data); } getData()178 void *getData() const 179 { return dBodyGetData (_id); } 180 setPosition(dReal x,dReal y,dReal z)181 void setPosition (dReal x, dReal y, dReal z) 182 { dBodySetPosition (_id,x,y,z); } setPosition(const dVector3 p)183 void setPosition (const dVector3 p) 184 { setPosition(p[0], p[1], p[2]); } 185 setRotation(const dMatrix3 R)186 void setRotation (const dMatrix3 R) 187 { dBodySetRotation (_id,R); } setQuaternion(const dQuaternion q)188 void setQuaternion (const dQuaternion q) 189 { dBodySetQuaternion (_id,q); } setLinearVel(dReal x,dReal y,dReal z)190 void setLinearVel (dReal x, dReal y, dReal z) 191 { dBodySetLinearVel (_id,x,y,z); } setLinearVel(const dVector3 v)192 void setLinearVel (const dVector3 v) 193 { setLinearVel(v[0], v[1], v[2]); } setAngularVel(dReal x,dReal y,dReal z)194 void setAngularVel (dReal x, dReal y, dReal z) 195 { dBodySetAngularVel (_id,x,y,z); } setAngularVel(const dVector3 v)196 void setAngularVel (const dVector3 v) 197 { setAngularVel (v[0], v[1], v[2]); } 198 getPosition()199 const dReal * getPosition() const 200 { return dBodyGetPosition (_id); } getRotation()201 const dReal * getRotation() const 202 { return dBodyGetRotation (_id); } getQuaternion()203 const dReal * getQuaternion() const 204 { return dBodyGetQuaternion (_id); } getLinearVel()205 const dReal * getLinearVel() const 206 { return dBodyGetLinearVel (_id); } getAngularVel()207 const dReal * getAngularVel() const 208 { return dBodyGetAngularVel (_id); } 209 setMass(const dMass * mass)210 void setMass (const dMass *mass) 211 { dBodySetMass (_id,mass); } setMass(const dMass & mass)212 void setMass (const dMass &mass) 213 { setMass (&mass); } getMass()214 dMass getMass () const 215 { dMass mass; dBodyGetMass (_id,&mass); return mass; } 216 addForce(dReal fx,dReal fy,dReal fz)217 void addForce (dReal fx, dReal fy, dReal fz) 218 { dBodyAddForce (_id, fx, fy, fz); } addForce(const dVector3 f)219 void addForce (const dVector3 f) 220 { addForce (f[0], f[1], f[2]); } addTorque(dReal fx,dReal fy,dReal fz)221 void addTorque (dReal fx, dReal fy, dReal fz) 222 { dBodyAddTorque (_id, fx, fy, fz); } addTorque(const dVector3 t)223 void addTorque (const dVector3 t) 224 { addTorque(t[0], t[1], t[2]); } 225 addRelForce(dReal fx,dReal fy,dReal fz)226 void addRelForce (dReal fx, dReal fy, dReal fz) 227 { dBodyAddRelForce (_id, fx, fy, fz); } addRelForce(const dVector3 f)228 void addRelForce (const dVector3 f) 229 { addRelForce (f[0], f[1], f[2]); } addRelTorque(dReal fx,dReal fy,dReal fz)230 void addRelTorque (dReal fx, dReal fy, dReal fz) 231 { dBodyAddRelTorque (_id, fx, fy, fz); } addRelTorque(const dVector3 t)232 void addRelTorque (const dVector3 t) 233 { addRelTorque (t[0], t[1], t[2]); } 234 addForceAtPos(dReal fx,dReal fy,dReal fz,dReal px,dReal py,dReal pz)235 void addForceAtPos (dReal fx, dReal fy, dReal fz, 236 dReal px, dReal py, dReal pz) 237 { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); } addForceAtPos(const dVector3 f,const dVector3 p)238 void addForceAtPos (const dVector3 f, const dVector3 p) 239 { addForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } 240 addForceAtRelPos(dReal fx,dReal fy,dReal fz,dReal px,dReal py,dReal pz)241 void addForceAtRelPos (dReal fx, dReal fy, dReal fz, 242 dReal px, dReal py, dReal pz) 243 { dBodyAddForceAtRelPos (_id, fx, fy, fz, px, py, pz); } addForceAtRelPos(const dVector3 f,const dVector3 p)244 void addForceAtRelPos (const dVector3 f, const dVector3 p) 245 { addForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } 246 addRelForceAtPos(dReal fx,dReal fy,dReal fz,dReal px,dReal py,dReal pz)247 void addRelForceAtPos (dReal fx, dReal fy, dReal fz, 248 dReal px, dReal py, dReal pz) 249 { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); } addRelForceAtPos(const dVector3 f,const dVector3 p)250 void addRelForceAtPos (const dVector3 f, const dVector3 p) 251 { addRelForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } 252 addRelForceAtRelPos(dReal fx,dReal fy,dReal fz,dReal px,dReal py,dReal pz)253 void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, 254 dReal px, dReal py, dReal pz) 255 { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); } addRelForceAtRelPos(const dVector3 f,const dVector3 p)256 void addRelForceAtRelPos (const dVector3 f, const dVector3 p) 257 { addRelForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } 258 getForce()259 const dReal * getForce() const 260 { return dBodyGetForce(_id); } getTorque()261 const dReal * getTorque() const 262 { return dBodyGetTorque(_id); } setForce(dReal x,dReal y,dReal z)263 void setForce (dReal x, dReal y, dReal z) 264 { dBodySetForce (_id,x,y,z); } setForce(const dVector3 f)265 void setForce (const dVector3 f) 266 { setForce (f[0], f[1], f[2]); } setTorque(dReal x,dReal y,dReal z)267 void setTorque (dReal x, dReal y, dReal z) 268 { dBodySetTorque (_id,x,y,z); } setTorque(const dVector3 t)269 void setTorque (const dVector3 t) 270 { setTorque (t[0], t[1], t[2]); } 271 setDynamic()272 void setDynamic() 273 { dBodySetDynamic (_id); } setKinematic()274 void setKinematic() 275 { dBodySetKinematic (_id); } isKinematic()276 bool isKinematic() const 277 { return dBodyIsKinematic (_id) != 0; } 278 enable()279 void enable() 280 { dBodyEnable (_id); } disable()281 void disable() 282 { dBodyDisable (_id); } isEnabled()283 bool isEnabled() const 284 { return dBodyIsEnabled (_id) != 0; } 285 getRelPointPos(dReal px,dReal py,dReal pz,dVector3 result)286 void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const 287 { dBodyGetRelPointPos (_id, px, py, pz, result); } getRelPointPos(const dVector3 p,dVector3 result)288 void getRelPointPos (const dVector3 p, dVector3 result) const 289 { getRelPointPos (p[0], p[1], p[2], result); } 290 getRelPointVel(dReal px,dReal py,dReal pz,dVector3 result)291 void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const 292 { dBodyGetRelPointVel (_id, px, py, pz, result); } getRelPointVel(const dVector3 p,dVector3 result)293 void getRelPointVel (const dVector3 p, dVector3 result) const 294 { getRelPointVel (p[0], p[1], p[2], result); } 295 getPointVel(dReal px,dReal py,dReal pz,dVector3 result)296 void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const 297 { dBodyGetPointVel (_id, px, py, pz, result); } getPointVel(const dVector3 p,dVector3 result)298 void getPointVel (const dVector3 p, dVector3 result) const 299 { getPointVel (p[0], p[1], p[2], result); } 300 getPosRelPoint(dReal px,dReal py,dReal pz,dVector3 result)301 void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const 302 { dBodyGetPosRelPoint (_id, px, py, pz, result); } getPosRelPoint(const dVector3 p,dVector3 result)303 void getPosRelPoint (const dVector3 p, dVector3 result) const 304 { getPosRelPoint (p[0], p[1], p[2], result); } 305 vectorToWorld(dReal px,dReal py,dReal pz,dVector3 result)306 void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const 307 { dBodyVectorToWorld (_id, px, py, pz, result); } vectorToWorld(const dVector3 p,dVector3 result)308 void vectorToWorld (const dVector3 p, dVector3 result) const 309 { vectorToWorld (p[0], p[1], p[2], result); } 310 vectorFromWorld(dReal px,dReal py,dReal pz,dVector3 result)311 void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const 312 { dBodyVectorFromWorld (_id,px,py,pz,result); } vectorFromWorld(const dVector3 p,dVector3 result)313 void vectorFromWorld (const dVector3 p, dVector3 result) const 314 { vectorFromWorld (p[0], p[1], p[2], result); } 315 setFiniteRotationMode(bool mode)316 void setFiniteRotationMode (bool mode) 317 { dBodySetFiniteRotationMode (_id, mode); } 318 setFiniteRotationAxis(dReal x,dReal y,dReal z)319 void setFiniteRotationAxis (dReal x, dReal y, dReal z) 320 { dBodySetFiniteRotationAxis (_id, x, y, z); } setFiniteRotationAxis(const dVector3 a)321 void setFiniteRotationAxis (const dVector3 a) 322 { setFiniteRotationAxis (a[0], a[1], a[2]); } 323 getFiniteRotationMode()324 bool getFiniteRotationMode() const 325 { return dBodyGetFiniteRotationMode (_id) != 0; } getFiniteRotationAxis(dVector3 result)326 void getFiniteRotationAxis (dVector3 result) const 327 { dBodyGetFiniteRotationAxis (_id, result); } 328 getNumJoints()329 int getNumJoints() const 330 { return dBodyGetNumJoints (_id); } getJoint(int index)331 dJointID getJoint (int index) const 332 { return dBodyGetJoint (_id, index); } 333 setGravityMode(bool mode)334 void setGravityMode (bool mode) 335 { dBodySetGravityMode (_id,mode); } getGravityMode()336 bool getGravityMode() const 337 { return dBodyGetGravityMode (_id) != 0; } 338 isConnectedTo(dBodyID body)339 bool isConnectedTo (dBodyID body) const 340 { return dAreConnected (_id, body) != 0; } 341 setAutoDisableLinearThreshold(dReal threshold)342 void setAutoDisableLinearThreshold (dReal threshold) 343 { dBodySetAutoDisableLinearThreshold (_id,threshold); } getAutoDisableLinearThreshold()344 dReal getAutoDisableLinearThreshold() const 345 { return dBodyGetAutoDisableLinearThreshold (_id); } setAutoDisableAngularThreshold(dReal threshold)346 void setAutoDisableAngularThreshold (dReal threshold) 347 { dBodySetAutoDisableAngularThreshold (_id,threshold); } getAutoDisableAngularThreshold()348 dReal getAutoDisableAngularThreshold() const 349 { return dBodyGetAutoDisableAngularThreshold (_id); } setAutoDisableSteps(int steps)350 void setAutoDisableSteps (int steps) 351 { dBodySetAutoDisableSteps (_id,steps); } getAutoDisableSteps()352 int getAutoDisableSteps() const 353 { return dBodyGetAutoDisableSteps (_id); } setAutoDisableTime(dReal time)354 void setAutoDisableTime (dReal time) 355 { dBodySetAutoDisableTime (_id,time); } getAutoDisableTime()356 dReal getAutoDisableTime() const 357 { return dBodyGetAutoDisableTime (_id); } setAutoDisableFlag(bool do_auto_disable)358 void setAutoDisableFlag (bool do_auto_disable) 359 { dBodySetAutoDisableFlag (_id,do_auto_disable); } getAutoDisableFlag()360 bool getAutoDisableFlag() const 361 { return dBodyGetAutoDisableFlag (_id) != 0; } 362 getLinearDamping()363 dReal getLinearDamping() const 364 { return dBodyGetLinearDamping(_id); } setLinearDamping(dReal scale)365 void setLinearDamping(dReal scale) 366 { dBodySetLinearDamping(_id, scale); } getAngularDamping()367 dReal getAngularDamping() const 368 { return dBodyGetAngularDamping(_id); } setAngularDamping(dReal scale)369 void setAngularDamping(dReal scale) 370 { dBodySetAngularDamping(_id, scale); } setDamping(dReal linear_scale,dReal angular_scale)371 void setDamping(dReal linear_scale, dReal angular_scale) 372 { dBodySetDamping(_id, linear_scale, angular_scale); } getLinearDampingThreshold()373 dReal getLinearDampingThreshold() const 374 { return dBodyGetLinearDampingThreshold(_id); } setLinearDampingThreshold(dReal threshold)375 void setLinearDampingThreshold(dReal threshold) const 376 { dBodySetLinearDampingThreshold(_id, threshold); } getAngularDampingThreshold()377 dReal getAngularDampingThreshold() const 378 { return dBodyGetAngularDampingThreshold(_id); } setAngularDampingThreshold(dReal threshold)379 void setAngularDampingThreshold(dReal threshold) 380 { dBodySetAngularDampingThreshold(_id, threshold); } setDampingDefaults()381 void setDampingDefaults() 382 { dBodySetDampingDefaults(_id); } 383 getMaxAngularSpeed()384 dReal getMaxAngularSpeed() const 385 { return dBodyGetMaxAngularSpeed(_id); } setMaxAngularSpeed(dReal max_speed)386 void setMaxAngularSpeed(dReal max_speed) 387 { dBodySetMaxAngularSpeed(_id, max_speed); } 388 getGyroscopicMode()389 bool getGyroscopicMode() const 390 { return dBodyGetGyroscopicMode(_id) != 0; } setGyroscopicMode(bool mode)391 void setGyroscopicMode(bool mode) 392 { dBodySetGyroscopicMode(_id, mode); } 393 394 }; 395 396 397 class dJointGroup { 398 dJointGroupID _id; 399 400 // intentionally undefined, don't use these 401 dJointGroup (const dJointGroup &); 402 void operator= (const dJointGroup &); 403 404 public: dJointGroup()405 dJointGroup () 406 { _id = dJointGroupCreate (0); } ~dJointGroup()407 ~dJointGroup() 408 { dJointGroupDestroy (_id); } create()409 void create () { 410 if (_id) dJointGroupDestroy (_id); 411 _id = dJointGroupCreate (0); 412 } 413 id()414 dJointGroupID id() const 415 { return _id; } dJointGroupID()416 operator dJointGroupID() const 417 { return _id; } 418 empty()419 void empty() 420 { dJointGroupEmpty (_id); } clear()421 void clear() 422 { empty(); } 423 }; 424 425 426 class dJoint { 427 private: 428 // intentionally undefined, don't use these 429 dJoint (const dJoint &) ; 430 void operator= (const dJoint &); 431 432 protected: 433 dJointID _id; 434 dJoint()435 dJoint() // don't let user construct pure dJoint objects 436 { _id = 0; } 437 438 public: ~dJoint()439 virtual ~dJoint() // :( Destructor must be virtual to suppress compiler warning "class XXX has virtual functions but non-virtual destructor" 440 { if (_id) dJointDestroy (_id); } 441 id()442 dJointID id() const 443 { return _id; } dJointID()444 operator dJointID() const 445 { return _id; } 446 getNumBodies()447 int getNumBodies() const 448 { return dJointGetNumBodies(_id); } 449 attach(dBodyID body1,dBodyID body2)450 void attach (dBodyID body1, dBodyID body2) 451 { dJointAttach (_id, body1, body2); } attach(dBody & body1,dBody & body2)452 void attach (dBody& body1, dBody& body2) 453 { attach(body1.id(), body2.id()); } 454 enable()455 void enable() 456 { dJointEnable (_id); } disable()457 void disable() 458 { dJointDisable (_id); } isEnabled()459 bool isEnabled() const 460 { return dJointIsEnabled (_id) != 0; } 461 setData(void * data)462 void setData (void *data) 463 { dJointSetData (_id, data); } getData()464 void *getData() const 465 { return dJointGetData (_id); } 466 getType()467 dJointType getType() const 468 { return dJointGetType (_id); } 469 getBody(int index)470 dBodyID getBody (int index) const 471 { return dJointGetBody (_id, index); } 472 setFeedback(dJointFeedback * fb)473 void setFeedback(dJointFeedback *fb) 474 { dJointSetFeedback(_id, fb); } getFeedback()475 dJointFeedback *getFeedback() const 476 { return dJointGetFeedback(_id); } 477 478 // If not implemented it will do nothing as describe in the doc setParam(int,dReal)479 virtual void setParam (int, dReal) {}; getParam(int)480 virtual dReal getParam (int) const { return 0; } 481 }; 482 483 484 class dBallJoint : public dJoint { 485 private: 486 // intentionally undefined, don't use these 487 dBallJoint (const dBallJoint &); 488 void operator= (const dBallJoint &); 489 490 public: dBallJoint()491 dBallJoint() { } 492 dBallJoint (dWorldID world, dJointGroupID group=0) 493 { _id = dJointCreateBall (world, group); } 494 dBallJoint (dWorld& world, dJointGroupID group=0) 495 { _id = dJointCreateBall (world.id(), group); } 496 497 void create (dWorldID world, dJointGroupID group=0) { 498 if (_id) dJointDestroy (_id); 499 _id = dJointCreateBall (world, group); 500 } 501 void create (dWorld& world, dJointGroupID group=0) 502 { create(world.id(), group); } 503 setAnchor(dReal x,dReal y,dReal z)504 void setAnchor (dReal x, dReal y, dReal z) 505 { dJointSetBallAnchor (_id, x, y, z); } setAnchor(const dVector3 a)506 void setAnchor (const dVector3 a) 507 { setAnchor (a[0], a[1], a[2]); } getAnchor(dVector3 result)508 void getAnchor (dVector3 result) const 509 { dJointGetBallAnchor (_id, result); } getAnchor2(dVector3 result)510 void getAnchor2 (dVector3 result) const 511 { dJointGetBallAnchor2 (_id, result); } setParam(int parameter,dReal value)512 virtual void setParam (int parameter, dReal value) 513 { dJointSetBallParam (_id, parameter, value); } getParam(int parameter)514 virtual dReal getParam (int parameter) const 515 { return dJointGetBallParam (_id, parameter); } 516 // TODO: expose params through methods 517 } ; 518 519 520 class dHingeJoint : public dJoint { 521 // intentionally undefined, don't use these 522 dHingeJoint (const dHingeJoint &); 523 void operator = (const dHingeJoint &); 524 525 public: dHingeJoint()526 dHingeJoint() { } 527 dHingeJoint (dWorldID world, dJointGroupID group=0) 528 { _id = dJointCreateHinge (world, group); } 529 dHingeJoint (dWorld& world, dJointGroupID group=0) 530 { _id = dJointCreateHinge (world.id(), group); } 531 532 void create (dWorldID world, dJointGroupID group=0) { 533 if (_id) dJointDestroy (_id); 534 _id = dJointCreateHinge (world, group); 535 } 536 void create (dWorld& world, dJointGroupID group=0) 537 { create(world.id(), group); } 538 setAnchor(dReal x,dReal y,dReal z)539 void setAnchor (dReal x, dReal y, dReal z) 540 { dJointSetHingeAnchor (_id, x, y, z); } setAnchor(const dVector3 a)541 void setAnchor (const dVector3 a) 542 { setAnchor (a[0], a[1], a[2]); } getAnchor(dVector3 result)543 void getAnchor (dVector3 result) const 544 { dJointGetHingeAnchor (_id, result); } getAnchor2(dVector3 result)545 void getAnchor2 (dVector3 result) const 546 { dJointGetHingeAnchor2 (_id, result); } 547 setAxis(dReal x,dReal y,dReal z)548 void setAxis (dReal x, dReal y, dReal z) 549 { dJointSetHingeAxis (_id, x, y, z); } setAxis(const dVector3 a)550 void setAxis (const dVector3 a) 551 { setAxis(a[0], a[1], a[2]); } getAxis(dVector3 result)552 void getAxis (dVector3 result) const 553 { dJointGetHingeAxis (_id, result); } 554 getAngle()555 dReal getAngle() const 556 { return dJointGetHingeAngle (_id); } getAngleRate()557 dReal getAngleRate() const 558 { return dJointGetHingeAngleRate (_id); } 559 setParam(int parameter,dReal value)560 virtual void setParam (int parameter, dReal value) 561 { dJointSetHingeParam (_id, parameter, value); } getParam(int parameter)562 virtual dReal getParam (int parameter) const 563 { return dJointGetHingeParam (_id, parameter); } 564 // TODO: expose params through methods 565 addTorque(dReal torque)566 void addTorque (dReal torque) 567 { dJointAddHingeTorque(_id, torque); } 568 }; 569 570 571 class dSliderJoint : public dJoint { 572 // intentionally undefined, don't use these 573 dSliderJoint (const dSliderJoint &); 574 void operator = (const dSliderJoint &); 575 576 public: dSliderJoint()577 dSliderJoint() { } 578 dSliderJoint (dWorldID world, dJointGroupID group=0) 579 { _id = dJointCreateSlider (world, group); } 580 dSliderJoint (dWorld& world, dJointGroupID group=0) 581 { _id = dJointCreateSlider (world.id(), group); } 582 583 void create (dWorldID world, dJointGroupID group=0) { 584 if (_id) dJointDestroy (_id); 585 _id = dJointCreateSlider (world, group); 586 } 587 void create (dWorld& world, dJointGroupID group=0) 588 { create(world.id(), group); } 589 setAxis(dReal x,dReal y,dReal z)590 void setAxis (dReal x, dReal y, dReal z) 591 { dJointSetSliderAxis (_id, x, y, z); } setAxis(const dVector3 a)592 void setAxis (const dVector3 a) 593 { setAxis (a[0], a[1], a[2]); } getAxis(dVector3 result)594 void getAxis (dVector3 result) const 595 { dJointGetSliderAxis (_id, result); } 596 getPosition()597 dReal getPosition() const 598 { return dJointGetSliderPosition (_id); } getPositionRate()599 dReal getPositionRate() const 600 { return dJointGetSliderPositionRate (_id); } 601 setParam(int parameter,dReal value)602 virtual void setParam (int parameter, dReal value) 603 { dJointSetSliderParam (_id, parameter, value); } getParam(int parameter)604 virtual dReal getParam (int parameter) const 605 { return dJointGetSliderParam (_id, parameter); } 606 // TODO: expose params through methods 607 addForce(dReal force)608 void addForce (dReal force) 609 { dJointAddSliderForce(_id, force); } 610 }; 611 612 613 class dUniversalJoint : public dJoint { 614 // intentionally undefined, don't use these 615 dUniversalJoint (const dUniversalJoint &); 616 void operator = (const dUniversalJoint &); 617 618 public: dUniversalJoint()619 dUniversalJoint() { } 620 dUniversalJoint (dWorldID world, dJointGroupID group=0) 621 { _id = dJointCreateUniversal (world, group); } 622 dUniversalJoint (dWorld& world, dJointGroupID group=0) 623 { _id = dJointCreateUniversal (world.id(), group); } 624 625 void create (dWorldID world, dJointGroupID group=0) { 626 if (_id) dJointDestroy (_id); 627 _id = dJointCreateUniversal (world, group); 628 } 629 void create (dWorld& world, dJointGroupID group=0) 630 { create(world.id(), group); } 631 setAnchor(dReal x,dReal y,dReal z)632 void setAnchor (dReal x, dReal y, dReal z) 633 { dJointSetUniversalAnchor (_id, x, y, z); } setAnchor(const dVector3 a)634 void setAnchor (const dVector3 a) 635 { setAnchor(a[0], a[1], a[2]); } setAxis1(dReal x,dReal y,dReal z)636 void setAxis1 (dReal x, dReal y, dReal z) 637 { dJointSetUniversalAxis1 (_id, x, y, z); } setAxis1(const dVector3 a)638 void setAxis1 (const dVector3 a) 639 { setAxis1 (a[0], a[1], a[2]); } setAxis2(dReal x,dReal y,dReal z)640 void setAxis2 (dReal x, dReal y, dReal z) 641 { dJointSetUniversalAxis2 (_id, x, y, z); } setAxis2(const dVector3 a)642 void setAxis2 (const dVector3 a) 643 { setAxis2 (a[0], a[1], a[2]); } 644 getAnchor(dVector3 result)645 void getAnchor (dVector3 result) const 646 { dJointGetUniversalAnchor (_id, result); } getAnchor2(dVector3 result)647 void getAnchor2 (dVector3 result) const 648 { dJointGetUniversalAnchor2 (_id, result); } getAxis1(dVector3 result)649 void getAxis1 (dVector3 result) const 650 { dJointGetUniversalAxis1 (_id, result); } getAxis2(dVector3 result)651 void getAxis2 (dVector3 result) const 652 { dJointGetUniversalAxis2 (_id, result); } 653 setParam(int parameter,dReal value)654 virtual void setParam (int parameter, dReal value) 655 { dJointSetUniversalParam (_id, parameter, value); } getParam(int parameter)656 virtual dReal getParam (int parameter) const 657 { return dJointGetUniversalParam (_id, parameter); } 658 // TODO: expose params through methods 659 getAngles(dReal * angle1,dReal * angle2)660 void getAngles(dReal *angle1, dReal *angle2) const 661 { dJointGetUniversalAngles (_id, angle1, angle2); } 662 getAngle1()663 dReal getAngle1() const 664 { return dJointGetUniversalAngle1 (_id); } getAngle1Rate()665 dReal getAngle1Rate() const 666 { return dJointGetUniversalAngle1Rate (_id); } getAngle2()667 dReal getAngle2() const 668 { return dJointGetUniversalAngle2 (_id); } getAngle2Rate()669 dReal getAngle2Rate() const 670 { return dJointGetUniversalAngle2Rate (_id); } 671 addTorques(dReal torque1,dReal torque2)672 void addTorques (dReal torque1, dReal torque2) 673 { dJointAddUniversalTorques(_id, torque1, torque2); } 674 }; 675 676 677 class dHinge2Joint : public dJoint { 678 // intentionally undefined, don't use these 679 dHinge2Joint (const dHinge2Joint &); 680 void operator = (const dHinge2Joint &); 681 682 public: dHinge2Joint()683 dHinge2Joint() { } 684 dHinge2Joint (dWorldID world, dJointGroupID group=0) 685 { _id = dJointCreateHinge2 (world, group); } 686 dHinge2Joint (dWorld& world, dJointGroupID group=0) 687 { _id = dJointCreateHinge2 (world.id(), group); } 688 689 void create (dWorldID world, dJointGroupID group=0) { 690 if (_id) dJointDestroy (_id); 691 _id = dJointCreateHinge2 (world, group); 692 } 693 void create (dWorld& world, dJointGroupID group=0) 694 { create(world.id(), group); } 695 setAnchor(dReal x,dReal y,dReal z)696 void setAnchor (dReal x, dReal y, dReal z) 697 { dJointSetHinge2Anchor (_id, x, y, z); } setAnchor(const dVector3 a)698 void setAnchor (const dVector3 a) 699 { setAnchor(a[0], a[1], a[2]); } setAxis1(dReal x,dReal y,dReal z)700 void setAxis1 (dReal x, dReal y, dReal z) 701 { dJointSetHinge2Axis1 (_id, x, y, z); } setAxis1(const dVector3 a)702 void setAxis1 (const dVector3 a) 703 { setAxis1 (a[0], a[1], a[2]); } setAxis2(dReal x,dReal y,dReal z)704 void setAxis2 (dReal x, dReal y, dReal z) 705 { dJointSetHinge2Axis2 (_id, x, y, z); } setAxis2(const dVector3 a)706 void setAxis2 (const dVector3 a) 707 { setAxis2 (a[0], a[1], a[2]); } 708 getAnchor(dVector3 result)709 void getAnchor (dVector3 result) const 710 { dJointGetHinge2Anchor (_id, result); } getAnchor2(dVector3 result)711 void getAnchor2 (dVector3 result) const 712 { dJointGetHinge2Anchor2 (_id, result); } getAxis1(dVector3 result)713 void getAxis1 (dVector3 result) const 714 { dJointGetHinge2Axis1 (_id, result); } getAxis2(dVector3 result)715 void getAxis2 (dVector3 result) const 716 { dJointGetHinge2Axis2 (_id, result); } 717 getAngle1()718 dReal getAngle1() const 719 { return dJointGetHinge2Angle1 (_id); } getAngle1Rate()720 dReal getAngle1Rate() const 721 { return dJointGetHinge2Angle1Rate (_id); } getAngle2Rate()722 dReal getAngle2Rate() const 723 { return dJointGetHinge2Angle2Rate (_id); } 724 setParam(int parameter,dReal value)725 virtual void setParam (int parameter, dReal value) 726 { dJointSetHinge2Param (_id, parameter, value); } getParam(int parameter)727 virtual dReal getParam (int parameter) const 728 { return dJointGetHinge2Param (_id, parameter); } 729 // TODO: expose params through methods 730 addTorques(dReal torque1,dReal torque2)731 void addTorques(dReal torque1, dReal torque2) 732 { dJointAddHinge2Torques(_id, torque1, torque2); } 733 }; 734 735 736 class dPRJoint : public dJoint { 737 dPRJoint (const dPRJoint &); 738 void operator = (const dPRJoint &); 739 740 public: dPRJoint()741 dPRJoint() { } 742 dPRJoint (dWorldID world, dJointGroupID group=0) 743 { _id = dJointCreatePR (world, group); } 744 dPRJoint (dWorld& world, dJointGroupID group=0) 745 { _id = dJointCreatePR (world.id(), group); } 746 747 void create (dWorldID world, dJointGroupID group=0) { 748 if (_id) dJointDestroy (_id); 749 _id = dJointCreatePR (world, group); 750 } 751 void create (dWorld& world, dJointGroupID group=0) 752 { create(world.id(), group); } 753 setAnchor(dReal x,dReal y,dReal z)754 void setAnchor (dReal x, dReal y, dReal z) 755 { dJointSetPRAnchor (_id, x, y, z); } setAnchor(const dVector3 a)756 void setAnchor (const dVector3 a) 757 { setAnchor (a[0], a[1], a[2]); } setAxis1(dReal x,dReal y,dReal z)758 void setAxis1 (dReal x, dReal y, dReal z) 759 { dJointSetPRAxis1 (_id, x, y, z); } setAxis1(const dVector3 a)760 void setAxis1 (const dVector3 a) 761 { setAxis1(a[0], a[1], a[2]); } setAxis2(dReal x,dReal y,dReal z)762 void setAxis2 (dReal x, dReal y, dReal z) 763 { dJointSetPRAxis2 (_id, x, y, z); } setAxis2(const dVector3 a)764 void setAxis2 (const dVector3 a) 765 { setAxis2(a[0], a[1], a[2]); } 766 getAnchor(dVector3 result)767 void getAnchor (dVector3 result) const 768 { dJointGetPRAnchor (_id, result); } getAxis1(dVector3 result)769 void getAxis1 (dVector3 result) const 770 { dJointGetPRAxis1 (_id, result); } getAxis2(dVector3 result)771 void getAxis2 (dVector3 result) const 772 { dJointGetPRAxis2 (_id, result); } 773 getPosition()774 dReal getPosition() const 775 { return dJointGetPRPosition (_id); } getPositionRate()776 dReal getPositionRate() const 777 { return dJointGetPRPositionRate (_id); } 778 getAngle()779 dReal getAngle() const 780 { return dJointGetPRAngle (_id); } getAngleRate()781 dReal getAngleRate() const 782 { return dJointGetPRAngleRate (_id); } 783 setParam(int parameter,dReal value)784 virtual void setParam (int parameter, dReal value) 785 { dJointSetPRParam (_id, parameter, value); } getParam(int parameter)786 virtual dReal getParam (int parameter) const 787 { return dJointGetPRParam (_id, parameter); } 788 }; 789 790 791 792 class dPUJoint : public dJoint 793 { 794 dPUJoint (const dPUJoint &); 795 void operator = (const dPUJoint &); 796 797 public: dPUJoint()798 dPUJoint() { } 799 dPUJoint (dWorldID world, dJointGroupID group=0) 800 { _id = dJointCreatePU (world, group); } 801 dPUJoint (dWorld& world, dJointGroupID group=0) 802 { _id = dJointCreatePU (world.id(), group); } 803 804 void create (dWorldID world, dJointGroupID group=0) 805 { 806 if (_id) dJointDestroy (_id); 807 _id = dJointCreatePU (world, group); 808 } 809 void create (dWorld& world, dJointGroupID group=0) 810 { create(world.id(), group); } 811 setAnchor(dReal x,dReal y,dReal z)812 void setAnchor (dReal x, dReal y, dReal z) 813 { dJointSetPUAnchor (_id, x, y, z); } setAnchor(const dVector3 a)814 void setAnchor (const dVector3 a) 815 { setAnchor (a[0], a[1], a[2]); } setAxis1(dReal x,dReal y,dReal z)816 void setAxis1 (dReal x, dReal y, dReal z) 817 { dJointSetPUAxis1 (_id, x, y, z); } setAxis1(const dVector3 a)818 void setAxis1 (const dVector3 a) 819 { setAxis1(a[0], a[1], a[2]); } setAxis2(dReal x,dReal y,dReal z)820 void setAxis2 (dReal x, dReal y, dReal z) 821 { dJointSetPUAxis2 (_id, x, y, z); } setAxis3(dReal x,dReal y,dReal z)822 void setAxis3 (dReal x, dReal y, dReal z) 823 { dJointSetPUAxis3 (_id, x, y, z); } setAxis3(const dVector3 a)824 void setAxis3 (const dVector3 a) 825 { setAxis3(a[0], a[1], a[2]); } setAxisP(dReal x,dReal y,dReal z)826 void setAxisP (dReal x, dReal y, dReal z) 827 { dJointSetPUAxis3 (_id, x, y, z); } setAxisP(const dVector3 a)828 void setAxisP (const dVector3 a) 829 { setAxisP(a[0], a[1], a[2]); } 830 getAnchor(dVector3 result)831 virtual void getAnchor (dVector3 result) const 832 { dJointGetPUAnchor (_id, result); } getAxis1(dVector3 result)833 void getAxis1 (dVector3 result) const 834 { dJointGetPUAxis1 (_id, result); } getAxis2(dVector3 result)835 void getAxis2 (dVector3 result) const 836 { dJointGetPUAxis2 (_id, result); } getAxis3(dVector3 result)837 void getAxis3 (dVector3 result) const 838 { dJointGetPUAxis3 (_id, result); } getAxisP(dVector3 result)839 void getAxisP (dVector3 result) const 840 { dJointGetPUAxis3 (_id, result); } 841 getAngle1()842 dReal getAngle1() const 843 { return dJointGetPUAngle1 (_id); } getAngle1Rate()844 dReal getAngle1Rate() const 845 { return dJointGetPUAngle1Rate (_id); } getAngle2()846 dReal getAngle2() const 847 { return dJointGetPUAngle2 (_id); } getAngle2Rate()848 dReal getAngle2Rate() const 849 { return dJointGetPUAngle2Rate (_id); } 850 getPosition()851 dReal getPosition() const 852 { return dJointGetPUPosition (_id); } getPositionRate()853 dReal getPositionRate() const 854 { return dJointGetPUPositionRate (_id); } 855 setParam(int parameter,dReal value)856 virtual void setParam (int parameter, dReal value) 857 { dJointSetPUParam (_id, parameter, value); } getParam(int parameter)858 virtual dReal getParam (int parameter) const 859 { return dJointGetPUParam (_id, parameter); } 860 // TODO: expose params through methods 861 }; 862 863 864 865 866 867 class dPistonJoint : public dJoint 868 { 869 // intentionally undefined, don't use these 870 dPistonJoint (const dPistonJoint &); 871 void operator = (const dPistonJoint &); 872 873 public: dPistonJoint()874 dPistonJoint() { } 875 dPistonJoint (dWorldID world, dJointGroupID group=0) 876 { _id = dJointCreatePiston (world, group); } 877 dPistonJoint (dWorld& world, dJointGroupID group=0) 878 { _id = dJointCreatePiston (world, group); } 879 880 void create (dWorldID world, dJointGroupID group=0) 881 { 882 if (_id) dJointDestroy (_id); 883 _id = dJointCreatePiston (world, group); 884 } 885 void create (dWorld& world, dJointGroupID group=0) 886 { create(world.id(), group); } 887 setAnchor(dReal x,dReal y,dReal z)888 void setAnchor (dReal x, dReal y, dReal z) 889 { dJointSetPistonAnchor (_id, x, y, z); } setAnchor(const dVector3 a)890 void setAnchor (const dVector3 a) 891 { setAnchor (a[0], a[1], a[2]); } getAnchor(dVector3 result)892 void getAnchor (dVector3 result) const 893 { dJointGetPistonAnchor (_id, result); } getAnchor2(dVector3 result)894 void getAnchor2 (dVector3 result) const 895 { dJointGetPistonAnchor2 (_id, result); } 896 setAxis(dReal x,dReal y,dReal z)897 void setAxis (dReal x, dReal y, dReal z) 898 { dJointSetPistonAxis (_id, x, y, z); } setAxis(const dVector3 a)899 void setAxis (const dVector3 a) 900 { setAxis(a[0], a[1], a[2]); } getAxis(dVector3 result)901 void getAxis (dVector3 result) const 902 { dJointGetPistonAxis (_id, result); } 903 getPosition()904 dReal getPosition() const 905 { return dJointGetPistonPosition (_id); } getPositionRate()906 dReal getPositionRate() const 907 { return dJointGetPistonPositionRate (_id); } 908 setParam(int parameter,dReal value)909 virtual void setParam (int parameter, dReal value) 910 { dJointSetPistonParam (_id, parameter, value); } getParam(int parameter)911 virtual dReal getParam (int parameter) const 912 { return dJointGetPistonParam (_id, parameter); } 913 // TODO: expose params through methods 914 addForce(dReal force)915 void addForce (dReal force) 916 { dJointAddPistonForce (_id, force); } 917 }; 918 919 920 921 class dFixedJoint : public dJoint 922 { 923 // intentionally undefined, don't use these 924 dFixedJoint (const dFixedJoint &); 925 void operator = (const dFixedJoint &); 926 927 public: dFixedJoint()928 dFixedJoint() { } 929 dFixedJoint (dWorldID world, dJointGroupID group=0) 930 { _id = dJointCreateFixed (world, group); } 931 dFixedJoint (dWorld& world, dJointGroupID group=0) 932 { _id = dJointCreateFixed (world, group); } 933 934 void create (dWorldID world, dJointGroupID group=0) { 935 if (_id) dJointDestroy (_id); 936 _id = dJointCreateFixed (world, group); 937 } 938 void create (dWorld& world, dJointGroupID group=0) 939 { create(world.id(), group); } 940 set()941 void set() 942 { dJointSetFixed (_id); } 943 setParam(int parameter,dReal value)944 virtual void setParam (int parameter, dReal value) 945 { dJointSetFixedParam (_id, parameter, value); } 946 getParam(int parameter)947 virtual dReal getParam (int parameter) const 948 { return dJointGetFixedParam (_id, parameter); } 949 // TODO: expose params through methods 950 }; 951 952 953 class dContactJoint : public dJoint { 954 // intentionally undefined, don't use these 955 dContactJoint (const dContactJoint &); 956 void operator = (const dContactJoint &); 957 958 public: dContactJoint()959 dContactJoint() { } dContactJoint(dWorldID world,dJointGroupID group,dContact * contact)960 dContactJoint (dWorldID world, dJointGroupID group, dContact *contact) 961 { _id = dJointCreateContact (world, group, contact); } dContactJoint(dWorld & world,dJointGroupID group,dContact * contact)962 dContactJoint (dWorld& world, dJointGroupID group, dContact *contact) 963 { _id = dJointCreateContact (world.id(), group, contact); } 964 create(dWorldID world,dJointGroupID group,dContact * contact)965 void create (dWorldID world, dJointGroupID group, dContact *contact) { 966 if (_id) dJointDestroy (_id); 967 _id = dJointCreateContact (world, group, contact); 968 } 969 create(dWorld & world,dJointGroupID group,dContact * contact)970 void create (dWorld& world, dJointGroupID group, dContact *contact) 971 { create(world.id(), group, contact); } 972 }; 973 974 975 class dNullJoint : public dJoint { 976 // intentionally undefined, don't use these 977 dNullJoint (const dNullJoint &); 978 void operator = (const dNullJoint &); 979 980 public: dNullJoint()981 dNullJoint() { } 982 dNullJoint (dWorldID world, dJointGroupID group=0) 983 { _id = dJointCreateNull (world, group); } 984 dNullJoint (dWorld& world, dJointGroupID group=0) 985 { _id = dJointCreateNull (world.id(), group); } 986 987 void create (dWorldID world, dJointGroupID group=0) { 988 if (_id) dJointDestroy (_id); 989 _id = dJointCreateNull (world, group); 990 } 991 void create (dWorld& world, dJointGroupID group=0) 992 { create(world.id(), group); } 993 }; 994 995 996 class dAMotorJoint : public dJoint { 997 // intentionally undefined, don't use these 998 dAMotorJoint (const dAMotorJoint &); 999 void operator = (const dAMotorJoint &); 1000 1001 public: dAMotorJoint()1002 dAMotorJoint() { } 1003 dAMotorJoint (dWorldID world, dJointGroupID group=0) 1004 { _id = dJointCreateAMotor (world, group); } 1005 dAMotorJoint (dWorld& world, dJointGroupID group=0) 1006 { _id = dJointCreateAMotor (world.id(), group); } 1007 1008 void create (dWorldID world, dJointGroupID group=0) { 1009 if (_id) dJointDestroy (_id); 1010 _id = dJointCreateAMotor (world, group); 1011 } 1012 void create (dWorld& world, dJointGroupID group=0) 1013 { create(world.id(), group); } 1014 setMode(int mode)1015 void setMode (int mode) 1016 { dJointSetAMotorMode (_id, mode); } getMode()1017 int getMode() const 1018 { return dJointGetAMotorMode (_id); } 1019 setNumAxes(int num)1020 void setNumAxes (int num) 1021 { dJointSetAMotorNumAxes (_id, num); } getNumAxes()1022 int getNumAxes() const 1023 { return dJointGetAMotorNumAxes (_id); } 1024 setAxis(int anum,int rel,dReal x,dReal y,dReal z)1025 void setAxis (int anum, int rel, dReal x, dReal y, dReal z) 1026 { dJointSetAMotorAxis (_id, anum, rel, x, y, z); } setAxis(int anum,int rel,const dVector3 a)1027 void setAxis (int anum, int rel, const dVector3 a) 1028 { setAxis(anum, rel, a[0], a[1], a[2]); } getAxis(int anum,dVector3 result)1029 void getAxis (int anum, dVector3 result) const 1030 { dJointGetAMotorAxis (_id, anum, result); } getAxisRel(int anum)1031 int getAxisRel (int anum) const 1032 { return dJointGetAMotorAxisRel (_id, anum); } 1033 setAngle(int anum,dReal angle)1034 void setAngle (int anum, dReal angle) 1035 { dJointSetAMotorAngle (_id, anum, angle); } getAngle(int anum)1036 dReal getAngle (int anum) const 1037 { return dJointGetAMotorAngle (_id, anum); } getAngleRate(int anum)1038 dReal getAngleRate (int anum) 1039 { return dJointGetAMotorAngleRate (_id,anum); } 1040 setParam(int parameter,dReal value)1041 void setParam (int parameter, dReal value) 1042 { dJointSetAMotorParam (_id, parameter, value); } getParam(int parameter)1043 dReal getParam (int parameter) const 1044 { return dJointGetAMotorParam (_id, parameter); } 1045 // TODO: expose params through methods 1046 addTorques(dReal torque1,dReal torque2,dReal torque3)1047 void addTorques(dReal torque1, dReal torque2, dReal torque3) 1048 { dJointAddAMotorTorques(_id, torque1, torque2, torque3); } 1049 }; 1050 1051 1052 class dLMotorJoint : public dJoint { 1053 // intentionally undefined, don't use these 1054 dLMotorJoint (const dLMotorJoint &); 1055 void operator = (const dLMotorJoint &); 1056 1057 public: dLMotorJoint()1058 dLMotorJoint() { } 1059 dLMotorJoint (dWorldID world, dJointGroupID group=0) 1060 { _id = dJointCreateLMotor (world, group); } 1061 dLMotorJoint (dWorld& world, dJointGroupID group=0) 1062 { _id = dJointCreateLMotor (world.id(), group); } 1063 1064 void create (dWorldID world, dJointGroupID group=0) { 1065 if (_id) dJointDestroy (_id); 1066 _id = dJointCreateLMotor (world, group); 1067 } 1068 void create (dWorld& world, dJointGroupID group=0) 1069 { create(world.id(), group); } 1070 setNumAxes(int num)1071 void setNumAxes (int num) 1072 { dJointSetLMotorNumAxes (_id, num); } getNumAxes()1073 int getNumAxes() const 1074 { return dJointGetLMotorNumAxes (_id); } 1075 setAxis(int anum,int rel,dReal x,dReal y,dReal z)1076 void setAxis (int anum, int rel, dReal x, dReal y, dReal z) 1077 { dJointSetLMotorAxis (_id, anum, rel, x, y, z); } setAxis(int anum,int rel,const dVector3 a)1078 void setAxis (int anum, int rel, const dVector3 a) 1079 { setAxis(anum, rel, a[0], a[1], a[2]); } getAxis(int anum,dVector3 result)1080 void getAxis (int anum, dVector3 result) const 1081 { dJointGetLMotorAxis (_id, anum, result); } 1082 setParam(int parameter,dReal value)1083 void setParam (int parameter, dReal value) 1084 { dJointSetLMotorParam (_id, parameter, value); } getParam(int parameter)1085 dReal getParam (int parameter) const 1086 { return dJointGetLMotorParam (_id, parameter); } 1087 // TODO: expose params through methods 1088 }; 1089 1090 //} 1091 1092 #endif 1093 #endif 1094 1095 // Local variables: 1096 // mode:c++ 1097 // c-basic-offset:2 1098 // End: 1099