Archived

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

obj63

Collision detection with polygons.

Recommended Posts

obj63    122
after looking through nehe''s tutorials and learning a ton on opengl, I want to know how I can detect a collision of my character (the translate location), and the walls of a 3d world. I am bassing this collision detection to go with nehe''s 10th tutorial. I want my character to not move past the walls like in most first person shooters, I also need help on how I can make other things not go past the walls like other characters I am looking at, at first they will be 2d but soon to be 3d. thanks for all help I truely appreciate it joe

Share this post


Link to post
Share on other sites
obj63    122
thanks I actually found theirs yesterday, I am looking at them and they look great, but in the code I understand what they are doing but I don''t understand why. I know the math find dot product, normalize, cross product ... but why is it done and how does that help check the collision. Are there any other tutorials out there that explain more

thanks

Share this post


Link to post
Share on other sites
Crispy    556
If you want something better, Google for Fluid Studios and look around on their web site. They have two CD tuts out one with source code (software rendered) and one with no source code.

Share this post


Link to post
Share on other sites
uber_n00b    122
That question is more complex than you might think. Here is what each action does in a nutshell by definition. Taking the cross product of two vectors which are the sides of polygons will return a vector that is perpendicular to both, and since it is impossible on a plane to return a vector perpendicular to two non-parallel vectors, the result is the normal to the polygon's plane in three dimensions. This normal will be used to calculate the shortest distance between the vector of the camera (same thing as its position really) and the vector collection that is the polygon. The dot product, by definition, returns the shortest distance of two vectors along the normal of one of them (its not really necessary to know which one). We take the dot product of the polygon's plane equation in ax+by+cz+d form and the camera's position (both in three dimensions obviously) to find the shortest distance between the two. Collision detection is merely checking to see if the dot product of the two previously mentioned objects is a certain value or below. Did that make any more sense? You may have to do some serious sleuthing to find an answer more exact than that. Most of the sites I went to when I was first learning collision detection were insanely confusing, so I eventually found the answers in a calculus textbook towards the back =(. Anyways good luck with your search.

[edited by - uber_n00b on August 13, 2003 3:42:40 PM]

Share this post


Link to post
Share on other sites
obj63    122
thanks uber that makes perfect sense. I just had no idea why they where taking the cross, and dot products and other things. They just said do this then do that and then if this collision, but they never said why I think more tutorials need to look into this because if you teach a person what to do that is a good step, but they have to know why first, cause if they don''t know why they won''t be able to adapt it to other situations.

Share this post


Link to post
Share on other sites