0
\$\begingroup\$

I'm currently creating the collision system for my 3D XNA game.

To check collisions with models (especially complex ones) like trees or other plants, I thought about rendering a low poly version of this object and check if the player is in collision with that low-poly shape.

I succeeded in getting all the positions of all vertices in my models. If my model is a cube, I get the 8 vertices, but how can I check if the player is inside this shape?

\$\endgroup\$
  • \$\begingroup\$ You seem to know how to find a bounding box. Are you asking how to calculate the collision between two bounding boxes? \$\endgroup\$ – Anko Dec 12 '13 at 12:08
2
\$\begingroup\$

This is generally done in one of two ways.

The first is to represent your object with multiple simple volumes. A tree might be a cylinder with a sphere at its top, for instance. This is not particularly accurate but may be "accurate enough." If you don't need to really worry about colliding with the branches you could even just use a cylinder or even just a bounding-box enclosing only the trunk. You can be a little "sloppy" here; you only need to be so accurate.

The other option is to actually do a collision against a mesh, usually a low-poly mesh like you mentioned. This may be taken from one of your lowest LODs (levels of detail) or it may be especially made for physics. I don't believe XNA supports this. If not, you'll need to upgrade to a real physics/collision engine; there are a number of them but I'm not sure which are the better options for C# users. Typically though you'll want to stick to the first option as it tends to have significantly better performance, though some games do actually have need for mesh-collision (shooters, for instance, but then only for things that bullets need to be able to hit).

\$\endgroup\$
0
\$\begingroup\$

In this tutorial (lecture 24) you can find informations about bounding spheres. In the last lecture you will see the working demo with everything set up correctly to have your character walking on a playground. You will also find the downloadable code

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.