1
\$\begingroup\$

This is going to be a rather vague question xD

In XNA is there a way of working out if a point or rectangle is colliding with a 3D .x object? It is a big model, and would take a long time to map out all the rectangles for collision detection so I was wondering if there was a easier way of doing it :)

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

If you don't mind the collision being somewhat rough, you can use the bounding sphere of the individual mesh parts for basic collision.

This will result in a small to large area for false positives (depending on the design of the model and the individual mesh parts), so be warned. However this will work well, and quickly, in situations where you don't need particularly fine grained checking or if you wish to know when you should employ a higher resolution collision check.

\$\endgroup\$
7
  • \$\begingroup\$ And what would be the best way to implement that do you think? Would it be good to have an array of the spheres or perform a check each update? \$\endgroup\$
    – Humpheh
    Jun 10, 2011 at 18:26
  • \$\begingroup\$ Depends on your setup. I'd probably say from the sound of your current situation to try checking vs the sphere of the entire model, then if that collides check vs the mesh spheres. That will make it so you only have to check vs each sphere when there's some chance that one of them could possibly collide. \$\endgroup\$
    – Lunin
    Jun 10, 2011 at 18:40
  • \$\begingroup\$ Yeah, my model is very large (it's a whole building), so I want to be able to walk around in it, would this be possible still? \$\endgroup\$
    – Humpheh
    Jun 10, 2011 at 18:44
  • \$\begingroup\$ Ah, a nested sphere situation isn't very good for concave collision like that as anything inside will be always colliding with the overall sphere. I take it the model is of a building and all the things inside it and you want to walk around in it? If this is the case are the individual objects inside the building their own meshes? Also what kind of objects are inside the building shape wise? \$\endgroup\$
    – Lunin
    Jun 10, 2011 at 18:47
  • \$\begingroup\$ Yes it's a model that we want to walk around in :P I believe the object is all one mesh. Its mainly walls in the building, and a few objects like computers and desks. We made the model in Sketch Up. Thanks for the help :) \$\endgroup\$
    – Humpheh
    Jun 10, 2011 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .