please answer :)

Started by
3 comments, last by hello_there 21 years, 3 months ago
can someone write me a few lines of code showing how to do collision detection using dot products and cross products. the collision detection like in the book open gl game programming. i want to write my own collision detection functions but can''t figure out exactly what i need to do. please?
____________________________________________________________How could hell be worse?
Advertisement
Well, I don''t have my own collision detection code handy, but there are tons of tutorials for simpler stuff on the internet.

For example:
http://www.gamasutra.com/features/20020118/vandenhuevel_01.htm
--Riley
Uhm... give us an example of the object pair(s) that you need to check collisions for... a lot of collision detection doesn''t even need dot/cross products (unless you consider Projection a use of Dot).
i'm checking against walls. i have an array of triangle data like so:

struct triangle
{
float point1[3];
float point2[3];
float point3[3];
};

triangle currentscene[10000];

don't know if that's a good way of doing it but it'll do for now.

after that i want a function that checks to see if you collide with the triangles. btw can you tell me how to check the distance from your position to the triangle so i don't have to check for collision if it to far away.

[edited by - hello_there on January 22, 2003 8:25:09 PM]

[edited by - hello_there on January 22, 2003 12:33:15 AM]
____________________________________________________________How could hell be worse?
Ahh... triangles vs. triangles. yes, I have seen dot and cross product used for that...

I believe the theory is that you find out where the 3 lines from one triangle intersect the plane of the other triangle, and then use dot products to see if any of those points are inside the second triangle.

And since I don''t remember the equations off the top of my head, I guess it''s google time!

Also, you probably don''t want to use a distance check to see if any triangle is too far away. What you want is a system where if you are on one side of a plane, then you don''t have to check any of the triangles on the other side... These are called BSPs, quadtrees or octtrees.

This topic is closed to new replies.

Advertisement