Thursday, March 2, 2017

Best/Efficient way to implement a 3d Collision


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: multiple bounding spheres



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...