ode/inc/collision_std.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*************************************************************************
       
     2  *                                                                       *
       
     3  * Open Dynamics Engine, Copyright (C) 2001,2002 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 /*
       
    24 
       
    25 the standard ODE geometry primitives.
       
    26 
       
    27 */
       
    28 
       
    29 #ifndef _ODE_COLLISION_STD_H_
       
    30 #define _ODE_COLLISION_STD_H_
       
    31 
       
    32 //#include <set>
       
    33 #include <ode/common.h>
       
    34 #include "collision_kernel.h"
       
    35 #include "set.h"
       
    36 
       
    37 
       
    38 // primitive collision functions - these have the dColliderFn interface, i.e.
       
    39 // the same interface as dCollide(). the first and second geom arguments must
       
    40 // have the specified types.
       
    41 
       
    42 int dCollideSphereSphere (dxGeom *o1, dxGeom *o2, int flags,
       
    43 			  dContactGeom *contact, int skip);
       
    44 int dCollideSphereBox (dxGeom *o1, dxGeom *o2, int flags,
       
    45 		       dContactGeom *contact, int skip);
       
    46 int dCollideSpherePlane (dxGeom *o1, dxGeom *o2, int flags,
       
    47 			 dContactGeom *contact, int skip);
       
    48 int dCollideBoxBox (dxGeom *o1, dxGeom *o2, int flags,
       
    49 		    dContactGeom *contact, int skip);
       
    50 int dCollideBoxPlane (dxGeom *o1, dxGeom *o2,
       
    51 		      int flags, dContactGeom *contact, int skip);
       
    52 int dCollideCapsuleSphere (dxGeom *o1, dxGeom *o2, int flags,
       
    53 			     dContactGeom *contact, int skip);
       
    54 int dCollideCapsuleBox (dxGeom *o1, dxGeom *o2, int flags,
       
    55 			  dContactGeom *contact, int skip);
       
    56 int dCollideCapsuleCapsule (dxGeom *o1, dxGeom *o2,
       
    57 				int flags, dContactGeom *contact, int skip);
       
    58 int dCollideCapsulePlane (dxGeom *o1, dxGeom *o2, int flags,
       
    59 			    dContactGeom *contact, int skip);
       
    60 int dCollideRaySphere (dxGeom *o1, dxGeom *o2, int flags,
       
    61 		       dContactGeom *contact, int skip);
       
    62 int dCollideRayBox (dxGeom *o1, dxGeom *o2, int flags,
       
    63 		    dContactGeom *contact, int skip);
       
    64 int dCollideRayCapsule (dxGeom *o1, dxGeom *o2,
       
    65 			  int flags, dContactGeom *contact, int skip);
       
    66 int dCollideRayPlane (dxGeom *o1, dxGeom *o2, int flags,
       
    67 		      dContactGeom *contact, int skip);
       
    68 int dCollideRayCylinder (dxGeom *o1, dxGeom *o2, int flags,
       
    69 		      dContactGeom *contact, int skip);
       
    70 
       
    71 // Cylinder - Box/Sphere by (C) CroTeam
       
    72 // Ported by Nguyen Binh
       
    73 int dCollideCylinderBox(dxGeom *o1, dxGeom *o2, 
       
    74                         int flags, dContactGeom *contact, int skip);
       
    75 int dCollideCylinderSphere(dxGeom *gCylinder, dxGeom *gSphere, 
       
    76                            int flags, dContactGeom *contact, int skip); 
       
    77 int dCollideCylinderPlane(dxGeom *gCylinder, dxGeom *gPlane, 
       
    78                            int flags, dContactGeom *contact, int skip); 
       
    79 
       
    80 //--> Convex Collision
       
    81 int dCollideConvexPlane (dxGeom *o1, dxGeom *o2, int flags,
       
    82 			 dContactGeom *contact, int skip);
       
    83 int dCollideSphereConvex (dxGeom *o1, dxGeom *o2, int flags,
       
    84 			  dContactGeom *contact, int skip);
       
    85 int dCollideConvexBox (dxGeom *o1, dxGeom *o2, int flags,
       
    86 		       dContactGeom *contact, int skip);
       
    87 int dCollideConvexCapsule (dxGeom *o1, dxGeom *o2,
       
    88 			   int flags, dContactGeom *contact, int skip);
       
    89 int dCollideConvexConvex (dxGeom *o1, dxGeom *o2, int flags, 
       
    90 			  dContactGeom *contact, int skip);
       
    91 int dCollideRayConvex (dxGeom *o1, dxGeom *o2, int flags, 
       
    92 		       dContactGeom *contact, int skip);
       
    93 //<-- Convex Collision
       
    94 
       
    95 // dHeightfield
       
    96 int dCollideHeightfield( dxGeom *o1, dxGeom *o2, 
       
    97 						 int flags, dContactGeom *contact, int skip );
       
    98 
       
    99 //****************************************************************************
       
   100 // the basic geometry objects
       
   101 
       
   102 struct dxSphere : public dxGeom {
       
   103   dReal radius;		// sphere radius
       
   104   dxSphere (dSpaceID space, dReal _radius);
       
   105   void computeAABB();
       
   106 };
       
   107 
       
   108 
       
   109 struct dxBox : public dxGeom {
       
   110   dVector3 side;	// side lengths (x,y,z)
       
   111   dxBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
       
   112   void computeAABB();
       
   113 };
       
   114 
       
   115 
       
   116 struct dxCapsule : public dxGeom {
       
   117   dReal radius,lz;	// radius, length along z axis
       
   118   dxCapsule (dSpaceID space, dReal _radius, dReal _length);
       
   119   void computeAABB();
       
   120 };
       
   121 
       
   122 
       
   123 struct dxCylinder : public dxGeom {
       
   124         dReal radius,lz;        // radius, length along z axis
       
   125         dxCylinder (dSpaceID space, dReal _radius, dReal _length);
       
   126         void computeAABB();
       
   127 };
       
   128 
       
   129 
       
   130 struct dxPlane : public dxGeom {
       
   131   dReal p[4];
       
   132   dxPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
       
   133   void computeAABB();
       
   134 };
       
   135 
       
   136 
       
   137 struct dxRay : public dxGeom {
       
   138   dReal length;
       
   139   dxRay (dSpaceID space, dReal _length);
       
   140   void computeAABB();
       
   141 };
       
   142 
       
   143 //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 */
       
   144 struct dxConvex : public dxGeom 
       
   145 {
       
   146   
       
   147   dReal *planes; /*!< An array of planes in the form:
       
   148 		   normal X, normal Y, normal Z,Distance
       
   149 		 */
       
   150   dReal *points; /*!< An array of points X,Y,Z */  
       
   151   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*/
       
   152   unsigned int planecount; /*!< Amount of planes in planes */
       
   153   unsigned int pointcount;/*!< Amount of points in points */
       
   154   dReal saabb[6];/*!< AABB */
       
   155   //std::set<edge> edges;
       
   156   set* edges;
       
   157   
       
   158   dxConvex(dSpaceID space,
       
   159 	   dReal *planes,
       
   160 	   unsigned int planecount,
       
   161 	   dReal *points,
       
   162 	   unsigned int pointcount,
       
   163 	   unsigned int *polygons);
       
   164   ~dxConvex()
       
   165   {
       
   166     //fprintf(stdout,"dxConvex Destroy\n");
       
   167   }
       
   168   void computeAABB();
       
   169   private:
       
   170   // For Internal Use Only
       
   171   void FillEdges();
       
   172 };
       
   173 
       
   174 
       
   175 #endif