Polygon-Polygon Collision System

Blitz3D Forums/Blitz3D Programming/Polygon-Polygon Collision System

Spot(Posted 2003) [#1]
How would I go about creating a polygon-polygon collision system? Are there code snippets for this purpose?

Where would I start?

Working out collisions is new to me so I need quite a bit of help in this department.

Thanks


Beaker(Posted 2003) [#2]
The easy answer is to use MeshesIntersect(a,b) but only after a distance check (EntityDistance(a,b)) as it can be a slow command.

You can do it by writing your own routines but it is a rather advanced topic.


Neo Genesis10(Posted 2003) [#3]
You'd have to individually cycle through all triangles in a mesh and check for intersection with triangles in a second mesh (third, fourth etc). As with MeshesIntersect though, unless you have a pretty darned good routine its not going to work very fast. There's probably an algo somewhere, but I'll be darned if I know it!


John Pickford(Posted 2003) [#4]
It's unlikely you'll need polygon to polygon collision detection. Even commercial games don't use that.

Polygon to a point (sphere perhaps) is more likely.

Many many games, 2d & 3D work perfectly well with sphere to sphere collision for objects and sphere to poly for the landscape\environment.


Poly to poly or pixel level (in 2D games) would often cause more problems than it solves. If your character has a different collision shape depending on the frame of animation then you can easily get stuck in small gaps etc.


Beaker(Posted 2003) [#5]
I agree with John, although of course sometimes polygon to polygon is needed in non-game situations. If you need higher definition character collision you should use multiple bounding spheres/boxes.


jhocking(Posted 2003) [#6]
Assuming you REALLY need polygon-polygon collision detection (and it is rare to need that kind of accuracy unless both objects are very large) go with MasterBeaker's first suggestion, of two-pass collision detection. Do a rough first pass with EntityDistance and then a more accurate second pass with MeshesIntersect for objects which are close enough.


Spot(Posted 2003) [#7]
Okay, But how would I use meshesintersect to perform collision functions. Currently I am using the ODE physics sytem which needs variables like CollisionX/Y/Z and CollisionNX/NY/NZ. I know meshesintersect does not produce these variables, so how would I make it, or how would I do it? Even if I was not using ODE, how would I use it to perform regular collision functions?

P.S. I know that MOST commercial games use seperate collision meshes with few polygons on them just to get a rough collision outline.. This is what I was thinking of.


Ross C(Posted 2003) [#8]
I don't think meshesintersect has any collision reponse either.


Rob(Posted 2003) [#9]
you can linepick instead?


Spot(Posted 2003) [#10]
Wouldn't that just get me sphere collision detection?


Beaker(Posted 2003) [#11]
Spot - I have to disagree with you. MOST games don't use seperate collision meshes at all, they mostly use mathematical approximations of the objects they want to collide: boxes, ellipsoids, cylinders.

It is insanity to want to do poly-to-polygon really. Even if you want fairly accurate physics modelling you are essentially using sphere-to-poly collisions and the like.


Rob(Posted 2003) [#12]
The closest I've seen is bsp convex hull collision detection. You wrap cellophane around the object and get an approximation from this...

This has more: http://www.melax.com/hull/consimp.html