00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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
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
00622
00623
00624
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
00747
00748
00749 enum {
00750 dMaxUserClasses = 4
00751 };
00752
00753
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 dQuadTreeSpaceClass,
00770 dLastSpaceClass = dQuadTreeSpaceClass,
00771
00772 dFirstUserClass,
00773 dLastUserClass = dFirstUserClass + dMaxUserClasses - 1,
00774 dGeomNumClasses
00775 };
00776
00777
00797 ODE_API dGeomID dCreateSphere (dSpaceID space, dReal radius);
00798
00799
00809 ODE_API void dGeomSphereSetRadius (dGeomID sphere, dReal radius);
00810
00811
00820 ODE_API dReal dGeomSphereGetRadius (dGeomID sphere);
00821
00822
00837 ODE_API dReal dGeomSpherePointDepth (dGeomID sphere, dReal x, dReal y, dReal z);
00838
00839
00840
00841 ODE_API dGeomID dCreateConvex (dSpaceID space,
00842 dReal *_planes,
00843 unsigned int _planecount,
00844 dReal *_points,
00845 unsigned int _pointcount,unsigned int *_polygons);
00846
00847 ODE_API void dGeomSetConvex (dGeomID g,
00848 dReal *_planes,
00849 unsigned int _count,
00850 dReal *_points,
00851 unsigned int _pointcount,unsigned int *_polygons);
00852
00853
00875 ODE_API dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
00876
00877
00889 ODE_API void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz);
00890
00891
00901 ODE_API void dGeomBoxGetLengths (dGeomID box, dVector3 result);
00902
00903
00916 ODE_API dReal dGeomBoxPointDepth (dGeomID box, dReal x, dReal y, dReal z);
00917
00918
00919 ODE_API dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
00920 ODE_API void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d);
00921 ODE_API void dGeomPlaneGetParams (dGeomID plane, dVector4 result);
00922 ODE_API dReal dGeomPlanePointDepth (dGeomID plane, dReal x, dReal y, dReal z);
00923
00924 ODE_API dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length);
00925 ODE_API void dGeomCapsuleSetParams (dGeomID ccylinder, dReal radius, dReal length);
00926 ODE_API void dGeomCapsuleGetParams (dGeomID ccylinder, dReal *radius, dReal *length);
00927 ODE_API dReal dGeomCapsulePointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);
00928
00929
00930 #define dCreateCCylinder dCreateCapsule
00931 #define dGeomCCylinderSetParams dGeomCapsuleSetParams
00932 #define dGeomCCylinderGetParams dGeomCapsuleGetParams
00933 #define dGeomCCylinderPointDepth dGeomCapsulePointDepth
00934 #define dCCylinderClass dCapsuleClass
00935
00936 ODE_API dGeomID dCreateCylinder (dSpaceID space, dReal radius, dReal length);
00937 ODE_API void dGeomCylinderSetParams (dGeomID cylinder, dReal radius, dReal length);
00938 ODE_API void dGeomCylinderGetParams (dGeomID cylinder, dReal *radius, dReal *length);
00939
00940 ODE_API dGeomID dCreateRay (dSpaceID space, dReal length);
00941 ODE_API void dGeomRaySetLength (dGeomID ray, dReal length);
00942 ODE_API dReal dGeomRayGetLength (dGeomID ray);
00943 ODE_API void dGeomRaySet (dGeomID ray, dReal px, dReal py, dReal pz,
00944 dReal dx, dReal dy, dReal dz);
00945 ODE_API void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir);
00946
00947
00948
00949
00950
00951
00952 ODE_API void dGeomRaySetParams (dGeomID g, int FirstContact, int BackfaceCull);
00953 ODE_API void dGeomRayGetParams (dGeomID g, int *FirstContact, int *BackfaceCull);
00954 ODE_API void dGeomRaySetClosestHit (dGeomID g, int closestHit);
00955 ODE_API int dGeomRayGetClosestHit (dGeomID g);
00956
00957 #include "collision_trimesh.h"
00958
00959 ODE_API dGeomID dCreateGeomTransform (dSpaceID space);
00960 ODE_API void dGeomTransformSetGeom (dGeomID g, dGeomID obj);
00961 ODE_API dGeomID dGeomTransformGetGeom (dGeomID g);
00962 ODE_API void dGeomTransformSetCleanup (dGeomID g, int mode);
00963 ODE_API int dGeomTransformGetCleanup (dGeomID g);
00964 ODE_API void dGeomTransformSetInfo (dGeomID g, int mode);
00965 ODE_API int dGeomTransformGetInfo (dGeomID g);
00966
00967
00968
00969
00970
00971
00972
00973 struct dxHeightfieldData;
00974 typedef struct dxHeightfieldData* dHeightfieldDataID;
00975
00976
00994 typedef dReal dHeightfieldGetHeight( void* p_user_data, int x, int z );
00995
00996
00997
01017 ODE_API dGeomID dCreateHeightfield( dSpaceID space,
01018 dHeightfieldDataID data, int bPlaceable );
01019
01020
01033 ODE_API dHeightfieldDataID dGeomHeightfieldDataCreate();
01034
01035
01044 ODE_API void dGeomHeightfieldDataDestroy( dHeightfieldDataID d );
01045
01046
01047
01088 ODE_API void dGeomHeightfieldDataBuildCallback( dHeightfieldDataID d,
01089 void* pUserData, dHeightfieldGetHeight* pCallback,
01090 dReal width, dReal depth, int widthSamples, int depthSamples,
01091 dReal scale, dReal offset, dReal thickness, int bWrap );
01092
01136 ODE_API void dGeomHeightfieldDataBuildByte( dHeightfieldDataID d,
01137 const unsigned char* pHeightData, int bCopyHeightData,
01138 dReal width, dReal depth, int widthSamples, int depthSamples,
01139 dReal scale, dReal offset, dReal thickness, int bWrap );
01140
01184 ODE_API void dGeomHeightfieldDataBuildShort( dHeightfieldDataID d,
01185 const short* pHeightData, int bCopyHeightData,
01186 dReal width, dReal depth, int widthSamples, int depthSamples,
01187 dReal scale, dReal offset, dReal thickness, int bWrap );
01188
01234 ODE_API void dGeomHeightfieldDataBuildSingle( dHeightfieldDataID d,
01235 const float* pHeightData, int bCopyHeightData,
01236 dReal width, dReal depth, int widthSamples, int depthSamples,
01237 dReal scale, dReal offset, dReal thickness, int bWrap );
01238
01284 ODE_API void dGeomHeightfieldDataBuildDouble( dHeightfieldDataID d,
01285 const double* pHeightData, int bCopyHeightData,
01286 dReal width, dReal depth, int widthSamples, int depthSamples,
01287 dReal scale, dReal offset, dReal thickness, int bWrap );
01288
01306 ODE_API void dGeomHeightfieldDataSetBounds( dHeightfieldDataID d,
01307 dReal minHeight, dReal maxHeight );
01308
01309
01320 ODE_API void dGeomHeightfieldSetHeightfieldData( dGeomID g, dHeightfieldDataID d );
01321
01322
01332 ODE_API dHeightfieldDataID dGeomHeightfieldGetHeightfieldData( dGeomID g );
01333
01334
01335
01336
01337
01338
01339 ODE_API void dClosestLineSegmentPoints (const dVector3 a1, const dVector3 a2,
01340 const dVector3 b1, const dVector3 b2,
01341 dVector3 cp1, dVector3 cp2);
01342
01343 ODE_API int dBoxTouchesBox (const dVector3 _p1, const dMatrix3 R1,
01344 const dVector3 side1, const dVector3 _p2,
01345 const dMatrix3 R2, const dVector3 side2);
01346
01347
01348 ODE_API int dBoxBox (const dVector3 p1, const dMatrix3 R1,
01349 const dVector3 side1, const dVector3 p2,
01350 const dMatrix3 R2, const dVector3 side2,
01351 dVector3 normal, dReal *depth, int *return_code,
01352 int flags, dContactGeom *contact, int skip);
01353
01354 ODE_API void dInfiniteAABB (dGeomID geom, dReal aabb[6]);
01355 ODE_API void dInitODE(void);
01356 ODE_API void dCloseODE(void);
01357
01358
01359
01360
01361 typedef void dGetAABBFn (dGeomID, dReal aabb[6]);
01362 typedef int dColliderFn (dGeomID o1, dGeomID o2,
01363 int flags, dContactGeom *contact, int skip);
01364 typedef dColliderFn * dGetColliderFnFn (int num);
01365 typedef void dGeomDtorFn (dGeomID o);
01366 typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]);
01367
01368 typedef struct dGeomClass {
01369 int bytes;
01370 dGetColliderFnFn *collider;
01371 dGetAABBFn *aabb;
01372 dAABBTestFn *aabb_test;
01373 dGeomDtorFn *dtor;
01374 } dGeomClass;
01375
01376 ODE_API int dCreateGeomClass (const dGeomClass *classptr);
01377 ODE_API void * dGeomGetClassData (dGeomID);
01378 ODE_API dGeomID dCreateGeom (int classnum);
01379
01380
01381
01382 #ifdef __cplusplus
01383 }
01384 #endif
01385
01386 #endif