source: OGRE/trunk/ogre_dependencies/Dependencies/include/ode/odecpp_collision.h @ 692

Revision 692, 9.4 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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/* C++ interface for new collision API */
24
25
26#ifndef _ODE_ODECPP_COLLISION_H_
27#define _ODE_ODECPP_COLLISION_H_
28#ifdef __cplusplus
29
30#include <ode/error.h>
31
32
33class dGeom {
34  // intentionally undefined, don't use these
35  dGeom (dGeom &);
36  void operator= (dGeom &);
37
38protected:
39  dGeomID _id;
40
41public:
42  dGeom()
43    { _id = 0; }
44  ~dGeom()
45    { if (_id) dGeomDestroy (_id); }
46
47  dGeomID id() const
48    { return _id; }
49  operator dGeomID() const
50    { return _id; }
51
52  void destroy() {
53    if (_id) dGeomDestroy (_id);
54    _id = 0;
55  }
56
57  int getClass() const
58    { return dGeomGetClass (_id); }
59
60  dSpaceID getSpace() const
61    { return dGeomGetSpace (_id); }
62
63  void setData (void *data)
64    { dGeomSetData (_id,data); }
65  void *getData() const
66    { return dGeomGetData (_id); }
67
68  void setBody (dBodyID b)
69    { dGeomSetBody (_id,b); }
70  dBodyID getBody() const
71    { return dGeomGetBody (_id); }
72
73  void setPosition (dReal x, dReal y, dReal z)
74    { dGeomSetPosition (_id,x,y,z); }
75  const dReal * getPosition() const
76    { return dGeomGetPosition (_id); }
77
78  void setRotation (const dMatrix3 R)
79    { dGeomSetRotation (_id,R); }
80  const dReal * getRotation() const
81    { return dGeomGetRotation (_id); }
82   
83  void setQuaternion (const dQuaternion quat)
84    { dGeomSetQuaternion (_id,quat); }
85  void getQuaternion (dQuaternion quat) const
86    { dGeomGetQuaternion (_id,quat); }
87
88  void getAABB (dReal aabb[6]) const
89    { dGeomGetAABB (_id, aabb); }
90
91  int isSpace()
92    { return dGeomIsSpace (_id); }
93
94  void setCategoryBits (unsigned long bits)
95    { dGeomSetCategoryBits (_id, bits); }
96  void setCollideBits (unsigned long bits)
97    { dGeomSetCollideBits (_id, bits); }
98  unsigned long getCategoryBits()
99    { return dGeomGetCategoryBits (_id); }
100  unsigned long getCollideBits()
101    { return dGeomGetCollideBits (_id); }
102
103  void enable()
104    { dGeomEnable (_id); }
105  void disable()
106    { dGeomDisable (_id); }
107  int isEnabled()
108    { return dGeomIsEnabled (_id); }
109
110  void collide2 (dGeomID g, void *data, dNearCallback *callback)
111    { dSpaceCollide2 (_id,g,data,callback); }
112};
113
114
115class dSpace : public dGeom {
116  // intentionally undefined, don't use these
117  dSpace (dSpace &);
118  void operator= (dSpace &);
119
120protected:
121  // the default constructor is protected so that you
122  // can't instance this class. you must instance one
123  // of its subclasses instead.
124  dSpace () { _id = 0; }
125
126public:
127  dSpaceID id() const
128    { return (dSpaceID) _id; }
129  operator dSpaceID() const
130    { return (dSpaceID) _id; }
131
132  void setCleanup (int mode)
133    { dSpaceSetCleanup (id(), mode); }
134  int getCleanup()
135    { return dSpaceGetCleanup (id()); }
136
137  void add (dGeomID x)
138    { dSpaceAdd (id(), x); }
139  void remove (dGeomID x)
140    { dSpaceRemove (id(), x); }
141  int query (dGeomID x)
142    { return dSpaceQuery (id(),x); }
143
144  int getNumGeoms()
145    { return dSpaceGetNumGeoms (id()); }
146  dGeomID getGeom (int i)
147    { return dSpaceGetGeom (id(),i); }
148
149  void collide (void *data, dNearCallback *callback)
150    { dSpaceCollide (id(),data,callback); }
151};
152
153
154class dSimpleSpace : public dSpace {
155  // intentionally undefined, don't use these
156  dSimpleSpace (dSimpleSpace &);
157  void operator= (dSimpleSpace &);
158
159public:
160  dSimpleSpace (dSpaceID space)
161    { _id = (dGeomID) dSimpleSpaceCreate (space); }
162};
163
164
165class dHashSpace : public dSpace {
166  // intentionally undefined, don't use these
167  dHashSpace (dHashSpace &);
168  void operator= (dHashSpace &);
169
170public:
171  dHashSpace (dSpaceID space)
172    { _id = (dGeomID) dHashSpaceCreate (space); }
173  void setLevels (int minlevel, int maxlevel)
174    { dHashSpaceSetLevels (id(),minlevel,maxlevel); }
175};
176
177
178class dQuadTreeSpace : public dSpace {
179  // intentionally undefined, don't use these
180  dQuadTreeSpace (dQuadTreeSpace &);
181  void operator= (dQuadTreeSpace &);
182
183public:
184  dQuadTreeSpace (dSpaceID space, dVector3 center, dVector3 extents, int depth)
185    { _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
186};
187
188
189class dSphere : public dGeom {
190  // intentionally undefined, don't use these
191  dSphere (dSphere &);
192  void operator= (dSphere &);
193
194public:
195  dSphere () { }
196  dSphere (dSpaceID space, dReal radius)
197    { _id = dCreateSphere (space, radius); }
198
199  void create (dSpaceID space, dReal radius) {
200    if (_id) dGeomDestroy (_id);
201    _id = dCreateSphere (space, radius);
202  }
203
204  void setRadius (dReal radius)
205    { dGeomSphereSetRadius (_id, radius); }
206  dReal getRadius() const
207    { return dGeomSphereGetRadius (_id); }
208};
209
210
211class dBox : public dGeom {
212  // intentionally undefined, don't use these
213  dBox (dBox &);
214  void operator= (dBox &);
215
216public:
217  dBox () { }
218  dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
219    { _id = dCreateBox (space,lx,ly,lz); }
220
221  void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
222    if (_id) dGeomDestroy (_id);
223    _id = dCreateBox (space,lx,ly,lz);
224  }
225
226  void setLengths (dReal lx, dReal ly, dReal lz)
227    { dGeomBoxSetLengths (_id, lx, ly, lz); }
228  void getLengths (dVector3 result) const
229    { dGeomBoxGetLengths (_id,result); }
230};
231
232
233class dPlane : public dGeom {
234  // intentionally undefined, don't use these
235  dPlane (dPlane &);
236  void operator= (dPlane &);
237
238public:
239  dPlane() { }
240  dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
241    { _id = dCreatePlane (space,a,b,c,d); }
242
243  void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
244    if (_id) dGeomDestroy (_id);
245    _id = dCreatePlane (space,a,b,c,d);
246  }
247
248  void setParams (dReal a, dReal b, dReal c, dReal d)
249    { dGeomPlaneSetParams (_id, a, b, c, d); }
250  void getParams (dVector4 result) const
251    { dGeomPlaneGetParams (_id,result); }
252};
253
254
255class dCCylinder : public dGeom {
256  // intentionally undefined, don't use these
257  dCCylinder (dCCylinder &);
258  void operator= (dCCylinder &);
259
260public:
261  dCCylinder() { }
262  dCCylinder (dSpaceID space, dReal radius, dReal length)
263    { _id = dCreateCCylinder (space,radius,length); }
264
265  void create (dSpaceID space, dReal radius, dReal length) {
266    if (_id) dGeomDestroy (_id);
267    _id = dCreateCCylinder (space,radius,length);
268  }
269
270  void setParams (dReal radius, dReal length)
271    { dGeomCCylinderSetParams (_id, radius, length); }
272  void getParams (dReal *radius, dReal *length) const
273    { dGeomCCylinderGetParams (_id,radius,length); }
274};
275
276
277class dRay : public dGeom {
278  // intentionally undefined, don't use these
279  dRay (dRay &);
280  void operator= (dRay &);
281
282public:
283  dRay() { }
284  dRay (dSpaceID space, dReal length)
285    { _id = dCreateRay (space,length); }
286
287  void create (dSpaceID space, dReal length) {
288    if (_id) dGeomDestroy (_id);
289    _id = dCreateRay (space,length);
290  }
291
292  void setLength (dReal length)
293    { dGeomRaySetLength (_id, length); }
294  dReal getLength()
295    { return dGeomRayGetLength (_id); }
296
297  void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
298    { dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
299  void get (dVector3 start, dVector3 dir)
300    { dGeomRayGet (_id, start, dir); }
301
302  void setParams (int firstContact, int backfaceCull)
303    { dGeomRaySetParams (_id, firstContact, backfaceCull); }
304  void getParams (int *firstContact, int *backfaceCull)
305    { dGeomRayGetParams (_id, firstContact, backfaceCull); }
306  void setClosestHit (int closestHit)
307    { dGeomRaySetClosestHit (_id, closestHit); }
308  int getClosestHit()
309    { return dGeomRayGetClosestHit (_id); }
310};
311
312
313class dGeomTransform : public dGeom {
314  // intentionally undefined, don't use these
315  dGeomTransform (dGeomTransform &);
316  void operator= (dGeomTransform &);
317
318public:
319  dGeomTransform() { }
320  dGeomTransform (dSpaceID space)
321    { _id = dCreateGeomTransform (space); }
322
323  void create (dSpaceID space=0) {
324    if (_id) dGeomDestroy (_id);
325    _id = dCreateGeomTransform (space);
326  }
327
328  void setGeom (dGeomID geom)
329    { dGeomTransformSetGeom (_id, geom); }
330  dGeomID getGeom() const
331    { return dGeomTransformGetGeom (_id); }
332
333  void setCleanup (int mode)
334    { dGeomTransformSetCleanup (_id,mode); }
335  int getCleanup ()
336    { return dGeomTransformGetCleanup (_id); }
337
338  void setInfo (int mode)
339    { dGeomTransformSetInfo (_id,mode); }
340  int getInfo()
341    { return dGeomTransformGetInfo (_id); }
342};
343
344
345#endif
346#endif
Note: See TracBrowser for help on using the repository browser.