I've already programmed a 2d based collision system for a previous game. It was my first collision system and it was ugly. I was looking for collision between objects by checking all objects with all objects. I've already heard about a grid system with cells where an object will only look the collision with other objects from its current cell(s). Is it really a good way to check collision?
I'd like to have a good technique to loop trough all my items in a 3d world.
Answer
You're going to need a good space-partitioning algorithm, commonly used in 3D are octrees.
After that you could surround models etc with bounding spheres in which they fit neatly because a collision between bounding spheres is very easy to calculate. After you know that two bounding spheres collide you can either iteratively make the bounding spheres smaller and adding bounding spheres to keep the object covered in them, or us another smart algorithm to calculate collisions between two complex objects.
See this image:
No comments:
Post a Comment