Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 :)

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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? –  Humpheh Jun 10 '11 at 18:26
    
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. –  Lunin Jun 10 '11 at 18:40
    
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? –  Humpheh Jun 10 '11 at 18:44
    
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? –  Lunin Jun 10 '11 at 18:47
    
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 :) –  Humpheh Jun 10 '11 at 18:52
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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