Main Page | Modules | Data Structures | File List | Data Fields

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 
00191 ODE_API void dGeomCopyPosition (dGeomID geom, dVector3 pos);
00192 
00193 
00210 ODE_API const dReal * dGeomGetRotation (dGeomID geom);
00211 
00212 
00226 ODE_API void dGeomCopyRotation(dGeomID geom, dMatrix3 R);
00227 
00228 
00242 ODE_API void dGeomGetQuaternion (dGeomID geom, dQuaternion result);
00243 
00244 
00261 ODE_API void dGeomGetAABB (dGeomID geom, dReal aabb[6]);
00262 
00263 
00270 ODE_API int dGeomIsSpace (dGeomID geom);
00271 
00272 
00280 ODE_API dSpaceID dGeomGetSpace (dGeomID);
00281 
00282 
00307 ODE_API int dGeomGetClass (dGeomID geom);
00308 
00309 
00322 ODE_API void dGeomSetCategoryBits (dGeomID geom, unsigned long bits);
00323 
00324 
00337 ODE_API void dGeomSetCollideBits (dGeomID geom, unsigned long bits);
00338 
00339 
00348 ODE_API unsigned long dGeomGetCategoryBits (dGeomID);
00349 
00350 
00359 ODE_API unsigned long dGeomGetCollideBits (dGeomID);
00360 
00361 
00374 ODE_API void dGeomEnable (dGeomID geom);
00375 
00376 
00389 ODE_API void dGeomDisable (dGeomID geom);
00390 
00391 
00405 ODE_API int dGeomIsEnabled (dGeomID geom);
00406 
00407 /* ************************************************************************ */
00408 /* geom offset from body */
00409 
00425 ODE_API void dGeomSetOffsetPosition (dGeomID geom, dReal x, dReal y, dReal z);
00426 
00427 
00441 ODE_API void dGeomSetOffsetRotation (dGeomID geom, const dMatrix3 R);
00442 
00443 
00457 ODE_API void dGeomSetOffsetQuaternion (dGeomID geom, const dQuaternion Q);
00458 
00459 
00476 ODE_API void dGeomSetOffsetWorldPosition (dGeomID geom, dReal x, dReal y, dReal z);
00477 
00478 
00493 ODE_API void dGeomSetOffsetWorldRotation (dGeomID geom, const dMatrix3 R);
00494 
00495 
00510 ODE_API void dGeomSetOffsetWorldQuaternion (dGeomID geom, const dQuaternion);
00511 
00512 
00526 ODE_API void dGeomClearOffset(dGeomID geom);
00527 
00528 
00544 ODE_API int dGeomIsOffset(dGeomID geom);
00545 
00546 
00560 ODE_API const dReal * dGeomGetOffsetPosition (dGeomID geom);
00561 
00562 
00573 ODE_API void dGeomCopyOffsetPosition (dGeomID geom, dVector3 pos);
00574 
00575 
00590 ODE_API const dReal * dGeomGetOffsetRotation (dGeomID geom);
00591 
00592 
00604 ODE_API void dGeomCopyOffsetRotation (dGeomID geom, dMatrix3 R);
00605 
00606 
00617 ODE_API void dGeomGetOffsetQuaternion (dGeomID geom, dQuaternion result);
00618 
00619 
00620 /* ************************************************************************ */
00621 /* collision detection */
00622 
00623 /*
00624  * Just generate any contacts (disables any contact refining).
00625  */
00626 #define CONTACTS_UNIMPORTANT        0x80000000
00627 
00675 ODE_API int dCollide (dGeomID o1, dGeomID o2, int flags, dContactGeom *contact,
00676          int skip);
00677 
00705 ODE_API void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback);
00706 
00707 
00742 ODE_API void dSpaceCollide2 (dGeomID space1, dGeomID space2, void *data, dNearCallback *callback);
00743 
00744 
00745 /* ************************************************************************ */
00746 /* standard classes */
00747 
00748 /* the maximum number of user classes that are supported */
00749 enum {
00750   dMaxUserClasses = 4
00751 };
00752 
00753 /* class numbers - each geometry object needs a unique number */
00754 enum {
00755   dSphereClass = 0,
00756   dBoxClass,
00757   dCapsuleClass,
00758   dCylinderClass,
00759   dPlaneClass,
00760   dRayClass,
00761   dConvexClass,
00762   dGeomTransformClass,
00763   dTriMeshClass,
00764   dHeightfieldClass,
00765 
00766   dFirstSpaceClass,
00767   dSimpleSpaceClass = dFirstSpaceClass,
00768   dHashSpaceClass,
00769   dSweepAndPruneSpaceClass, // SAP
00770   dQuadTreeSpaceClass,
00771   dLastSpaceClass = dQuadTreeSpaceClass,
00772 
00773   dFirstUserClass,
00774   dLastUserClass = dFirstUserClass + dMaxUserClasses - 1,
00775   dGeomNumClasses
00776 };
00777 
00778 
00798 ODE_API dGeomID dCreateSphere (dSpaceID space, dReal radius);
00799 
00800 
00810 ODE_API void dGeomSphereSetRadius (dGeomID sphere, dReal radius);
00811 
00812 
00821 ODE_API dReal dGeomSphereGetRadius (dGeomID sphere);
00822 
00823 
00838 ODE_API dReal dGeomSpherePointDepth (dGeomID sphere, dReal x, dReal y, dReal z);
00839 
00840 
00841 //--> Convex Functions
00842 ODE_API dGeomID dCreateConvex (dSpaceID space,
00843                 dReal *_planes,
00844                 unsigned int _planecount,
00845                 dReal *_points,
00846                 unsigned int _pointcount,unsigned int *_polygons);
00847 
00848 ODE_API void dGeomSetConvex (dGeomID g,
00849               dReal *_planes,
00850               unsigned int _count,
00851               dReal *_points,
00852               unsigned int _pointcount,unsigned int *_polygons);
00853 //<-- Convex Functions
00854 
00876 ODE_API dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
00877 
00878 
00890 ODE_API void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz);
00891 
00892 
00902 ODE_API void dGeomBoxGetLengths (dGeomID box, dVector3 result);
00903 
00904 
00917 ODE_API dReal dGeomBoxPointDepth (dGeomID box, dReal x, dReal y, dReal z);
00918 
00919 
00920 ODE_API dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
00921 ODE_API void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d);
00922 ODE_API void dGeomPlaneGetParams (dGeomID plane, dVector4 result);
00923 ODE_API dReal dGeomPlanePointDepth (dGeomID plane, dReal x, dReal y, dReal z);
00924 
00925 ODE_API dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length);
00926 ODE_API void dGeomCapsuleSetParams (dGeomID ccylinder, dReal radius, dReal length);
00927 ODE_API void dGeomCapsuleGetParams (dGeomID ccylinder, dReal *radius, dReal *length);
00928 ODE_API dReal dGeomCapsulePointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);
00929 
00930 // For now we want to have a backwards compatible C-API, note: C++ API is not.
00931 #define dCreateCCylinder dCreateCapsule
00932 #define dGeomCCylinderSetParams dGeomCapsuleSetParams
00933 #define dGeomCCylinderGetParams dGeomCapsuleGetParams
00934 #define dGeomCCylinderPointDepth dGeomCapsulePointDepth
00935 #define dCCylinderClass dCapsuleClass
00936 
00937 ODE_API dGeomID dCreateCylinder (dSpaceID space, dReal radius, dReal length);
00938 ODE_API void dGeomCylinderSetParams (dGeomID cylinder, dReal radius, dReal length);
00939 ODE_API void dGeomCylinderGetParams (dGeomID cylinder, dReal *radius, dReal *length);
00940 
00941 ODE_API dGeomID dCreateRay (dSpaceID space, dReal length);
00942 ODE_API void dGeomRaySetLength (dGeomID ray, dReal length);
00943 ODE_API dReal dGeomRayGetLength (dGeomID ray);
00944 ODE_API void dGeomRaySet (dGeomID ray, dReal px, dReal py, dReal pz,
00945         dReal dx, dReal dy, dReal dz);
00946 ODE_API void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir);
00947 
00948 /*
00949  * Set/get ray flags that influence ray collision detection.
00950  * These flags are currently only noticed by the trimesh collider, because
00951  * they can make a major differences there.
00952  */
00953 ODE_API void dGeomRaySetParams (dGeomID g, int FirstContact, int BackfaceCull);
00954 ODE_API void dGeomRayGetParams (dGeomID g, int *FirstContact, int *BackfaceCull);
00955 ODE_API void dGeomRaySetClosestHit (dGeomID g, int closestHit);
00956 ODE_API int dGeomRayGetClosestHit (dGeomID g);
00957 
00958 #include "collision_trimesh.h"
00959 
00960 ODE_API dGeomID dCreateGeomTransform (dSpaceID space);
00961 ODE_API void dGeomTransformSetGeom (dGeomID g, dGeomID obj);
00962 ODE_API dGeomID dGeomTransformGetGeom (dGeomID g);
00963 ODE_API void dGeomTransformSetCleanup (dGeomID g, int mode);
00964 ODE_API int dGeomTransformGetCleanup (dGeomID g);
00965 ODE_API void dGeomTransformSetInfo (dGeomID g, int mode);
00966 ODE_API int dGeomTransformGetInfo (dGeomID g);
00967 
00968 
00969 /* ************************************************************************ */
00970 /* heightfield functions */
00971 
00972 
00973 // Data storage for heightfield data.
00974 struct dxHeightfieldData;
00975 typedef struct dxHeightfieldData* dHeightfieldDataID;
00976 
00977 
00995 typedef dReal dHeightfieldGetHeight( void* p_user_data, int x, int z );
00996 
00997 
00998 
01018 ODE_API dGeomID dCreateHeightfield( dSpaceID space,
01019                dHeightfieldDataID data, int bPlaceable );
01020 
01021 
01034 ODE_API dHeightfieldDataID dGeomHeightfieldDataCreate();
01035 
01036 
01045 ODE_API void dGeomHeightfieldDataDestroy( dHeightfieldDataID d );
01046 
01047 
01048 
01089 ODE_API void dGeomHeightfieldDataBuildCallback( dHeightfieldDataID d,
01090             void* pUserData, dHeightfieldGetHeight* pCallback,
01091             dReal width, dReal depth, int widthSamples, int depthSamples,
01092             dReal scale, dReal offset, dReal thickness, int bWrap );
01093 
01137 ODE_API void dGeomHeightfieldDataBuildByte( dHeightfieldDataID d,
01138             const unsigned char* pHeightData, int bCopyHeightData,
01139             dReal width, dReal depth, int widthSamples, int depthSamples,
01140             dReal scale, dReal offset, dReal thickness,  int bWrap );
01141 
01185 ODE_API void dGeomHeightfieldDataBuildShort( dHeightfieldDataID d,
01186             const short* pHeightData, int bCopyHeightData,
01187             dReal width, dReal depth, int widthSamples, int depthSamples,
01188             dReal scale, dReal offset, dReal thickness, int bWrap );
01189 
01235 ODE_API void dGeomHeightfieldDataBuildSingle( dHeightfieldDataID d,
01236             const float* pHeightData, int bCopyHeightData,
01237             dReal width, dReal depth, int widthSamples, int depthSamples,
01238             dReal scale, dReal offset, dReal thickness, int bWrap );
01239 
01285 ODE_API void dGeomHeightfieldDataBuildDouble( dHeightfieldDataID d,
01286             const double* pHeightData, int bCopyHeightData,
01287             dReal width, dReal depth, int widthSamples, int depthSamples,
01288             dReal scale, dReal offset, dReal thickness, int bWrap );
01289 
01307 ODE_API void dGeomHeightfieldDataSetBounds( dHeightfieldDataID d,
01308             dReal minHeight, dReal maxHeight );
01309 
01310 
01321 ODE_API void dGeomHeightfieldSetHeightfieldData( dGeomID g, dHeightfieldDataID d );
01322 
01323 
01333 ODE_API dHeightfieldDataID dGeomHeightfieldGetHeightfieldData( dGeomID g );
01334 
01335 
01336 
01337 /* ************************************************************************ */
01338 /* utility functions */
01339 
01340 ODE_API void dClosestLineSegmentPoints (const dVector3 a1, const dVector3 a2,
01341             const dVector3 b1, const dVector3 b2,
01342             dVector3 cp1, dVector3 cp2);
01343 
01344 ODE_API int dBoxTouchesBox (const dVector3 _p1, const dMatrix3 R1,
01345           const dVector3 side1, const dVector3 _p2,
01346           const dMatrix3 R2, const dVector3 side2);
01347 
01348 // The meaning of flags parameter is the same as in dCollide()
01349 ODE_API int dBoxBox (const dVector3 p1, const dMatrix3 R1,
01350         const dVector3 side1, const dVector3 p2,
01351         const dMatrix3 R2, const dVector3 side2,
01352         dVector3 normal, dReal *depth, int *return_code,
01353         int flags, dContactGeom *contact, int skip);
01354 
01355 ODE_API void dInfiniteAABB (dGeomID geom, dReal aabb[6]);
01356 ODE_API void dInitODE(void);
01357 ODE_API void dCloseODE(void);
01358 
01359 /* ************************************************************************ */
01360 /* custom classes */
01361 
01362 typedef void dGetAABBFn (dGeomID, dReal aabb[6]);
01363 typedef int dColliderFn (dGeomID o1, dGeomID o2,
01364           int flags, dContactGeom *contact, int skip);
01365 typedef dColliderFn * dGetColliderFnFn (int num);
01366 typedef void dGeomDtorFn (dGeomID o);
01367 typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]);
01368 
01369 typedef struct dGeomClass {
01370   int bytes;
01371   dGetColliderFnFn *collider;
01372   dGetAABBFn *aabb;
01373   dAABBTestFn *aabb_test;
01374   dGeomDtorFn *dtor;
01375 } dGeomClass;
01376 
01377 ODE_API int dCreateGeomClass (const dGeomClass *classptr);
01378 ODE_API void * dGeomGetClassData (dGeomID);
01379 ODE_API dGeomID dCreateGeom (int classnum);
01380 
01381 /* ************************************************************************ */
01382 
01383 #ifdef __cplusplus
01384 }
01385 #endif
01386 
01387 #endif

Generated on Sun Dec 2 22:00:27 2007 for Open Dynamics Engine by  doxygen 1.3.9.1