Figuring Collisions Between Lines and Faces/Planes - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Design (/forum-5.html)
+--- Thread: Figuring Collisions Between Lines and Faces/Planes (/thread-5839.html)
Figuring Collisions Between Lines and Faces/Planes - Nick - Feb 24, 2005 03:38 PM
I would like to have some people assist me in understanding this sort of math. I've looked at page after page of 3d math equations but all I can pull from it are obscure Greek symbols and confusion.
With my own setup, I have a beginning point and a directional vector for the line. I have coordinates of vertices of the faces I wish to check it against. I also have the normals for the faces so I could theoretically check the line against an infinitely large plane and get the coordinates and check those against the face.
Can anyone assist me at all? Sample code? Words of advice? Good websites? Prayers ?
Figuring Collisions Between Lines and Faces/Planes - reubert - Feb 24, 2005 03:47 PM
if at all possible, use ODE or something similar. Working it all out yourself is no fun IMHO, and someone else has already done it
Otherwise, check out http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=30 and have a look at the text and code snippet on that page in the paragraph Ray - Plane Intersection Detection. Worked for me with a little trial and error.
Figuring Collisions Between Lines and Faces/Planes - Nick - Feb 24, 2005 03:58 PM
I though about ODE but couldn't find the Mac "version". I remember some one here posting about it but I can't find it (searching for ODE doesn't work). I'd love to at least try it.
I'll give NeHe a look sometime as well. Thanks.
Figuring Collisions Between Lines and Faces/Planes - reubert - Feb 24, 2005 04:04 PM
you will need to build the library by following the instructions in INSTALL. Then find some example code that does something similar to what you want, copy and paste, #include <ode/ode.h> and you're away laughing.
Figuring Collisions Between Lines and Faces/Planes - MarkJ - Feb 24, 2005 04:08 PM
This is a very nice ray/triangle intersection algorithm, and it is what I have been using for collision detection in my latest game.
Figuring Collisions Between Lines and Faces/Planes - Nick - Feb 27, 2005 07:01 AM
Here's something I found online about this:
Figuring Collisions Between Lines and Faces/Planes - MarkJ - Feb 27, 2005 12:52 PM
Nick, did you look at that Trumbore97 algorithm? The C implementation for it is right here. All you need to do is split the poly faces you want to check against into triangles Then you pass in the coordinates of the triangle vertices, the point you want to check against, and its normal. The function will give you back the distance from the point to the triangle, so it makes collision detection very simple.
Figuring Collisions Between Lines and Faces/Planes - Nick - Feb 27, 2005 02:29 PM
Unfortunately I need to test the line because I have a seemingly infinite amount of points to check. I don't have a point to check against the triangle. I have a line 1000 units in length (I had to assign a number to help make some things work, i.e. I couldn't just have a origin and direction making a line 1 unit in length) so checking points along the line is a daunting task. That is why I'm working on something like this.
I do, however, have a new idea for checking collisions that should be interesting if I can get it to work properly.
Figuring Collisions Between Lines and Faces/Planes - Nick - Mar 2, 2005 08:17 PM
Here's my setup after looking at two websites and NeHe for ideas on collisions. I just wrote this up but it doesn't quite work as it should. The comments should help explain everything. Technically I left out the part that sees if the point of collision is simply on the plane or actually on the face of the box but I just wanted to see the collisions with the planes work but it doesn't. I'm not sure why. Any ideas or suggestions (besides using someone else's code)?