Jump to content
  • Advertisement
Sign in to follow this  
Pirosan

Collision Detection?

This topic is 4862 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

I'm looking for a way to detect when a vector collides with an object in my program. I could build lower polygon collision meshes, but i am not sure if there is an opengl mesh that supports collision detection (im only a week or so into opengl). i thought i could also just do box collision but i dont know how to do that when using vectors or rays, let alone having the box and the vector translated and rotated to their respected positions. What do you guys use for collision detection? A point in the right direction would really help. Cheers, Chris

Share this post


Link to post
Share on other sites
Advertisement
Hello Pirosan,
The only thing that OpenGL does is rendering, nothing more, nothing less.
It does not provide things such as collison detection.
And I can't help you with your questions about collison detection, because I just don't know.
Hylke

Share this post


Link to post
Share on other sites
There's actually some good info on this site:

http://www.gamedev.net/reference/articles/article736.asp

But, there are also some great commercial/open source libraries out there to do collision detection if you want to go that route. Most of the algorithms are very simple, they just have more complicated things that go on top of it (elasticity, angle of reflection, deformation, etc, force vectors, etc), but the gamedev link goes over the basics pretty well. Grab a college physics book and go over reflection and refraction; collisions follow a lot of the same rules, even if the percentages and such are different.

Hope that steers you in the right direction, ask if you need more help.

Share this post


Link to post
Share on other sites
Colision between a vector and a plane is pretty simple:
plane ABC is define by
A+uAB+B+vBC
a vector OP by
O+wOP
then intersection is given by resolving equation
A+uAB+B+vBC=O+wOP == A+uAB+B+vBC-O-wOP=0 or the system
uxAB+vxBC-wxOP=xO-xA-xB
uyAB+vyBC-wyOP=yO-yA-yB
uzAB+vzBC-wzOP=zO-zA-zB


put it in matrix form and you just have to resolve a simple
3*3 matrix M
MX=B
if plane is bounded ( triangle ) put constraint on u and v (0<u<1 and 0<v<1 )(and then u+v<1(I've forgotten that:)...this isn't a parallelogram) )
if vector is bounded ( segment ) put constraint on w ( 0<w<1 )

you'll notice you'll must give a tolerance on collision on the edge with a TETA(tiny float) in your constraints cause ther'are lake of precision due to approximations in computations


For more theory infos=> http://www.geometrictools.com/Books.html (see Books samples)

Sorry i will complete that post later when i will have more time

[Edited by - mp3butcher on July 26, 2005 2:45:08 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by mp3butcher
Colision between a vector and a plane is pretty simple:
plane ABC is define by
A+uAB+B+vBC
a vector OP by
O+wOP
then intersection is given by resolving equation
A+uAB+B+vBC=O+wOP == A+uAB+B+vBC-O-wOP=0 or the system
uxAB+vxBC-wxOP=xO-xA-xB
uyAB+vyBC-wyOP=yO-yA-yB
uzAB+vzBC-wzOP=zO-zA-zB


put it in matrix form and you just have to resolve a simple
3*3 matrix M
MX=B
if plane is bounded ( triangle ) put constraint on u and v (0<u<1 and 0<v<1)
if vector is bounded ( segment ) put constraint on w ( 0<w<1 )

you'll notice you'll must give a tolerance on collision on the edge with a TETA(tiny float) in your constraints cause ther'are lake of precision due to approximations in computations


For more theory infos=> http://www.geometrictools.com/Books.html (see Books samples)

Sorry i will complete that post later when i will have more time


Don't you need an extra constraint u + v < 1 to ensure that the point of intersection lies inside the triangle? Also, I never work using matrice like this, so I'm very interested in how good this method would perform against a traditional 'intersect plane', 'point-in-poly', etc method performance-wise... My first impression is that it hardly benefits from early exit but if all tests were to pass, wich would be faster?

[Edited by - b34r on July 25, 2005 10:32:06 AM]

Share this post


Link to post
Share on other sites
good thing i asked rather than looking around in opengl references for a collision detection function. This has saved me a lot of time.

I will look into that website and/or try out that technique.

One of my thoughts was to use the vector in box technique because it would allow me to create collision boxes on the fly, but if that box rotates its no longer that simple... Any ideas?

Thanks for your input so far!



Chris

Share this post


Link to post
Share on other sites
Quote:
Original post by Pirosan
good thing i asked rather than looking around in opengl references for a collision detection function. This has saved me a lot of time.


Not intended as flame, but you would have saved even more time by looking in the forum FAQ rather than posting and waiting for a reply ;)
Anyway, hope you get it working :)

