Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

hello_there

please answer :)

This topic is 5601 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!