source: GTP/trunk/Lib/Geom/OgreStuff/include/ode/odecpp_old.h @ 1809

Revision 1809, 9.5 KB checked in by gumbau, 18 years ago (diff)
Line 
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/* this is the old C++ interface, the new C++ interface is not quite
24 * compatible with this. but this file is kept around in case you were
25 * using the old interface.
26 */
27
28#ifndef _ODE_ODECPP_H_
29#define _ODE_ODECPP_H_
30#ifdef __cplusplus
31
32#include <ode/error.h>
33
34
35class dWorld {
36  dWorldID _id;
37
38  dWorld (dWorld &) { dDebug (0,"bad"); }
39  void operator= (dWorld &) { dDebug (0,"bad"); }
40
41public:
42  dWorld()
43    { _id = dWorldCreate(); }
44  ~dWorld()
45    { dWorldDestroy (_id); }
46  dWorldID id()
47    { return _id; }
48
49  void setGravity (dReal x, dReal y, dReal z)
50    { dWorldSetGravity (_id,x,y,z); }
51  void getGravity (dVector3 g)
52    { dWorldGetGravity (_id,g); }
53  void step (dReal stepsize)
54    { dWorldStep (_id,stepsize); }
55};
56
57
58class dBody {
59  dBodyID _id;
60
61  dBody (dBody &) { dDebug (0,"bad"); }
62  void operator= (dBody &) { dDebug (0,"bad"); }
63
64public:
65  dBody()
66    { _id = 0; }
67  dBody (dWorld &world)
68    { _id = dBodyCreate (world.id()); }
69  ~dBody()
70    { dBodyDestroy (_id); }
71  void create (dWorld &world)
72    { if (_id) dBodyDestroy (_id); _id = dBodyCreate (world.id()); }
73  dBodyID id()
74    { return _id; }
75
76  void setData (void *data)
77    { dBodySetData (_id,data); }
78  void *getData()
79    { return dBodyGetData (_id); }
80
81  void setPosition (dReal x, dReal y, dReal z)
82    { dBodySetPosition (_id,x,y,z); }
83  void setRotation (const dMatrix3 R)
84    { dBodySetRotation (_id,R); }
85  void setQuaternion (const dQuaternion q)
86    { dBodySetQuaternion (_id,q); }
87  void setLinearVel  (dReal x, dReal y, dReal z)
88    { dBodySetLinearVel (_id,x,y,z); }
89  void setAngularVel (dReal x, dReal y, dReal z)
90    { dBodySetAngularVel (_id,x,y,z); }
91
92  const dReal * getPosition()
93    { return dBodyGetPosition (_id); }
94  const dReal * getRotation()
95    { return dBodyGetRotation (_id); }
96  const dReal * getQuaternion()
97    { return dBodyGetQuaternion (_id); }
98  const dReal * getLinearVel()
99    { return dBodyGetLinearVel (_id); }
100  const dReal * getAngularVel()
101    { return dBodyGetAngularVel (_id); }
102
103  void setMass (const dMass *mass)
104    { dBodySetMass (_id,mass); }
105  void getMass (dMass *mass)
106    { dBodyGetMass (_id,mass); }
107
108  void addForce (dReal fx, dReal fy, dReal fz)
109    { dBodyAddForce (_id, fx, fy, fz); }
110  void addTorque (dReal fx, dReal fy, dReal fz)
111    { dBodyAddTorque (_id, fx, fy, fz); }
112  void addRelForce (dReal fx, dReal fy, dReal fz)
113    { dBodyAddRelForce (_id, fx, fy, fz); }
114  void addRelTorque (dReal fx, dReal fy, dReal fz)
115    { dBodyAddRelTorque (_id, fx, fy, fz); }
116  void addForceAtPos (dReal fx, dReal fy, dReal fz,
117                      dReal px, dReal py, dReal pz)
118    { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); }
119  void addRelForceAtPos (dReal fx, dReal fy, dReal fz,
120                         dReal px, dReal py, dReal pz)
121    { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); }
122  void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz,
123                            dReal px, dReal py, dReal pz)
124    { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); }
125
126  void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result)
127    { dBodyGetRelPointPos (_id, px, py, pz, result); }
128  void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result)
129    { dBodyGetRelPointVel (_id, px, py, pz, result); }
130
131  int isConnectedTo (const dBody &b)
132    { return dAreConnected (_id,b._id); }
133};
134
135
136class dJointGroup {
137  dJointGroupID _id;
138
139  dJointGroup (dJointGroup &) { dDebug (0,"bad"); }
140  void operator= (dJointGroup &) { dDebug (0,"bad"); }
141
142public:
143  dJointGroup()
144    { _id = 0; }
145  dJointGroup (int max_size)
146    { _id = dJointGroupCreate (max_size); }
147  ~dJointGroup()
148    { dJointGroupDestroy (_id); }
149  void create (int max_size)
150    { if (_id) dJointGroupDestroy (_id); _id = dJointGroupCreate (max_size); }
151  dJointGroupID id()
152    { return _id; }
153
154  void empty()
155    { dJointGroupEmpty (_id); }
156};
157
158
159class dJoint {
160  dJointID _id;
161
162  dJoint (dJoint &) { dDebug (0,"bad"); }
163  void operator= (dJoint &) { dDebug (0,"bad"); }
164
165public:
166  dJoint()
167    { _id = 0; }
168  ~dJoint()
169    { dJointDestroy (_id); }
170  dJointID id()
171    { return _id; }
172
173  void createBall (dWorld &world, dJointGroup *group=0) {
174    if (_id) dJointDestroy (_id);
175    _id = dJointCreateBall (world.id(), group ? group->id() : 0);
176  }
177  void createHinge (dWorld &world, dJointGroup *group=0) {
178    if (_id) dJointDestroy (_id);
179    _id = dJointCreateHinge (world.id(), group ? group->id() : 0);
180  }
181  void createSlider (dWorld &world, dJointGroup *group=0) {
182    if (_id) dJointDestroy (_id);
183    _id = dJointCreateSlider (world.id(), group ? group->id() : 0);
184  }
185  void createContact (dWorld &world, dJointGroup *group, dContact *contact) {
186    if (_id) dJointDestroy (_id);
187    _id = dJointCreateContact (world.id(), group ? group->id() : 0, contact);
188  }
189
190  void attach (dBody &body1, dBody &body2)
191    { dJointAttach (_id, body1.id(), body2.id()); }
192
193  void setBallAnchor (dReal x, dReal y, dReal z)
194    { dJointSetBallAnchor (_id, x, y, z); }
195  void setHingeAnchor (dReal x, dReal y, dReal z)
196    { dJointSetHingeAnchor (_id, x, y, z); }
197
198  void setHingeAxis (dReal x, dReal y, dReal z)
199    { dJointSetHingeAxis (_id, x, y, z); }
200  void setSliderAxis (dReal x, dReal y, dReal z)
201    { dJointSetSliderAxis (_id, x, y, z); }
202
203  void getBallAnchor (dVector3 result)
204    { dJointGetBallAnchor (_id, result); }
205  void getHingeAnchor (dVector3 result)
206    { dJointGetHingeAnchor (_id, result); }
207
208  void getHingeAxis (dVector3 result)
209    { dJointGetHingeAxis (_id, result); }
210  void getSliderAxis (dVector3 result)
211    { dJointGetSliderAxis (_id, result); }
212};
213
214
215class dSpace {
216  dSpaceID _id;
217
218  dSpace (dSpace &) { dDebug (0,"bad"); }
219  void operator= (dSpace &) { dDebug (0,"bad"); }
220
221public:
222  dSpace ()
223    { _id = dHashSpaceCreate(); }
224  ~dSpace()
225    { dSpaceDestroy (_id); }
226  dSpaceID id()
227    { return _id; }
228  void collide (void *data, dNearCallback *callback)
229    { dSpaceCollide (_id,data,callback); }
230};
231
232
233class dGeom {
234  dGeomID _id;
235
236  dGeom (dGeom &) { dDebug (0,"bad"); }
237  void operator= (dGeom &) { dDebug (0,"bad"); }
238
239public:
240  dGeom()
241    { _id = 0; }
242  ~dGeom()
243    { dGeomDestroy (_id); }
244  dGeomID id()
245    { return _id; }
246
247  void createSphere (dSpace &space, dReal radius) {
248    if (_id) dGeomDestroy (_id);
249    _id = dCreateSphere (space.id(),radius);
250  }
251
252  void createBox (dSpace &space, dReal lx, dReal ly, dReal lz) {
253    if (_id) dGeomDestroy (_id);
254    _id = dCreateBox (space.id(),lx,ly,lz);
255  }
256
257  void createPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d) {
258    if (_id) dGeomDestroy (_id);
259    _id = dCreatePlane (space.id(),a,b,c,d);
260  }
261
262  void createCCylinder (dSpace &space, dReal radius, dReal length) {
263    if (_id) dGeomDestroy (_id);
264    _id = dCreateCCylinder (space.id(),radius,length);
265  }
266
267  void destroy() {
268    if (_id) dGeomDestroy (_id);
269    _id = 0;
270  }
271
272  int getClass()
273    { return dGeomGetClass (_id); }
274
275  dReal sphereGetRadius()
276    { return dGeomSphereGetRadius (_id); }
277
278  void boxGetLengths (dVector3 result)
279    { dGeomBoxGetLengths (_id,result); }
280
281  void planeGetParams (dVector4 result)
282    { dGeomPlaneGetParams (_id,result); }
283
284  void CCylinderGetParams (dReal *radius, dReal *length)
285    { dGeomCCylinderGetParams (_id,radius,length); }
286
287  void setData (void *data)
288    { dGeomSetData (_id,data); }
289
290  void *getData()
291    { return dGeomGetData (_id); }
292
293  void setBody (dBody &b)
294    { dGeomSetBody (_id,b.id()); }
295  void setBody (dBodyID b)
296    { dGeomSetBody (_id,b); }
297
298  dBodyID getBody()
299    { return dGeomGetBody (_id); }
300
301  void setPosition (dReal x, dReal y, dReal z)
302    { dGeomSetPosition (_id,x,y,z); }
303
304  void setRotation (const dMatrix3 R)
305    { dGeomSetRotation (_id,R); }
306
307  const dReal * getPosition()
308    { return dGeomGetPosition (_id); }
309
310  const dReal * getRotation()
311    { return dGeomGetRotation (_id); }
312};
313
314
315#endif
316#endif
Note: See TracBrowser for help on using the repository browser.