Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

collision.h

Go to the documentation of this file.
00001 // Collision detection routines and helper functions 
00002 // (by Alan Baylis 2001, Adapted from the work of Kasper Fauerby - aka Telemachos)
00003 
00004 #ifndef COLLISION_H
00005 #define COLLISION_H
00006 
00007 #include "vector.h"
00008 #include "polygon.h"
00009 #include "shared.h"
00010 #include "locmath.h"
00011 
00012 extern float radian;
00013 extern float pi;
00014 extern float epsilon;
00015 
00016 struct CollisionPacket
00017 {
00018   // data about player movement
00019  VECTOR velocity;
00020  VECTOR sourcePoint;
00021   
00022  // radius of ellipsoid.  
00023  VECTOR eRadius; 
00024   
00025  // for error handling  
00026  VECTOR lastSafePosition;
00027  bool stuck; 
00028     
00029  // data for collision response 
00030  bool foundCollision;
00031  float    nearestDistance; // nearest distance to hit
00032  VECTOR nearestSphereIntersectionPoint; // on sphere
00033  VECTOR nearestPolygonIntersectionPoint; // on polygon
00034 };
00035 
00036 void SetLength(VECTOR& v, float l);
00037 bool IsZeroVector(VECTOR& v);
00038 VECTOR Wedge(VECTOR v1, VECTOR v2);
00039 float IntersectRayPlane(VECTOR rOrigin, VECTOR rVector, VECTOR pOrigin, VECTOR pNormal);
00040 float IntersectRaySphere(VECTOR rO, VECTOR rV, VECTOR sO, float sR);
00041 bool CheckPointInTriangle(VECTOR point, VECTOR a, VECTOR b, VECTOR c);
00042 VECTOR ClosestPointOnLine(VECTOR& a, VECTOR& b, VECTOR& p);
00043 VECTOR ClosestPointOnPolygon(VECTOR a, VECTOR c, VECTOR b, VECTOR p);
00044 bool CheckPointInSphere(VECTOR point, VECTOR sO, float sR);
00045 VECTOR TangentPlaneNormalOfEllipsoid(VECTOR point, VECTOR eO, VECTOR eR);
00046 int ClassifyPoint(VECTOR point, VECTOR pO, VECTOR pN);
00047 void CheckForCollision(POLYGON* polygon, VECTOR* destination, CollisionPacket* colPackage);
00048 
00049 #endif

Generated on Fri Dec 23 05:20:17 2005 for Portals by doxygen1.2.15