collision detect using bounding box ...?

Started by
2 comments, last by Trip99 18 years, 8 months ago
i have make bounding box for my character, to collide it with other object for example trees, do i have to make those trees bounding box too...? if that true...so for every single object in the world i want to use collision system.. have to own a bounding box/sphere ? isn't it consume much performance?
Advertisement
Yes, for every item that you want to test for collision with you will need 1 or more bounding primitives (if it was a model of a person you would use many bounding primitives). The calculations for intersection are prety simple in most cases so it isnt that CPU intensive, especially when optimised.

Try here for intersection algorithms.

ace
You will want every single object in your scene to have a both bounding box and a bounding sphere. Checking a bounding box against another bounding box, or a bounding sphere against another bounding sphere is orders of magnitude faster than going down to the polygon level to check for exact collisions, so its a good way of quickly eliminating the possibility of a collision between objects. Only if the bounding boxes/spheres intersect do you have to go down to a finer level of collision detection. So, it'll add performance and not consume it.

DirectX also has functions built in for computing the bounding boxes and spheres of your meshes for you:
Geometry.ComputeBoundingBox and Geometry.ComputeBoundingSphere
A tree is a good example of a case where you really need two or more boxes. If you just have one around the whole tree collisions with the trunk will look wrong as they will happen to early so a box for the leafs and branches and another for the trunk would work better. This does make it more difficult to programatically create boxes from an arbitary mesh but you could split the tree into two. Often in games development artists will actually create the bounding shapes in the 3D package along with the model. you then load the model, detect the meshes that are bounding shapes and do not render them but use them to define the shapes.
------------------------See my games programming site at: www.toymaker.info

This topic is closed to new replies.

Advertisement