1 /*************************************************************************
3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
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 *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
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. *
21 *************************************************************************/
23 /* C++ interface for new collision API */
26 #ifndef _ODE_ODECPP_COLLISION_H_
27 #define _ODE_ODECPP_COLLISION_H_
30 //#include <ode/error.h>
35 // intentionally undefined, don't use these
37 void operator= (dGeom &);
46 { if (_id) dGeomDestroy (_id); }
50 operator dGeomID() const
54 if (_id) dGeomDestroy (_id);
59 { return dGeomGetClass (_id); }
61 dSpaceID getSpace() const
62 { return dGeomGetSpace (_id); }
64 void setData (void *data)
65 { dGeomSetData (_id,data); }
67 { return dGeomGetData (_id); }
69 void setBody (dBodyID b)
70 { dGeomSetBody (_id,b); }
71 dBodyID getBody() const
72 { return dGeomGetBody (_id); }
74 void setPosition (dReal x, dReal y, dReal z)
75 { dGeomSetPosition (_id,x,y,z); }
76 const dReal * getPosition() const
77 { return dGeomGetPosition (_id); }
79 void setRotation (const dMatrix3 R)
80 { dGeomSetRotation (_id,R); }
81 const dReal * getRotation() const
82 { return dGeomGetRotation (_id); }
84 void setQuaternion (const dQuaternion quat)
85 { dGeomSetQuaternion (_id,quat); }
86 void getQuaternion (dQuaternion quat) const
87 { dGeomGetQuaternion (_id,quat); }
89 void getAABB (dReal aabb[6]) const
90 { dGeomGetAABB (_id, aabb); }
93 { return dGeomIsSpace (_id); }
95 void setCategoryBits (unsigned long bits)
96 { dGeomSetCategoryBits (_id, bits); }
97 void setCollideBits (unsigned long bits)
98 { dGeomSetCollideBits (_id, bits); }
99 unsigned long getCategoryBits()
100 { return dGeomGetCategoryBits (_id); }
101 unsigned long getCollideBits()
102 { return dGeomGetCollideBits (_id); }
105 { dGeomEnable (_id); }
107 { dGeomDisable (_id); }
109 { return dGeomIsEnabled (_id); }
111 void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
112 { dGeomGetRelPointPos (_id, px, py, pz, result); }
113 void getRelPointPos (const dVector3 p, dVector3 result) const
114 { getRelPointPos (p[0], p[1], p[2], result); }
116 void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
117 { dGeomGetPosRelPoint (_id, px, py, pz, result); }
118 void getPosRelPoint (const dVector3 p, dVector3 result) const
119 { getPosRelPoint (p[0], p[1], p[2], result); }
121 void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
122 { dGeomVectorToWorld (_id, px, py, pz, result); }
123 void vectorToWorld (const dVector3 p, dVector3 result) const
124 { vectorToWorld (p[0], p[1], p[2], result); }
126 void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const
127 { dGeomVectorFromWorld (_id, px, py, pz, result); }
128 void vectorFromWorld (const dVector3 p, dVector3 result) const
129 { vectorFromWorld (p[0], p[1], p[2], result); }
131 void collide2 (dGeomID g, void *data, dNearCallback *callback)
132 { dSpaceCollide2 (_id,g,data,callback); }
136 class dSpace : public dGeom {
137 // intentionally undefined, don't use these
139 void operator= (dSpace &);
142 // the default constructor is protected so that you
143 // can't instance this class. you must instance one
144 // of its subclasses instead.
145 dSpace () { _id = 0; }
149 { return (dSpaceID) _id; }
150 operator dSpaceID() const
151 { return (dSpaceID) _id; }
153 void setCleanup (int mode)
154 { dSpaceSetCleanup (id(), mode); }
156 { return dSpaceGetCleanup (id()); }
159 { dSpaceAdd (id(), x); }
160 void remove (dGeomID x)
161 { dSpaceRemove (id(), x); }
162 int query (dGeomID x)
163 { return dSpaceQuery (id(),x); }
166 { return dSpaceGetNumGeoms (id()); }
167 dGeomID getGeom (int i)
168 { return dSpaceGetGeom (id(),i); }
170 void collide (void *data, dNearCallback *callback)
171 { dSpaceCollide (id(),data,callback); }
175 class dSimpleSpace : public dSpace {
176 // intentionally undefined, don't use these
177 dSimpleSpace (dSimpleSpace &);
178 void operator= (dSimpleSpace &);
182 { _id = (dGeomID) dSimpleSpaceCreate (0); }
183 dSimpleSpace (dSpace &space)
184 { _id = (dGeomID) dSimpleSpaceCreate (space.id()); }
185 dSimpleSpace (dSpaceID space)
186 { _id = (dGeomID) dSimpleSpaceCreate (space); }
190 class dHashSpace : public dSpace {
191 // intentionally undefined, don't use these
192 dHashSpace (dHashSpace &);
193 void operator= (dHashSpace &);
197 { _id = (dGeomID) dHashSpaceCreate (0); }
198 dHashSpace (dSpace &space)
199 { _id = (dGeomID) dHashSpaceCreate (space.id()); }
200 dHashSpace (dSpaceID space)
201 { _id = (dGeomID) dHashSpaceCreate (space); }
203 void setLevels (int minlevel, int maxlevel)
204 { dHashSpaceSetLevels (id(),minlevel,maxlevel); }
208 class dQuadTreeSpace : public dSpace {
209 // intentionally undefined, don't use these
210 dQuadTreeSpace (dQuadTreeSpace &);
211 void operator= (dQuadTreeSpace &);
214 dQuadTreeSpace (const dVector3 center, const dVector3 extents, int depth)
215 { _id = (dGeomID) dQuadTreeSpaceCreate (0,center,extents,depth); }
216 dQuadTreeSpace (dSpace &space, const dVector3 center, const dVector3 extents, int depth)
217 { _id = (dGeomID) dQuadTreeSpaceCreate (space.id(),center,extents,depth); }
218 dQuadTreeSpace (dSpaceID space, const dVector3 center, const dVector3 extents, int depth)
219 { _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
223 class dSphere : public dGeom {
224 // intentionally undefined, don't use these
226 void operator= (dSphere &);
230 dSphere (dReal radius)
231 { _id = dCreateSphere (0, radius); }
232 dSphere (dSpace &space, dReal radius)
233 { _id = dCreateSphere (space.id(), radius); }
234 dSphere (dSpaceID space, dReal radius)
235 { _id = dCreateSphere (space, radius); }
237 void create (dSpaceID space, dReal radius) {
238 if (_id) dGeomDestroy (_id);
239 _id = dCreateSphere (space, radius);
242 void setRadius (dReal radius)
243 { dGeomSphereSetRadius (_id, radius); }
244 dReal getRadius() const
245 { return dGeomSphereGetRadius (_id); }
249 class dBox : public dGeom {
250 // intentionally undefined, don't use these
252 void operator= (dBox &);
256 dBox (dReal lx, dReal ly, dReal lz)
257 { _id = dCreateBox (0,lx,ly,lz); }
258 dBox (dSpace &space, dReal lx, dReal ly, dReal lz)
259 { _id = dCreateBox (space,lx,ly,lz); }
260 dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
261 { _id = dCreateBox (space,lx,ly,lz); }
263 void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
264 if (_id) dGeomDestroy (_id);
265 _id = dCreateBox (space,lx,ly,lz);
268 void setLengths (dReal lx, dReal ly, dReal lz)
269 { dGeomBoxSetLengths (_id, lx, ly, lz); }
270 void getLengths (dVector3 result) const
271 { dGeomBoxGetLengths (_id,result); }
275 class dPlane : public dGeom {
276 // intentionally undefined, don't use these
278 void operator= (dPlane &);
282 dPlane (dReal a, dReal b, dReal c, dReal d)
283 { _id = dCreatePlane (0,a,b,c,d); }
284 dPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d)
285 { _id = dCreatePlane (space.id(),a,b,c,d); }
286 dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
287 { _id = dCreatePlane (space,a,b,c,d); }
289 void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
290 if (_id) dGeomDestroy (_id);
291 _id = dCreatePlane (space,a,b,c,d);
294 void setParams (dReal a, dReal b, dReal c, dReal d)
295 { dGeomPlaneSetParams (_id, a, b, c, d); }
296 void getParams (dVector4 result) const
297 { dGeomPlaneGetParams (_id,result); }
301 class dCapsule : public dGeom {
302 // intentionally undefined, don't use these
303 dCapsule (dCapsule &);
304 void operator= (dCapsule &);
308 dCapsule (dReal radius, dReal length)
309 { _id = dCreateCapsule (0,radius,length); }
310 dCapsule (dSpace &space, dReal radius, dReal length)
311 { _id = dCreateCapsule (space.id(),radius,length); }
312 dCapsule (dSpaceID space, dReal radius, dReal length)
313 { _id = dCreateCapsule (space,radius,length); }
315 void create (dSpaceID space, dReal radius, dReal length) {
316 if (_id) dGeomDestroy (_id);
317 _id = dCreateCapsule (space,radius,length);
320 void setParams (dReal radius, dReal length)
321 { dGeomCapsuleSetParams (_id, radius, length); }
322 void getParams (dReal *radius, dReal *length) const
323 { dGeomCapsuleGetParams (_id,radius,length); }
327 class dCylinder : public dGeom {
328 // intentionally undefined, don't use these
329 dCylinder (dCylinder &);
330 void operator= (dCylinder &);
334 dCylinder (dReal radius, dReal length)
335 { _id = dCreateCylinder (0,radius,length); }
336 dCylinder (dSpace &space, dReal radius, dReal length)
337 { _id = dCreateCylinder (space.id(),radius,length); }
338 dCylinder (dSpaceID space, dReal radius, dReal length)
339 { _id = dCreateCylinder (space,radius,length); }
341 void create (dSpaceID space, dReal radius, dReal length) {
342 if (_id) dGeomDestroy (_id);
343 _id = dCreateCylinder (space,radius,length);
346 void setParams (dReal radius, dReal length)
347 { dGeomCylinderSetParams (_id, radius, length); }
348 void getParams (dReal *radius, dReal *length) const
349 { dGeomCylinderGetParams (_id,radius,length); }
353 class dRay : public dGeom {
354 // intentionally undefined, don't use these
356 void operator= (dRay &);
361 { _id = dCreateRay (0,length); }
362 dRay (dSpace &space, dReal length)
363 { _id = dCreateRay (space.id(),length); }
364 dRay (dSpaceID space, dReal length)
365 { _id = dCreateRay (space,length); }
367 void create (dSpaceID space, dReal length) {
368 if (_id) dGeomDestroy (_id);
369 _id = dCreateRay (space,length);
372 void setLength (dReal length)
373 { dGeomRaySetLength (_id, length); }
375 { return dGeomRayGetLength (_id); }
377 void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
378 { dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
379 void get (dVector3 start, dVector3 dir)
380 { dGeomRayGet (_id, start, dir); }
383 #pragma warning( push )
384 #pragma warning( disable : 4996 )
386 #pragma GCC diagnostic push
387 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
390 void setParams (int firstContact, int backfaceCull)
391 { dGeomRaySetParams (_id, firstContact, backfaceCull); }
394 void getParams (int *firstContact, int *backfaceCull)
395 { dGeomRayGetParams (_id, firstContact, backfaceCull); }
397 #pragma warning( pop )
399 #pragma GCC diagnostic pop
401 void setBackfaceCull (int backfaceCull)
402 { dGeomRaySetBackfaceCull (_id, backfaceCull); }
403 int getBackfaceCull()
404 { return dGeomRayGetBackfaceCull (_id); }
406 void setFirstContact (int firstContact)
407 { dGeomRaySetFirstContact (_id, firstContact); }
408 int getFirstContact()
409 { return dGeomRayGetFirstContact (_id); }
411 void setClosestHit (int closestHit)
412 { dGeomRaySetClosestHit (_id, closestHit); }
414 { return dGeomRayGetClosestHit (_id); }
418 #pragma warning( push )
419 #pragma warning( disable : 4996 )
421 #pragma GCC diagnostic push
422 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
425 class ODE_API_DEPRECATED dGeomTransform : public dGeom {
426 // intentionally undefined, don't use these
427 dGeomTransform (dGeomTransform &);
428 void operator= (dGeomTransform &);
432 dGeomTransform (dSpace &space)
433 { _id = dCreateGeomTransform (space.id()); }
434 dGeomTransform (dSpaceID space)
435 { _id = dCreateGeomTransform (space); }
437 void create (dSpaceID space=0) {
438 if (_id) dGeomDestroy (_id);
439 _id = dCreateGeomTransform (space);
442 void setGeom (dGeomID geom)
443 { dGeomTransformSetGeom (_id, geom); }
444 dGeomID getGeom() const
445 { return dGeomTransformGetGeom (_id); }
447 void setCleanup (int mode)
448 { dGeomTransformSetCleanup (_id,mode); }
450 { return dGeomTransformGetCleanup (_id); }
452 void setInfo (int mode)
453 { dGeomTransformSetInfo (_id,mode); }
455 { return dGeomTransformGetInfo (_id); }
459 #pragma warning( pop )
461 #pragma GCC diagnostic pop