1 | /*************************************************************************
|
---|
2 | * *
|
---|
3 | * Open Dynamics Engine, Copyright (C) 2001-2003 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 | #ifndef _ODE_COLLISION_H_
|
---|
24 | #define _ODE_COLLISION_H_
|
---|
25 |
|
---|
26 | #include <ode/common.h>
|
---|
27 | #include <ode/collision_space.h>
|
---|
28 | #include <ode/contact.h>
|
---|
29 |
|
---|
30 | #ifdef __cplusplus
|
---|
31 | extern "C" {
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* ************************************************************************ */
|
---|
35 | /* general functions */
|
---|
36 |
|
---|
37 | void dGeomDestroy (dGeomID);
|
---|
38 | void dGeomSetData (dGeomID, void *);
|
---|
39 | void *dGeomGetData (dGeomID);
|
---|
40 | void dGeomSetBody (dGeomID, dBodyID);
|
---|
41 | dBodyID dGeomGetBody (dGeomID);
|
---|
42 | void dGeomSetPosition (dGeomID, dReal x, dReal y, dReal z);
|
---|
43 | void dGeomSetRotation (dGeomID, const dMatrix3 R);
|
---|
44 | void dGeomSetQuaternion (dGeomID, const dQuaternion);
|
---|
45 | const dReal * dGeomGetPosition (dGeomID);
|
---|
46 | const dReal * dGeomGetRotation (dGeomID);
|
---|
47 | void dGeomGetQuaternion (dGeomID, dQuaternion result);
|
---|
48 | void dGeomGetAABB (dGeomID, dReal aabb[6]);
|
---|
49 | int dGeomIsSpace (dGeomID);
|
---|
50 | dSpaceID dGeomGetSpace (dGeomID);
|
---|
51 | int dGeomGetClass (dGeomID);
|
---|
52 | void dGeomSetCategoryBits (dGeomID, unsigned long bits);
|
---|
53 | void dGeomSetCollideBits (dGeomID, unsigned long bits);
|
---|
54 | unsigned long dGeomGetCategoryBits (dGeomID);
|
---|
55 | unsigned long dGeomGetCollideBits (dGeomID);
|
---|
56 | void dGeomEnable (dGeomID);
|
---|
57 | void dGeomDisable (dGeomID);
|
---|
58 | int dGeomIsEnabled (dGeomID);
|
---|
59 |
|
---|
60 | /* ************************************************************************ */
|
---|
61 | /* collision detection */
|
---|
62 |
|
---|
63 | int dCollide (dGeomID o1, dGeomID o2, int flags, dContactGeom *contact,
|
---|
64 | int skip);
|
---|
65 | void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback);
|
---|
66 | void dSpaceCollide2 (dGeomID o1, dGeomID o2, void *data,
|
---|
67 | dNearCallback *callback);
|
---|
68 |
|
---|
69 | /* ************************************************************************ */
|
---|
70 | /* standard classes */
|
---|
71 |
|
---|
72 | /* the maximum number of user classes that are supported */
|
---|
73 | enum {
|
---|
74 | dMaxUserClasses = 4
|
---|
75 | };
|
---|
76 |
|
---|
77 | /* class numbers - each geometry object needs a unique number */
|
---|
78 | enum {
|
---|
79 | dSphereClass = 0,
|
---|
80 | dBoxClass,
|
---|
81 | dCCylinderClass,
|
---|
82 | dCylinderClass,
|
---|
83 | dPlaneClass,
|
---|
84 | dRayClass,
|
---|
85 | dGeomTransformClass,
|
---|
86 | dTriMeshClass,
|
---|
87 | // Terrain callback mod
|
---|
88 | dTerrainCallbackClass,
|
---|
89 |
|
---|
90 | dFirstSpaceClass,
|
---|
91 | dSimpleSpaceClass = dFirstSpaceClass,
|
---|
92 | dHashSpaceClass,
|
---|
93 | dQuadTreeSpaceClass,
|
---|
94 | dLastSpaceClass = dQuadTreeSpaceClass,
|
---|
95 |
|
---|
96 | dFirstUserClass,
|
---|
97 | dLastUserClass = dFirstUserClass + dMaxUserClasses - 1,
|
---|
98 | dGeomNumClasses
|
---|
99 | };
|
---|
100 |
|
---|
101 | // Terrain Callback mod (start)
|
---|
102 | typedef dReal dTerrainHeightCallback(void* data,dReal x,dReal z);
|
---|
103 |
|
---|
104 | dGeomID dCreateTerrainCallback (dSpaceID space, dReal *pHeights,dReal vHeight,dReal vLength,int nNumNodesPerSide, int bFinite, int bPlaceable);
|
---|
105 | dReal dGeomTerrainCallbackPointDepth (dGeomID g, dReal x, dReal y, dReal z);
|
---|
106 | void dGeomTerrainCallbackSetHeightCallback(dGeomID g,dTerrainHeightCallback* callback);
|
---|
107 | // Terrain Callback mod (end)
|
---|
108 |
|
---|
109 | dGeomID dCreateSphere (dSpaceID space, dReal radius);
|
---|
110 | void dGeomSphereSetRadius (dGeomID sphere, dReal radius);
|
---|
111 | dReal dGeomSphereGetRadius (dGeomID sphere);
|
---|
112 | dReal dGeomSpherePointDepth (dGeomID sphere, dReal x, dReal y, dReal z);
|
---|
113 |
|
---|
114 | dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
|
---|
115 | void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz);
|
---|
116 | void dGeomBoxGetLengths (dGeomID box, dVector3 result);
|
---|
117 | dReal dGeomBoxPointDepth (dGeomID box, dReal x, dReal y, dReal z);
|
---|
118 |
|
---|
119 | dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
|
---|
120 | void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d);
|
---|
121 | void dGeomPlaneGetParams (dGeomID plane, dVector4 result);
|
---|
122 | dReal dGeomPlanePointDepth (dGeomID plane, dReal x, dReal y, dReal z);
|
---|
123 |
|
---|
124 | dGeomID dCreateCCylinder (dSpaceID space, dReal radius, dReal length);
|
---|
125 | void dGeomCCylinderSetParams (dGeomID ccylinder, dReal radius, dReal length);
|
---|
126 | void dGeomCCylinderGetParams (dGeomID ccylinder, dReal *radius, dReal *length);
|
---|
127 | dReal dGeomCCylinderPointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);
|
---|
128 |
|
---|
129 | dGeomID dCreateRay (dSpaceID space, dReal length);
|
---|
130 | void dGeomRaySetLength (dGeomID ray, dReal length);
|
---|
131 | dReal dGeomRayGetLength (dGeomID ray);
|
---|
132 | void dGeomRaySet (dGeomID ray, dReal px, dReal py, dReal pz,
|
---|
133 | dReal dx, dReal dy, dReal dz);
|
---|
134 | void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir);
|
---|
135 |
|
---|
136 | /*
|
---|
137 | * Set/get ray flags that influence ray collision detection.
|
---|
138 | * These flags are currently only noticed by the trimesh collider, because
|
---|
139 | * they can make a major differences there.
|
---|
140 | */
|
---|
141 | void dGeomRaySetParams (dGeomID g, int FirstContact, int BackfaceCull);
|
---|
142 | void dGeomRayGetParams (dGeomID g, int *FirstContact, int *BackfaceCull);
|
---|
143 | void dGeomRaySetClosestHit (dGeomID g, int closestHit);
|
---|
144 | int dGeomRayGetClosestHit (dGeomID g);
|
---|
145 |
|
---|
146 | #include "collision_trimesh.h"
|
---|
147 |
|
---|
148 | dGeomID dCreateGeomTransform (dSpaceID space);
|
---|
149 | void dGeomTransformSetGeom (dGeomID g, dGeomID obj);
|
---|
150 | dGeomID dGeomTransformGetGeom (dGeomID g);
|
---|
151 | void dGeomTransformSetCleanup (dGeomID g, int mode);
|
---|
152 | int dGeomTransformGetCleanup (dGeomID g);
|
---|
153 | void dGeomTransformSetInfo (dGeomID g, int mode);
|
---|
154 | int dGeomTransformGetInfo (dGeomID g);
|
---|
155 |
|
---|
156 | /* ************************************************************************ */
|
---|
157 | /* utility functions */
|
---|
158 |
|
---|
159 | void dClosestLineSegmentPoints (const dVector3 a1, const dVector3 a2,
|
---|
160 | const dVector3 b1, const dVector3 b2,
|
---|
161 | dVector3 cp1, dVector3 cp2);
|
---|
162 |
|
---|
163 | int dBoxTouchesBox (const dVector3 _p1, const dMatrix3 R1,
|
---|
164 | const dVector3 side1, const dVector3 _p2,
|
---|
165 | const dMatrix3 R2, const dVector3 side2);
|
---|
166 |
|
---|
167 | void dInfiniteAABB (dGeomID geom, dReal aabb[6]);
|
---|
168 | void dCloseODE();
|
---|
169 |
|
---|
170 | /* ************************************************************************ */
|
---|
171 | /* custom classes */
|
---|
172 |
|
---|
173 | typedef void dGetAABBFn (dGeomID, dReal aabb[6]);
|
---|
174 | typedef int dColliderFn (dGeomID o1, dGeomID o2,
|
---|
175 | int flags, dContactGeom *contact, int skip);
|
---|
176 | typedef dColliderFn * dGetColliderFnFn (int num);
|
---|
177 | typedef void dGeomDtorFn (dGeomID o);
|
---|
178 | typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]);
|
---|
179 |
|
---|
180 | typedef struct dGeomClass {
|
---|
181 | int bytes;
|
---|
182 | dGetColliderFnFn *collider;
|
---|
183 | dGetAABBFn *aabb;
|
---|
184 | dAABBTestFn *aabb_test;
|
---|
185 | dGeomDtorFn *dtor;
|
---|
186 | } dGeomClass;
|
---|
187 |
|
---|
188 | int dCreateGeomClass (const dGeomClass *classptr);
|
---|
189 | void * dGeomGetClassData (dGeomID);
|
---|
190 | dGeomID dCreateGeom (int classnum);
|
---|
191 |
|
---|
192 | /* ************************************************************************ */
|
---|
193 |
|
---|
194 | #ifdef __cplusplus
|
---|
195 | }
|
---|
196 | #endif
|
---|
197 |
|
---|
198 | #endif
|
---|