views:

259

answers:

1

I've been looking for a tutorial on 3D per-vertex collision systems (using C# and XNA, since I have that readily available), but have only been able to put together bits and pieces. I have a pretty good understanding at this point, but there's one rather large, glaring hole in my understanding.

Basically, my problem comes down to: how do I get the polys and their info?

Does anyone have any good references?

Note: while I'm using XNA and am most interested with that system, this is more of a self-educational exercise, and I am interested in how to do it in other systems if it's done differently (i.e OpenGL, etc.)

Clarification: What I mean by "how do I get the polys", is if I have a 3D object, and perhaps even an animation applied to that object, is there a system for retrieving the rendered polys' information (positions, etc.) for testing? The most logical thing to do would be retrieve the poly information after it's been rendered, but that also sounds exceedingly expensive, and I'm not sure how to go about doing that anyway. I wasn't sure if there was a better way, or if retrieving rendered information at that level was even possible.

+2  A: 

You get hold of the polygon information from the model. There will be a set of calls and/or methods which will return you things like lists of points, normals, texture coordinates etc, and a list of faces that reference these other arrays.

It can be (well it used to be) fairly difficult to get hold of the data once it has been sent to the graphics card for rendering. Also once it's been rendered, the information is in 2d not 3d.

Per polygon collision is expensive, if only because even moderately complex models can contain hundreds if not thousands of polygons. The first step is to try and eliminate most of the information by performing bounding box collisions. These will tell you that most objects in the scene don't collide with each other. You can then concentrate on the cases where the bounding boxes intersect in some way. Using a bounding sphere is another way and may give you fewer false positives as the sphere will bound the object more tightly than a box. Though the calculations might be a bit more expensive.

The next step is to take each polygon in your test object and check it against the other objects. Again start with a bounding box/sphere test before checking against all the polygons in the other object(s).

The maths you need should be covered in any decent book on 3d graphics.

ChrisF