I am working on collision detection for a custom game engine.
It has the following basic classes: (simplified to show only the relavent bits)
class Vector3
{
float X;
float Y;
float Z;
};
class AABoxClass
{
Vector3 Center;
Vector3 Extent;
};
class TriClass
{
const Vector3 *N;
const Vector3 *V[3];
};
struct CastResultStruct
{
bool StartBad; // was the inital configuration interpenetrating something?
float Fraction; // fraction of the move up until collision
Vector3 Normal; // surface normal at the collision point
};
I need to create a function that looks like this.
bool Collide(const AABoxClass & box,const Vector3 & move,const TriClass & tri,CastResultStruct * result)
i.e. it collides a moving AABox against a triangle and returns a bool for whether it collided or not plus the 3 items in CastResultStruct.
Can anyone point me in the right direction on how to do this? I searched all over the internet and all over gamedev.net and elsewhere and cant find any kind of example of how to do this (I found a couple pointers to how to do it if all you care about is the "did these objects collide" flag and not the actual collision information but nothing on how to calculate the actual collision information (i.e. CastResultStruct above)