views:

20

answers:

1

Hi, I am making an application for 3d ball balancing game on j2me, I need to move my 3d ball on my ball path. I can get both ball and path object as a mesh from m3g file.

How I will know that my ball is in the path or not ? Is there any notification I can get for interaction of two meshes ?

Thanks in advance...

A: 

How to detect a collision:

At each frame, you need to compute the distance from the center of your ball to each of the polygons of you meshes. If the distance is smaller than the radius of your ball, then there is a collision (and penetration).

How to respond to the collision:

Keep the previous spatial state of your ball in memory, once you know there is a penetration, go back in time until the penetration is only a contact. Then, starting from there you have to decide how you want the ball to responde to the collision (bounce ?). Just make sure that you prevent the ball from penetrating the mesh.

Vincent