Rope physics with Havok

Havok rope physics testing: https://playground.babylonjs.com/#XTCZ07#14

I’m trying to get a certain kind of rope physics for my project using Havok. You can see in the playground I made a bunch of sphere shapes with ball & socket constraints between them. It looks pretty good if you are looking for thin, flexible rope or string, but I was hoping to get the feeling of a thick cable that doesn’t bend so much. Not sure if this is even the right approach though. I keep messing with angular and linear damping, altering the mass of various parts, and I can’t seem to get the effect I’m looking for.

Does anyone have ideas for how to make it look more like a stiff steel cable?

Just a guess but would a 6DOF constraint work where you limit the “swing” angles of the cable?

2 Likes

That’s a good idea. But I have been unable to make a 6DOF constraint that looks even remotely similar to a ball and socket constraint. Probably I misunderstand how to use 6DOF constraints. Any help? Playground here: https://playground.babylonjs.com/#XTCZ07#18

cc @Cedric and @carolhmj

If you add limits on the angular axes of the 6DOFConstraint creation, it sets those axes mode to LIMITED: Babylon.js/havokPlugin.ts at master · BabylonJS/Babylon.js · GitHub, which is not set on the BallAndSocketConstraint, so that’ll make them behave differently, is that right @eoin ?

2 Likes

You have specified pivot points as a number (you need a vector3, as you did in the first example).
I copied the pivot points from your commented code and it worked great.

Obvious mistake, but it seems strange that there are no error messages :thinking:

1 Like

Good catch @ilyhandrik
Fixed here : https://playground.babylonjs.com/#XTCZ07#19

2 Likes

Well that’s embarrassing but I’m glad you caught that :slight_smile:

So, back to the original question of how to make a less flexible rope. Adding the angular limits on the 6DOF constraint doesn’t seem to have much of an effect on the stiffness of the joints. When I put the limits down to [0, 0] it does act a bit stiffer but also kind of glitches out (see https://playground.babylonjs.com/#XTCZ07#20) (the rope segments don’t keep their ends together). I fully understand that the solver will never be perfect especially when there is a long chain of constraints, but I keep thinking there must be a way to get the effect I want.

Have you tried adding friction to the angular axes?

https://playground.babylonjs.com/#XTCZ07#22

2 Likes

This has a lot of potential! I will experiment with this in my project. Somehow I missed that part of the API – apparently my reading comprehension is low this week. Thank you and thanks to everyone else who offered ideas

edit: I see that setAxisFriction is only available in the 6DOF constraint. Is there any reason the other constraints (ball/socket, hinge, etc) couldn’t have a method for axis friction?

Did you found a solution to get it less flexible? It would help me a lot to simulate a thick steel cable.

1 Like