How suitable is Bullet for billiards simulation?

Post Reply
pinkisntwell
Posts: 11
Joined: Tue May 31, 2016 3:38 pm

How suitable is Bullet for billiards simulation?

Post by pinkisntwell »

The accuracy of a billiards simulation rests 100% on how well it simulates spin and the effect it has on ball-to-cloth, ball-to-cushion and ball-to-ball contacts.

For example, would Bullet be capable of simulating all the effects shown in this video: https://www.youtube.com/watch?v=avFjRgzTL-w ?

If not, what would be required to rectify this?
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: How suitable is Bullet for billiards simulation?

Post by benelot »

Hello pinkisntwell,

Welcome to the Bullet Physics Simulation forum!

Most simulations, especially game simulations depend on approximations of reality. For all the effects, we could give you hints on how to approximate them:
The Ball-to-ball contacts should be easiest, only needs some adjusting of the proper restitution when hitting another ball.

The Cue-to-ball contacts should be the second easiest, doable by adding some friction to the cue and soften it by approximating some local softness.

The Ball-to-cushion contacts could probably be done by approximating some friction and local softness again, but there might be some other effects I do not see right now. It could be implemented using a volume-preserving softbody.

The Ball-to-cloth effects are definitely the hardest of all, meaning that it has friction to make the ball roll, it is soft in a way that it might dampen the ball slightly, restitution to make it hop, but not too high. Furthermore the spinning properties I do not know how well you get them. You could try using a volume-preserving softbody being very flat on top of the table, which would them represent the cloth. You should definitely try to do it. I hope I could give you some valuable answers.

Ask if you need more!
pinkisntwell
Posts: 11
Joined: Tue May 31, 2016 3:38 pm

Re: How suitable is Bullet for billiards simulation?

Post by pinkisntwell »

What about the "cloth-grabbing" effect, an example of which is here:

https://youtu.be/avFjRgzTL-w?t=1m2s

?

If you are not familiar with billiards, what happens in that shot is: The cue is held vertically and the ball is struck very hard. Here is another example: https://youtu.be/YrzaNTFukXE?t=1m38s
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: How suitable is Bullet for billiards simulation?

Post by benelot »

I am familiar with billiards, but not much more than what you do at a bar, so I am not familiar with the terminology (also others that might help you here might not be), so it is good if you show examples. From what I see, the cloth-grabbing effect is basically an interaction causing the ball to spin around a horizontal axis, which then makes the ball "grab" the cloth, which is a friction of the cloth against the ball.

I am no longer sure if you get such delicate interaction of the cue and the ball, so that you do not always get side effects such as a bouncing ball on the table. But technically it should be doable to make it spin (maybe the spin is going to be torque induced instead of a proper cue hit, that would have to be considered specially), and move forward despite the spin, but then slowly transform the spin through friction into a rolling motion of opposite direction.

Do you intend to implement Billiards in Bullet Physics or is this just a feasibility question (could it be done if one wanted) ? Because I think while it can be done, it could be hard work to actually make it look realistic (in the sense that professional billiards players would say it feels correct). Most approximations are good and little details are irrelevant, but with higher accuracy, you might need all these second order effects (cloth causes damping, which is velocity dependent etc.)
pinkisntwell
Posts: 11
Joined: Tue May 31, 2016 3:38 pm

Re: How suitable is Bullet for billiards simulation?

Post by pinkisntwell »

"Cloth-grabbing" is not pool terminology, I just made up this term to better explain what it is :mrgreen:

I am considering implementing a billiards simulation and I am faced with a dilemma. Do I implement a physics engine myself, purpose-built for billiards, or go with a tested general-purpose physics engine, maybe with some modifications?

I was always leaning towards the former option. I didn't think that general-purpose physics engines can accurately model those interactions. Another example: https://www.youtube.com/watch?v=YzvEyOkIWiI

The cue is not a problem. I can leave the cue outside of the physics simulation and just induce a torque myself, directly to the ball.

