Basic collision detection

I am running the danger of looking silly, but after seraching the forum for an example of collision detection, I have not managed to find the answer. Does anybody know of such example?



I have looked at Cep21’s example for intersection, but I am not sure what is needed to declare objects to be colidable and what I need to do to detect their collision.

tomcat

Take a look at TestCollision (bounding volume accuracy) and TestOBBTree (Triangle accuracy). Collision/Picking has changed dramatically, so the Starter’s Guide is not going to be accurate at the moment. Those two tests should help. Take a look at them and then direct questions towards that. We’ll work on getting the guide updated to handle the new system.

OK, got the new cvs version downloaded and looking at the code to figure out whats going on. Probably post some questions later.

tomcat

I have checked out both TestCollision and TestOBBTree. This is what I understand how the code works.



create geometry
create node
add bounding box
create BoundingCollisionResults or triangleCollisionResults

then in the update method first clear results
then call calculateCollision or findCollision


Is this what you need to do?

I dont know how do we tell the object to be collidable. Do we assume that all objects are collidable and we find out which ones when we call collision result?

Or does the xxxCollisionResult only calcs the objects (two of them) that we think are collidable?

What if we have a lot of objects in the world that we need to test for collision?

sorry if I am asking lots of questions in one go.
tomcat
Is this what you need to do?


Yes, basically, although there are convience methods that can handle the clearing, calculation and processing for you.

I dont know how do we tell the object to be collidable. Do we assume that all objects are collidable and we find out which ones when we call collision result?


If a TriMesh has a bounding volume it can be collidable.

player.findCollisions(world, results);

will find all the collisions between the player and the world and place them in results.

Or does the xxxCollisionResult only calcs the objects (two of them) that we think are collidable?


No, all collisions are handled between the two nodes.

What if we have a lot of objects in the world that we need to test for collision?


again, all collisions between the two test spatials are stored in results.