 Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki Blog Search Turing Chat Room Members
Triangle - Triangle Intersection/Collision Detection       Author Message
ncvitak  Posted: Wed Jun 05, 2013 9:28 pm   Post subject: Triangle - Triangle Intersection/Collision Detection

I am working on a game, and I am going to use triangle - triangle collision detection, since all 3d meshes are made out of triangles. However I can't seem to find out how to do it. Please help me if you can. Thanks!

I have the following:

// Vector3f: a class i created to represent a 3D vector with public numeric variables x,y,z

class Vector3f {
public:
float x;
float y;
float z;

//additional operator overloads for vector3f - vector3f, or vector3f - scalar operations
//Ex: +, -, *, /, etc...

};

Vector3f Tri1; //3 Verticies, which can be interpreted as 3D vectors for Triangle 1
Vector3f Tri2; //3 Verticies, which can be interpreted as 3D vectors for Triangle 2

bool TriangleTriangleCollisionDetected(Vector3f T1, Vector3f T2) {
//code to check if the 2 triangles intersect
//returns true if the intersect
//returns false if they do not intersect
}    Insectoid  Posted: Wed Jun 05, 2013 9:55 pm   Post subject: RE:Triangle - Triangle Intersection/Collision Detection

I was reading through this StackOverflow thread, which has a good solution, but then I got to the bottom and it links to this thread on compsci.ca.

Basically, you need to check all the lines against each other to see if they intersect, and if they don't, then check to see if any corner is inside the other triangle. If they aren't, then they haven't collided. Otherwise, they have. Tony  Posted: Wed Jun 05, 2013 11:01 pm   Post subject: Re: Triangle - Triangle Intersection/Collision Detection

ncvitak @ Wed Jun 05, 2013 9:28 pm wrote:
I am going to use triangle - triangle collision detection, since all 3d meshes are made out of triangles.

What happens when the two triangles are not in the same plane? http://stackoverflow.com/questions/7113344/find-whether-two-triangles-intersect-or-not

Of course this doesn't cover the case where one object is completely inside of another. Are they in a state of collision? Tony's programming blog. DWITE - a programming contest. ncvitak  Posted: Sat Jun 08, 2013 4:42 pm   Post subject: Re: Triangle - Triangle Intersection/Collision Detection

I was able to find this C source code
for the following document online         