00001
00002
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
00019 VECTOR velocity;
00020 VECTOR sourcePoint;
00021
00022
00023 VECTOR eRadius;
00024
00025
00026 VECTOR lastSafePosition;
00027 bool stuck;
00028
00029
00030 bool foundCollision;
00031 float nearestDistance;
00032 VECTOR nearestSphereIntersectionPoint;
00033 VECTOR nearestTriangleIntersectionPoint;
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(VECTOR* destination, int num_polygons, POLYGON* polys, CollisionPacket* colPackage);
00048
00049 #endif