classicui_plat/ode_api/inc/odecpp_collision.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 "error.h"
       
    31 
       
    32 
       
    33 class dGeom {
       
    34   // intentionally undefined, don't use these
       
    35   dGeom (dGeom &);
       
    36   void operator= (dGeom &);
       
    37 
       
    38 protected:
       
    39   dGeomID _id;
       
    40 
       
    41 public:
       
    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 
       
   115 class dSpace : public dGeom {
       
   116   // intentionally undefined, don't use these
       
   117   dSpace (dSpace &);
       
   118   void operator= (dSpace &);
       
   119 
       
   120 protected:
       
   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 
       
   126 public:
       
   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 
       
   154 class dSimpleSpace : public dSpace {
       
   155   // intentionally undefined, don't use these
       
   156   dSimpleSpace (dSimpleSpace &);
       
   157   void operator= (dSimpleSpace &);
       
   158 
       
   159 public:
       
   160   dSimpleSpace (dSpaceID space)
       
   161     { _id = (dGeomID) dSimpleSpaceCreate (space); }
       
   162 };
       
   163 
       
   164 class dQuadTreeSpace : public dSpace {
       
   165   // intentionally undefined, don't use these
       
   166   dQuadTreeSpace (dQuadTreeSpace &);
       
   167   void operator= (dQuadTreeSpace &);
       
   168 
       
   169 public:
       
   170   dQuadTreeSpace (dSpaceID space, dVector3 center, dVector3 extents, int depth)
       
   171     { _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
       
   172 };
       
   173 
       
   174 
       
   175 class dSphere : public dGeom {
       
   176   // intentionally undefined, don't use these
       
   177   dSphere (dSphere &);
       
   178   void operator= (dSphere &);
       
   179 
       
   180 public:
       
   181   dSphere () { }
       
   182   dSphere (dSpaceID space, dReal radius)
       
   183     { _id = dCreateSphere (space, radius); }
       
   184 
       
   185   void create (dSpaceID space, dReal radius) {
       
   186     if (_id) dGeomDestroy (_id);
       
   187     _id = dCreateSphere (space, radius);
       
   188   }
       
   189 
       
   190   void setRadius (dReal radius)
       
   191     { dGeomSphereSetRadius (_id, radius); }
       
   192   dReal getRadius() const
       
   193     { return dGeomSphereGetRadius (_id); }
       
   194 };
       
   195 
       
   196 
       
   197 class dBox : public dGeom {
       
   198   // intentionally undefined, don't use these
       
   199   dBox (dBox &);
       
   200   void operator= (dBox &);
       
   201 
       
   202 public:
       
   203   dBox () { }
       
   204   dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
       
   205     { _id = dCreateBox (space,lx,ly,lz); }
       
   206 
       
   207   void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
       
   208     if (_id) dGeomDestroy (_id);
       
   209     _id = dCreateBox (space,lx,ly,lz);
       
   210   }
       
   211 
       
   212   void setLengths (dReal lx, dReal ly, dReal lz)
       
   213     { dGeomBoxSetLengths (_id, lx, ly, lz); }
       
   214   void getLengths (dVector3 result) const
       
   215     { dGeomBoxGetLengths (_id,result); }
       
   216 };
       
   217 
       
   218 
       
   219 class dPlane : public dGeom {
       
   220   // intentionally undefined, don't use these
       
   221   dPlane (dPlane &);
       
   222   void operator= (dPlane &);
       
   223 
       
   224 public:
       
   225   dPlane() { }
       
   226   dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
       
   227     { _id = dCreatePlane (space,a,b,c,d); }
       
   228 
       
   229   void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
       
   230     if (_id) dGeomDestroy (_id);
       
   231     _id = dCreatePlane (space,a,b,c,d);
       
   232   }
       
   233 
       
   234   void setParams (dReal a, dReal b, dReal c, dReal d)
       
   235     { dGeomPlaneSetParams (_id, a, b, c, d); }
       
   236   void getParams (dVector4 result) const
       
   237     { dGeomPlaneGetParams (_id,result); }
       
   238 };
       
   239 
       
   240 
       
   241 class dCapsule : public dGeom {
       
   242   // intentionally undefined, don't use these
       
   243   dCapsule (dCapsule &);
       
   244   void operator= (dCapsule &);
       
   245 
       
   246 public:
       
   247   dCapsule() { }
       
   248   dCapsule (dSpaceID space, dReal radius, dReal length)
       
   249     { _id = dCreateCapsule (space,radius,length); }
       
   250 
       
   251   void create (dSpaceID space, dReal radius, dReal length) {
       
   252     if (_id) dGeomDestroy (_id);
       
   253     _id = dCreateCapsule (space,radius,length);
       
   254   }
       
   255 
       
   256   void setParams (dReal radius, dReal length)
       
   257     { dGeomCapsuleSetParams (_id, radius, length); }
       
   258   void getParams (dReal *radius, dReal *length) const
       
   259     { dGeomCapsuleGetParams (_id,radius,length); }
       
   260 };
       
   261 
       
   262 
       
   263 class dRay : public dGeom {
       
   264   // intentionally undefined, don't use these
       
   265   dRay (dRay &);
       
   266   void operator= (dRay &);
       
   267 
       
   268 public:
       
   269   dRay() { }
       
   270   dRay (dSpaceID space, dReal length)
       
   271     { _id = dCreateRay (space,length); }
       
   272 
       
   273   void create (dSpaceID space, dReal length) {
       
   274     if (_id) dGeomDestroy (_id);
       
   275     _id = dCreateRay (space,length);
       
   276   }
       
   277 
       
   278   void setLength (dReal length)
       
   279     { dGeomRaySetLength (_id, length); }
       
   280   dReal getLength()
       
   281     { return dGeomRayGetLength (_id); }
       
   282 
       
   283   void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
       
   284     { dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
       
   285   void get (dVector3 start, dVector3 dir)
       
   286     { dGeomRayGet (_id, start, dir); }
       
   287 
       
   288   void setParams (int firstContact, int backfaceCull)
       
   289     { dGeomRaySetParams (_id, firstContact, backfaceCull); }
       
   290   void getParams (int *firstContact, int *backfaceCull)
       
   291     { dGeomRayGetParams (_id, firstContact, backfaceCull); }
       
   292   void setClosestHit (int closestHit)
       
   293     { dGeomRaySetClosestHit (_id, closestHit); }
       
   294   int getClosestHit()
       
   295     { return dGeomRayGetClosestHit (_id); }
       
   296 };
       
   297 
       
   298 
       
   299 class dGeomTransform : public dGeom {
       
   300   // intentionally undefined, don't use these
       
   301   dGeomTransform (dGeomTransform &);
       
   302   void operator= (dGeomTransform &);
       
   303 
       
   304 public:
       
   305   dGeomTransform() { }
       
   306   dGeomTransform (dSpaceID space)
       
   307     { _id = dCreateGeomTransform (space); }
       
   308 
       
   309   void create (dSpaceID space=0) {
       
   310     if (_id) dGeomDestroy (_id);
       
   311     _id = dCreateGeomTransform (space);
       
   312   }
       
   313 
       
   314   void setGeom (dGeomID geom)
       
   315     { dGeomTransformSetGeom (_id, geom); }
       
   316   dGeomID getGeom() const
       
   317     { return dGeomTransformGetGeom (_id); }
       
   318 
       
   319   void setCleanup (int mode)
       
   320     { dGeomTransformSetCleanup (_id,mode); }
       
   321   int getCleanup ()
       
   322     { return dGeomTransformGetCleanup (_id); }
       
   323 
       
   324   void setInfo (int mode)
       
   325     { dGeomTransformSetInfo (_id,mode); }
       
   326   int getInfo()
       
   327     { return dGeomTransformGetInfo (_id); }
       
   328 };
       
   329 
       
   330 
       
   331 #endif
       
   332 #endif