I am designing a simple billiard game with box2d. I think I can easily simulate hitting left or right side of a ball. Since box2d is not 3D, however, I am not sure how to simulate hitting upper or lower part of ball with a cue.

In case you are not familiar with the game. If the ball is hit on its upper part, it's still going forward after hitting another ball. But when cue hit on its lower part, it should backspin as soon as striking another ball.

Is this simulation possible with box2d? If so, a hint or reference will be appreciated.

1 Answer
1

First off; I am not familiar with box2D and may not have the right terminology for physics. But storing the top/backspin should be as simple as storing a 2d vector for the potential velocity the ball is "carrying" from when the spin started. Then on collision detection you perform the normal collision and after that you apply the spin. Some tweaking would be required to make it feel right.

Also though, top/backspin affects the balls trajectory depending on how much grip the ball has, correct? So you would probably need to add code for each simulation step to check how much velocity it would transfer depending on the balls current velocity and the friction between the ball and the table.

That's pretty much exactly it. Box2D is a 2D physics engine; it won't automatically handle friction against a table 'behind' the playing field, and it has no way to represent rotations relative to it. So you end up having to fake it in a manner like the one that Daniel describes, or else use a fully 3D physics engine, such as ODE or Bullet.
–
Trevor PowellJan 22 '12 at 9:03