# Collision Detection

This topic is 4851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'd like to know how to implement bounding boxes and bounding spheres for loaded .ms3d models. Also i'd also like to get camera world collision (as in a first person camera colliding with objects in the world) so if there's anybody out there that can gimme a bit if help with that in any way possible it would definitely be appreciated.

##### Share on other sites
I would say just use a bounding sphere. For that, I would compute the centroid of the model by averaging all of it's points. Then, I'd compute the sphere radius by finding the maximum distance to the centroid.

Then you can have the model centered at the origin by subtracting the centroid from all points. That will make it easier to position for drawing.

Then for collision detection, just check if the sphere's distance from your triangles is less than or equal to the radius of the sphere. I'd probably just cast a bunch of random rays out from the sphere's center and see how long it takes them to hit the triangles. If you cast them out and they have a speed of 1, the time it takes for them to hit a triangle is the distance to it (d = rt, r = 1, d = t). I would use Moller Trumbore for this. They have posted code that works.

Mike C.
http://www.coolgroups.com/zoomer/

Quote:
 Original post by jonnysI'd like to know how to implement bounding boxes and bounding spheres for loaded .ms3d models. Also i'd also like to get camera world collision (as in a first person camera colliding with objects in the world) so if there's anybody out there that can gimme a bit if help with that in any way possible it would definitely be appreciated.

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 15
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632962
• Total Posts
3009498
• ### Who's Online (See full list)

There are no registered users currently online

×