collision.h

00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith.       *
00004  * All rights reserved.  Email: russ@q12.org   Web: www.q12.org          *
00005  *                                                                       *
00006  * This library is free software; you can redistribute it and/or         *
00007  * modify it under the terms of EITHER:                                  *
00008  *   (1) The GNU Lesser General Public License as published by the Free  *
00009  *       Software Foundation; either version 2.1 of the License, or (at  *
00010  *       your option) any later version. The text of the GNU Lesser      *
00011  *       General Public License is included with this library in the     *
00012  *       file LICENSE.TXT.                                               *
00013  *   (2) The BSD-style license that is included with this library in     *
00014  *       the file LICENSE-BSD.TXT.                                       *
00015  *                                                                       *
00016  * This library is distributed in the hope that it will be useful,       *
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00019  * LICENSE.TXT and LICENSE-BSD.TXT for more details.                     *
00020  *                                                                       *
00021  *************************************************************************/
00022 
00023 #ifndef _ODE_COLLISION_H_
00024 #define _ODE_COLLISION_H_
00025 
00026 #include <ode/common.h>
00027 #include <ode/collision_space.h>
00028 #include <ode/contact.h>
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00049 /* ************************************************************************ */
00050 /* general functions */
00051 
00065 ODE_API void dGeomDestroy (dGeomID geom);
00066 
00067 
00075 ODE_API void dGeomSetData (dGeomID geom, void* data);
00076 
00077 
00084 ODE_API void *dGeomGetData (dGeomID geom);
00085 
00086 
00105 ODE_API void dGeomSetBody (dGeomID geom, dBodyID body);
00106 
00107 
00114 ODE_API dBodyID dGeomGetBody (dGeomID geom);
00115 
00116 
00131 ODE_API void dGeomSetPosition (dGeomID geom, dReal x, dReal y, dReal z);
00132 
00133 
00146 ODE_API void dGeomSetRotation (dGeomID geom, const dMatrix3 R);
00147 
00148 
00162 ODE_API void dGeomSetQuaternion (dGeomID geom, const dQuaternion Q);
00163 
00164 
00181 ODE_API const dReal * dGeomGetPosition (dGeomID geom);
00182 
00183 
00200 ODE_API const dReal * dGeomGetRotation (dGeomID geom);
00201 
00202 
00216 ODE_API void dGeomGetQuaternion (dGeomID geom, dQuaternion result);
00217 
00218 
00235 ODE_API void dGeomGetAABB (dGeomID geom, dReal aabb[6]);
00236 
00237 
00244 ODE_API int dGeomIsSpace (dGeomID geom);
00245 
00246 
00254 ODE_API dSpaceID dGeomGetSpace (dGeomID);
00255 
00256 
00281 ODE_API int dGeomGetClass (dGeomID geom);
00282 
00283 
00296 ODE_API void dGeomSetCategoryBits (dGeomID geom, unsigned long bits);
00297 
00298 
00311 ODE_API void dGeomSetCollideBits (dGeomID geom, unsigned long bits);
00312 
00313 
00322 ODE_API unsigned long dGeomGetCategoryBits (dGeomID);
00323 
00324 
00333 ODE_API unsigned long dGeomGetCollideBits (dGeomID);
00334 
00335 
00348 ODE_API void dGeomEnable (dGeomID geom);
00349 
00350 
00363 ODE_API void dGeomDisable (dGeomID geom);
00364 
00365 
00379 ODE_API int dGeomIsEnabled (dGeomID geom);
00380 
00381 /* ************************************************************************ */
00382 /* geom offset from body */
00383 
00399 ODE_API void dGeomSetOffsetPosition (dGeomID geom, dReal x, dReal y, dReal z);
00400 
00401 
00415 ODE_API void dGeomSetOffsetRotation (dGeomID geom, const dMatrix3 R);
00416 
00417 
00431 ODE_API void dGeomSetOffsetQuaternion (dGeomID geom, const dQuaternion Q);
00432 
00433 
00450 ODE_API void dGeomSetOffsetWorldPosition (dGeomID geom, dReal x, dReal y, dReal z);
00451 
00452 
00467 ODE_API void dGeomSetOffsetWorldRotation (dGeomID geom, const dMatrix3 R);
00468 
00469 
00484 ODE_API void dGeomSetOffsetWorldQuaternion (dGeomID geom, const dQuaternion);
00485 
00486 
00500 ODE_API void dGeomClearOffset(dGeomID geom);
00501 
00502 
00518 ODE_API int dGeomIsOffset(dGeomID geom);
00519 
00520 
00534 ODE_API const dReal * dGeomGetOffsetPosition (dGeomID geom);
00535 
00536 
00550 ODE_API const dReal * dGeomGetOffsetRotation (dGeomID geom);
00551 
00552 
00563 ODE_API void dGeomGetOffsetQuaternion (dGeomID geom, dQuaternion result);
00564 
00565 /* ************************************************************************ */
00566 /* collision detection */
00567 
00568 ODE_API int dCollide (dGeomID o1, dGeomID o2, int flags, dContactGeom *contact,
00569          int skip);
00570 ODE_API void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback);
00571 ODE_API void dSpaceCollide2 (dGeomID o1, dGeomID o2, void *data,
00572            dNearCallback *callback);
00573 
00574 /* ************************************************************************ */
00575 /* standard classes */
00576 
00577 /* the maximum number of user classes that are supported */
00578 enum {
00579   dMaxUserClasses = 4
00580 };
00581 
00582 /* class numbers - each geometry object needs a unique number */
00583 enum {
00584   dSphereClass = 0,
00585   dBoxClass,
00586   dCapsuleClass,
00587   dCylinderClass,
00588   dPlaneClass,
00589   dRayClass,
00590   dConvexClass,
00591   dGeomTransformClass,
00592   dTriMeshClass,
00593 
00594   dFirstSpaceClass,
00595   dSimpleSpaceClass = dFirstSpaceClass,
00596   dHashSpaceClass,
00597   dQuadTreeSpaceClass,
00598   dLastSpaceClass = dQuadTreeSpaceClass,
00599 
00600   dFirstUserClass,
00601   dLastUserClass = dFirstUserClass + dMaxUserClasses - 1,
00602   dGeomNumClasses
00603 };
00604 
00605 
00606 ODE_API dGeomID dCreateSphere (dSpaceID space, dReal radius);
00607 ODE_API void dGeomSphereSetRadius (dGeomID sphere, dReal radius);
00608 ODE_API dReal dGeomSphereGetRadius (dGeomID sphere);
00609 ODE_API dReal dGeomSpherePointDepth (dGeomID sphere, dReal x, dReal y, dReal z);
00610 
00611 //--> Convex Functions
00612 ODE_API dGeomID dCreateConvex (dSpaceID space,
00613                 dReal *_planes,
00614                 unsigned int _planecount,
00615                 dReal *_points,
00616                 unsigned int _pointcount,unsigned int *_polygons);
00617   
00618 ODE_API void dGeomSetConvex (dGeomID g,
00619               dReal *_planes,
00620               unsigned int _count,
00621               dReal *_points,
00622               unsigned int _pointcount,unsigned int *_polygons);
00623 //<-- Convex Functions
00624 
00625 ODE_API dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
00626 ODE_API void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz);
00627 ODE_API void dGeomBoxGetLengths (dGeomID box, dVector3 result);
00628 ODE_API dReal dGeomBoxPointDepth (dGeomID box, dReal x, dReal y, dReal z);
00629 
00630 ODE_API dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
00631 ODE_API void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d);
00632 ODE_API void dGeomPlaneGetParams (dGeomID plane, dVector4 result);
00633 ODE_API dReal dGeomPlanePointDepth (dGeomID plane, dReal x, dReal y, dReal z);
00634 
00635 ODE_API dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length);
00636 ODE_API void dGeomCapsuleSetParams (dGeomID ccylinder, dReal radius, dReal length);
00637 ODE_API void dGeomCapsuleGetParams (dGeomID ccylinder, dReal *radius, dReal *length);
00638 ODE_API dReal dGeomCapsulePointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);
00639 
00640 // For now we want to have a backwards compatible C-API, note: C++ API is not.
00641 #define dCreateCCylinder dCreateCapsule
00642 #define dGeomCCylinderSetParams dGeomCapsuleSetParams
00643 #define dGeomCCylinderGetParams dGeomCapsuleGetParams
00644 #define dGeomCCylinderPointDepth dGeomCapsulePointDepth
00645 #define dCCylinderClass dCapsuleClass
00646 
00647 ODE_API dGeomID dCreateCylinder (dSpaceID space, dReal radius, dReal length);
00648 ODE_API void dGeomCylinderSetParams (dGeomID cylinder, dReal radius, dReal length);
00649 ODE_API void dGeomCylinderGetParams (dGeomID cylinder, dReal *radius, dReal *length);
00650 
00651 ODE_API dGeomID dCreateRay (dSpaceID space, dReal length);
00652 ODE_API void dGeomRaySetLength (dGeomID ray, dReal length);
00653 ODE_API dReal dGeomRayGetLength (dGeomID ray);
00654 ODE_API void dGeomRaySet (dGeomID ray, dReal px, dReal py, dReal pz,
00655         dReal dx, dReal dy, dReal dz);
00656 ODE_API void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir);
00657 
00658 /*
00659  * Set/get ray flags that influence ray collision detection.
00660  * These flags are currently only noticed by the trimesh collider, because
00661  * they can make a major differences there.
00662  */
00663 ODE_API void dGeomRaySetParams (dGeomID g, int FirstContact, int BackfaceCull);
00664 ODE_API void dGeomRayGetParams (dGeomID g, int *FirstContact, int *BackfaceCull);
00665 ODE_API void dGeomRaySetClosestHit (dGeomID g, int closestHit);
00666 ODE_API int dGeomRayGetClosestHit (dGeomID g);
00667 
00668 #include "collision_trimesh.h"
00669 
00670 ODE_API dGeomID dCreateGeomTransform (dSpaceID space);
00671 ODE_API void dGeomTransformSetGeom (dGeomID g, dGeomID obj);
00672 ODE_API dGeomID dGeomTransformGetGeom (dGeomID g);
00673 ODE_API void dGeomTransformSetCleanup (dGeomID g, int mode);
00674 ODE_API int dGeomTransformGetCleanup (dGeomID g);
00675 ODE_API void dGeomTransformSetInfo (dGeomID g, int mode);
00676 ODE_API int dGeomTransformGetInfo (dGeomID g);
00677 
00678 /* ************************************************************************ */
00679 /* utility functions */
00680 
00681 ODE_API void dClosestLineSegmentPoints (const dVector3 a1, const dVector3 a2,
00682             const dVector3 b1, const dVector3 b2,
00683             dVector3 cp1, dVector3 cp2);
00684 
00685 ODE_API int dBoxTouchesBox (const dVector3 _p1, const dMatrix3 R1,
00686           const dVector3 side1, const dVector3 _p2,
00687           const dMatrix3 R2, const dVector3 side2);
00688 
00689 ODE_API int dBoxBox (const dVector3 p1, const dMatrix3 R1,
00690         const dVector3 side1, const dVector3 p2,
00691         const dMatrix3 R2, const dVector3 side2,
00692         dVector3 normal, dReal *depth, int *return_code,
00693         int maxc, dContactGeom *contact, int skip);
00694 
00695 ODE_API void dInfiniteAABB (dGeomID geom, dReal aabb[6]);
00696 ODE_API void dCloseODE(void);
00697 
00698 /* ************************************************************************ */
00699 /* custom classes */
00700 
00701 typedef void dGetAABBFn (dGeomID, dReal aabb[6]);
00702 typedef int dColliderFn (dGeomID o1, dGeomID o2,
00703           int flags, dContactGeom *contact, int skip);
00704 typedef dColliderFn * dGetColliderFnFn (int num);
00705 typedef void dGeomDtorFn (dGeomID o);
00706 typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]);
00707 
00708 typedef struct dGeomClass {
00709   int bytes;
00710   dGetColliderFnFn *collider;
00711   dGetAABBFn *aabb;
00712   dAABBTestFn *aabb_test;
00713   dGeomDtorFn *dtor;
00714 } dGeomClass;
00715 
00716 ODE_API int dCreateGeomClass (const dGeomClass *classptr);
00717 ODE_API void * dGeomGetClassData (dGeomID);
00718 ODE_API dGeomID dCreateGeom (int classnum);
00719 
00720 /* ************************************************************************ */
00721 
00722 #ifdef __cplusplus
00723 }
00724 #endif
00725 
00726 #endif

Generated on Fri Jun 9 10:49:47 2006 for Open Dynamics Engine by  doxygen 1.4.6-NO