Collision Detection...

Started by
2 comments, last by iNsAn1tY 22 years, 4 months ago
Hi. I''m writing a 3D engine, and everything was going OK, until the other day. It''s my first attempt, and I haven''t written any collision detection code before. I''ve researched some different ways of doing it, and I''m using the dot product system, whereby you calculate to see if the player has passed a plane, so if the point is in the halfspace behind all the hyperplanes, it''s inside the object. But I''m having a problem with the formula: DotProduct(Polygon.Normal, Player.Position) + Plane.Distance I can''t calculate the minimum distance of the plane the triangular polygon lies on from the origin. I have managed to do it with polygons in the three major axes, x, y and z, but not with any others. I think I have to calculate the plane equation from the points of the polygon, and then I can find the minimum distance, but I''m not sure how to do this...can anyone help? I got the method above from http://www.flipcode.com/tutorials/tut_collision.shtml, if you want some clarification on what I''m talking about. The above formula is about 1/4 of the way down the page...
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Advertisement
An easier way to do this is as follows:

// assume that v1 is a vertex in your polygon
DotProduct(Polygon.Normal, Player.Position - v1);

If the dot product is negative, the player is "inside" the halfspace.

FragLegs
Thank you, thank you, thank you! Now, I can finish my collision detection, and start on the physics!
That was me, by the way, I forgot to sign in, damn it...
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

This topic is closed to new replies.

Advertisement