Regarding how accurate it needs to be, well, there are already Virtual Pool 3 and 4 on the market, which are very, very accurate and I have been playing them on-and-off for about 15 years now (I have also been playing real billiards for about the same time). But they still have some small problems which the developers are not interested in fixing and online play is subpar. I was hoping to make something open source that can cure such problems.

From your comments so far it appears I will need to build my own physics engine.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: How suitable is Bullet for billiards simulation?

Post by benelot »

With my comments, I actually wanted to say that it is feasible to a certain extent and that you might have to improve certain parts. But except if you have a lot of experience in implementing your own physics engine, I would not recommend you to do this. There are very many caveats, especially if you want to have a high accuracy and stability as you would want. A simple physics engine will be possible to build, but billiards is definitely not simple physics. Additionally we can still help you with your problems if you are stuck.

There seem to be at least two implementations of billiard on youtube already, maybe you can get in contact with one of them and help to improve one:

https://www.youtube.com/watch?v=DIAvDdmtcvs

https://www.youtube.com/watch?v=_x2bB9KQ6Io

Edit: In case you want to learn the physics engine basics, here is a very good introduction:
http://gafferongames.com/game-physics/
pinkisntwell
Posts: 11
Joined: Tue May 31, 2016 3:38 pm

Re: How suitable is Bullet for billiards simulation?

Post by pinkisntwell »

I have started playing with Bullet and I am seeing very funky results with spheres. If I just set LinearVelocity to a sphere then it doesn't roll, it just slides. And if I apply AngularVelocity it never stops rotating.

I have applied both friction and rolling friction. My code is here: http://pastebin.com/teuiUkcz, but note it is using Irrlicht for graphics.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: How suitable is Bullet for billiards simulation?

Post by drleviathan »

I've seen that happen when the mass properties are not set right. Maybe the inertia tensor of the ball is too high? I looked at your code and don't see you setting the mass properties at all. It would go something like this:

Code: Select all

btCollisionShape* shape = new btSphereShape(1);
btVector3 inertia(0, 0, 0);
btScalar mass = density * 4 * pi * radius * radius * radius / 3;
shape->calculateLocalInertia(mass, inertia);
btRigidBody::btRigidBodyConstructionInfo bodyCI(mass, &motionState, shape, inertia);
btRigidBody body(bodyCI);
If you look at the documentation for btRigidBodyConstructionInfo you'll see that the inertia has a default value of (0,0,0) which I think makes it unrotatable (e.g. uses the inverse inertia hack to disable rotations).
pinkisntwell
Posts: 11
Joined: Tue May 31, 2016 3:38 pm

Re: How suitable is Bullet for billiards simulation?

Post by pinkisntwell »

Thanks! Calculating the local inertia did the trick.
pinkisntwell
Posts: 11
Joined: Tue May 31, 2016 3:38 pm

Re: How suitable is Bullet for billiards simulation?

Post by pinkisntwell »

Progress update:

I have now created a prototype application where I can run Bullet as a billiards simulator. So far I only use one ball in order to try and find the correct friction settings. However, I feel this is an exercise in futility. Bullet appears to be very sensitive to scale which means that I have to keep changing my scale to see if it will help simulation. Every time I change the scale I have to try the whole process from the beginning.
pinkisntwell
Posts: 11
Joined: Tue May 31, 2016 3:38 pm

Re: How suitable is Bullet for billiards simulation?

Post by pinkisntwell »

I've also been having problems with rolling friction. Rolling friction does stop the balls but changes to the rolling friction coefficient appears to have no effect.

Does rolling friction have effect when using perfectly rigid bodies? Are there scaling issues with rolling friction coefficients?
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: How suitable is Bullet for billiards simulation?

Post by benelot »

Hi, I think there might be an issue with your setup. Let us find out what it is. I have seen in your code in the other thread you opened that you use a strange definition in the timestep. That might fix many issues. The rolling friction should work on rigidbodies, but I do not know if it scales with dimension in any way. I will try to help you when I am home next week.
Post Reply