1 /*************************************************************************
3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
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 *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
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. *
21 *************************************************************************/
25 the standard ODE geometry primitives.
29 #ifndef _ODE_COLLISION_STD_H_
30 #define _ODE_COLLISION_STD_H_
33 #include <ode/common.h>
34 #include "collision_kernel.h"
37 // primitive collision functions - these have the dColliderFn interface, i.e.
38 // the same interface as dCollide(). the first and second geom arguments must
39 // have the specified types.
41 int dCollideSphereSphere (dxGeom
*o1
, dxGeom
*o2
, int flags
,
42 dContactGeom
*contact
, int skip
);
43 int dCollideSphereBox (dxGeom
*o1
, dxGeom
*o2
, int flags
,
44 dContactGeom
*contact
, int skip
);
45 int dCollideSpherePlane (dxGeom
*o1
, dxGeom
*o2
, int flags
,
46 dContactGeom
*contact
, int skip
);
47 int dCollideBoxBox (dxGeom
*o1
, dxGeom
*o2
, int flags
,
48 dContactGeom
*contact
, int skip
);
49 int dCollideBoxPlane (dxGeom
*o1
, dxGeom
*o2
,
50 int flags
, dContactGeom
*contact
, int skip
);
51 int dCollideCapsuleSphere (dxGeom
*o1
, dxGeom
*o2
, int flags
,
52 dContactGeom
*contact
, int skip
);
53 int dCollideCapsuleBox (dxGeom
*o1
, dxGeom
*o2
, int flags
,
54 dContactGeom
*contact
, int skip
);
55 int dCollideCapsuleCapsule (dxGeom
*o1
, dxGeom
*o2
,
56 int flags
, dContactGeom
*contact
, int skip
);
57 int dCollideCapsulePlane (dxGeom
*o1
, dxGeom
*o2
, int flags
,
58 dContactGeom
*contact
, int skip
);
59 int dCollideRaySphere (dxGeom
*o1
, dxGeom
*o2
, int flags
,
60 dContactGeom
*contact
, int skip
);
61 int dCollideRayBox (dxGeom
*o1
, dxGeom
*o2
, int flags
,
62 dContactGeom
*contact
, int skip
);
63 int dCollideRayCapsule (dxGeom
*o1
, dxGeom
*o2
,
64 int flags
, dContactGeom
*contact
, int skip
);
65 int dCollideRayPlane (dxGeom
*o1
, dxGeom
*o2
, int flags
,
66 dContactGeom
*contact
, int skip
);
67 int dCollideRayCylinder (dxGeom
*o1
, dxGeom
*o2
, int flags
,
68 dContactGeom
*contact
, int skip
);
70 // Cylinder - Box/Sphere by (C) CroTeam
71 // Ported by Nguyen Binh
72 int dCollideCylinderBox(dxGeom
*o1
, dxGeom
*o2
,
73 int flags
, dContactGeom
*contact
, int skip
);
74 int dCollideCylinderSphere(dxGeom
*gCylinder
, dxGeom
*gSphere
,
75 int flags
, dContactGeom
*contact
, int skip
);
76 int dCollideCylinderPlane(dxGeom
*gCylinder
, dxGeom
*gPlane
,
77 int flags
, dContactGeom
*contact
, int skip
);
79 //--> Convex Collision
80 int dCollideConvexPlane (dxGeom
*o1
, dxGeom
*o2
, int flags
,
81 dContactGeom
*contact
, int skip
);
82 int dCollideSphereConvex (dxGeom
*o1
, dxGeom
*o2
, int flags
,
83 dContactGeom
*contact
, int skip
);
84 int dCollideConvexBox (dxGeom
*o1
, dxGeom
*o2
, int flags
,
85 dContactGeom
*contact
, int skip
);
86 int dCollideConvexCapsule (dxGeom
*o1
, dxGeom
*o2
,
87 int flags
, dContactGeom
*contact
, int skip
);
88 int dCollideConvexConvex (dxGeom
*o1
, dxGeom
*o2
, int flags
,
89 dContactGeom
*contact
, int skip
);
90 int dCollideRayConvex (dxGeom
*o1
, dxGeom
*o2
, int flags
,
91 dContactGeom
*contact
, int skip
);
92 //<-- Convex Collision
95 int dCollideHeightfield( dxGeom
*o1
, dxGeom
*o2
,
96 int flags
, dContactGeom
*contact
, int skip
);
98 //****************************************************************************
99 // the basic geometry objects
101 struct dxSphere
: public dxGeom
{
102 dReal radius
; // sphere radius
103 dxSphere (dSpaceID space
, dReal _radius
);
108 struct dxBox
: public dxGeom
{
109 dVector3 side
; // side lengths (x,y,z)
110 dxBox (dSpaceID space
, dReal lx
, dReal ly
, dReal lz
);
115 struct dxCapsule
: public dxGeom
{
116 dReal radius
,lz
; // radius, length along z axis
117 dxCapsule (dSpaceID space
, dReal _radius
, dReal _length
);
122 struct dxCylinder
: public dxGeom
{
123 dReal radius
,lz
; // radius, length along z axis
124 dxCylinder (dSpaceID space
, dReal _radius
, dReal _length
);
129 struct dxPlane
: public dxGeom
{
131 dxPlane (dSpaceID space
, dReal a
, dReal b
, dReal c
, dReal d
);
136 struct dxRay
: public dxGeom
{
138 dxRay (dSpaceID space
, dReal _length
);
142 typedef std::pair
<unsigned int,unsigned int> edge
; /*!< Used to descrive a convex hull edge, an edge is a pair or indices into the hull's points */
143 struct dxConvex
: public dxGeom
146 dReal
*planes
; /*!< An array of planes in the form:
147 normal X, normal Y, normal Z,Distance
149 dReal
*points
; /*!< An array of points X,Y,Z */
150 unsigned int *polygons
; /*! An array of indices to the points of each polygon, it should be the number of vertices followed by that amount of indices to "points" in counter clockwise order*/
151 unsigned int planecount
; /*!< Amount of planes in planes */
152 unsigned int pointcount
;/*!< Amount of points in points */
153 dReal saabb
[6];/*!< Static AABB */
154 std::set
<edge
> edges
;
155 dxConvex(dSpaceID space
,
157 unsigned int planecount
,
159 unsigned int pointcount
,
160 unsigned int *polygons
);
163 //fprintf(stdout,"dxConvex Destroy\n");
167 // For Internal Use Only