Regards,
/Omid

Share this post


Link to post
Share on other sites
Quote:
Original post by b34r
Quote:
Original post by mp3butcher
Colision between a vector and a plane is pretty simple:
plane ABC is define by
A+uAB+B+vBC
a vector OP by
O+wOP
then intersection is given by resolving equation
A+uAB+B+vBC=O+wOP == A+uAB+B+vBC-O-wOP=0 or the system
uxAB+vxBC-wxOP=xO-xA-xB
uyAB+vyBC-wyOP=yO-yA-yB
uzAB+vzBC-wzOP=zO-zA-zB


put it in matrix form and you just have to resolve a simple
3*3 matrix M
MX=B
if plane is bounded ( triangle ) put constraint on u and v (0<u<1 and 0<v<1)
if vector is bounded ( segment ) put constraint on w ( 0<w<1 )

you'll notice you'll must give a tolerance on collision on the edge with a TETA(tiny float) in your constraints cause ther'are lake of precision due to approximations in computations


For more theory infos=> http://www.geometrictools.com/Books.html (see Books samples)

Sorry i will complete that post later when i will have more time


Don't you need an extra constraint u + v < 1 to ensure that the point of intersection lies inside the triangle? Also, I never work using matrice like this, so I'm very interested in how good this method would perform against a traditional 'intersect plane', 'point-in-poly', etc method performance-wise... My first impression is that it hardly benefits from early exit but if all tests were to pass, wich would be faster?


which early exit would can be??
I wrote that algo without reading anything before...
There are techniques to exit earlier?!
I'm going to read about this...
can you give me references...

Share this post


Link to post
Share on other sites
Quote:
Original post by mp3butcher
which early exit would can be??
I wrote that algo without reading anything before...
There are techniques to exit earlier?!
I'm going to read about this...
can you give me references...


Well, what you describe is like an all-in-one method to intersect the triangle plane, get the point of intersection and verify that it lies inside the triangle.
Since you solve everything at once in a matrix you cannot reject rays going away from the triangle or rays that would stop before hitting the plane unless you make extras tests for it (since the matrix solve that as well).

One more thing, as I said I never work this way. But I'm very interested in learning it so that's the reason for my question. This was not an affirmative statement, really just a question. :)

However I'm still pretty sure that you need an extra u + v < 1 constraint in order to make sure the point of intersection lies inside the triangle.

Share this post


Link to post
Share on other sites
Quote:
Original post by b34r
Quote:
Original post by mp3butcher
which early exit would can be??
I wrote that algo without reading anything before...
There are techniques to exit earlier?!
I'm going to read about this...
can you give me references...


Well, what you describe is like an all-in-one method to intersect the triangle plane, get the point of intersection and verify that it lies inside the triangle.
Since you solve everything at once in a matrix you cannot reject rays going away from the triangle or rays that would stop before hitting the plane unless you make extras tests for it (since the matrix solve that as well).

One more thing, as I said I never work this way. But I'm very interested in learning it so that's the reason for my question. This was not an affirmative statement, really just a question. :)

However I'm still pretty sure that you need an extra u + v < 1 constraint in order to make sure the point of intersection lies inside the triangle.


I have wrote that in the hurry I have modified my post...
The only way i found to speed up that algo is space partitionning ( modified octree with neighbourhood relationship ) + bounding boxes
But as i said i need more infozz.........

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!