Soft Body / Cloth Physics?

I want to implement some kind of soft body physics. Think of a mattress with a bowling ball moving across it. The mattress compresses at the position of the ball as it rolls over it in realtime. Would something like this be possible in PLaycanvas? Any pointers to how I could implement such an idea?

Hi @Grimmy, indeed it’s possible, check the following post:

Thanks. I see that was posted over a year ago and according to the article there were still some areas that needed refining. Do you know how much of this has been refined and if there are any more updated projects or tutorials showing us how to use it?
Thanks

I think there wasn’t any additional update on the subject in a sense of an official cloth sim API. But the technology is indeed supported if you want to give it a try (ammo.js has support for soft bodies).

@will may have something to share on this. And also @mvaligursky if the patched vertex shaders for CPU skinning have been integrated to the engine.

As @Leonidas mentioned, soft body physics is possible but it’s not officially supported by the engine so you are on your own for the most part.

Given that it’s just compressing and uncompressing, maybe morph targets, a bone for each spring animation or directly manipulating the mesh are other possibilities here.

2 Likes

This looks pretty close (directly manipulating the mesh) to what I want https://playcanvas.github.io/#/graphics/mesh-generation

…but I have no idea how I would manipulate vertices on a imported mesh. This demo creates the mesh at runtime. I want an imported mesh to compress/squash down slightly as the user moves their finger /or an object across it. It looks like it could be possible but maybe its way out of my league.

Mesh deformation may be closer to your use case considering you are using a model asset PlayCanvas Examples

The tricky bit will be working out which vertices are under the finger. Off hand, I would place a plane on the top of the mattress to recast against and loop over the vertices to manipulate based on distance from the finger on the plane.

1 Like

the mentioned mesh-generation would work on generic mesh … it computes a distance of each vertex from those 4 points to see how much they would get affected.

Combine that with mesh deformation - which loads a mesh a uses its vertices for some modification on cpu, and you have a solution.

2 Likes