home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / collision.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-06  |  1.6 KB  |  71 lines

  1. #ifndef __collision_h__
  2. #define __collision_h__
  3.  
  4. #include "vectormath.h"
  5. #include "Face.h"
  6. //#include "Vehicle.h"
  7. class Vehicle;
  8.  
  9. #include <vector>
  10. using namespace std;
  11.  
  12. class SpacePartitioningTreeNode;
  13.  
  14. typedef struct AABB_s{
  15.     vec3_t min, max;
  16. }AABB_t;
  17.  
  18.  
  19. #define COLLISION_FLAG_NONE                0x0000
  20. #define COLLISION_FLAG_SHOOT_THROUGH    0x0001
  21. #define COLLISION_FLAG_WALK_THROUGH        0x0002
  22. #define COLLISION_FLAG_ARENA            0x0004
  23. #define COLLISION_FLAG_VEHICLES            0x0008
  24. #define COLLISION_FLAG_BACKFACES        0x0010
  25. #define COLLISION_FLAG_SUBSEQUENT_HITS    0x0020
  26.  
  27. enum traceTypes_e{
  28.     TRACE_TYPE_RAY=0,
  29.     TRACE_TYPE_LINE_SEGMENT,
  30.     TRACE_TYPE_AABB,
  31.  
  32.     NUM_TRACE_TYPES
  33. };
  34.  
  35. typedef struct hit_s{
  36.     vec3_t pos;
  37.     float distance;
  38.      SpacePartitioningTreeNode* node;
  39.     Face* face;
  40.     Vehicle* vehicle;
  41. }hit_t;
  42.  
  43. typedef struct trace_s{
  44.     int traceType;
  45.     vec3_t startPos;
  46.     vec3_t dir;
  47.     vec3_t endPos;
  48.     vec3_t min, max;
  49.     unsigned int ignoreFlags;
  50.  
  51.     vector<hit_t> hits;
  52. }trace_t;
  53.  
  54.  
  55.  
  56. bool rayIntersectsFace(vec3_t pos, vec3_t dir, Face* face, float* distance, vec3_t hitpoint);
  57. bool linesegmentIntersectsFace(vec3_t pos1, vec3_t pos2, Face* face, float* distance, vec3_t hitpoint);
  58.  
  59.  
  60. void traceRay(vec3_t startPos, vec3_t dir, trace_t* trace);
  61. void traceLinesegment(vec3_t pos1, vec3_t pos2, trace_t* trace);
  62. void traceAABB(vec3_t pos1, vec3_t pos2, AABB_t, trace_t* trace);
  63.  
  64. //void castRay();
  65. //void renderDebugStuff();
  66.  
  67. //void collisionDetection(Mech* mech, int deltaT);
  68. //void collisionDetection(Camera* cam, int deltaT);    // als member
  69.  
  70. #endif    /* __collision_h__ */
  71.