Polygon-Polygon Collision System
Blitz3D Forums/Blitz3D Programming/Polygon-Polygon Collision System
| ||
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 |
| ||
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. |
| ||
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! |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
I don't think meshesintersect has any collision reponse either. |
| ||
you can linepick instead? |
| ||
Wouldn't that just get me sphere collision detection? |
| ||
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. |
| ||
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 |