odecpp.h 36 KB

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