Simple Bullet Soft Body Simulation

A simple soft body simulation with Bullet Physics engine.
The physics of a simple soft body sphere.
Graphics rendered in OpenGL.
Interaction using SensAble Desktop Haptic device and OpenHaptics toolkit.
Widget rendered in QT.

Advertisements

About somapanam

Like violent gusts of wind the droughts that I have drunk have lifted me. Have I not drunk of Soma juice?
This entry was posted in Literature. Bookmark the permalink.

18 Responses to Simple Bullet Soft Body Simulation

  1. XMight says:

    Hello,
    I also created something like this. Check my post and video on the blog that begins with my nickname (lowercase) + “.” + blogspot.com. The blog is not public for the moment, because I just started it. Also, if you’ll have some time and you will be interested, maybe you’ll help me with some problems that I have, maybe you know how to fix them, but as I am a beginner, I don’t.

  2. XMight says:

    Sorry, my post from above must be for this video: https://somapanam.wordpress.com/2011/03/03/haptic-symphony/. Can you move it there and delete this one?

  3. Benny says:

    Hi,

    this looks very nice. But the framerate seems to be very low. Is this because of the computation speed or because of the video quality.
    It would be nice to test the program.

    • somapanam says:

      The video quality is not good because I used a bad screen capture software. It actually runs quite nice in my old Dell Intel Xeon CPU, 2GB of RAM and 128 MB graphics card.

  4. XMight says:

    How do you detect the nodes of the softBody that are in collision with the rigidBody? I’m trying to implement the method to pick up the soft body with the arm, but it’s not the same as for the rigid bodies.

  5. XMight says:

    In this case, the deformation of the sphere is done at collision by Bullet itself? Hmm. To be honest, I tried to do the same thing as for the rigid bodies, but this doesn’t work because the softBodies haven’t the same properties and methods. Also, I tried to apply the same thing as when pushing the soft body with the arm:

    softBody->addForce(btVector3(x,y,z));
    softBody->applyForces();

    This works in the case when pushing the soft body with the arm, and not picking up. If I pick up the soft body, and I do the thing above, the object blows up and disappears from scene at all :)). Obviously this will not work, so the solution is to apply a force to a vertex of the softBody, but in this case I must detect the vertex nearest to the collision region (nearer the centroid for the collision region in fact). Bullet soft demo demonstrates this with the mouse cursor, but they do raycast test from camera to the 2D location of the mouse cursor. It is not the same thing as for the arm in 3D, but I think I must use something like this.

    So if you’ll have some suggestions :D, you’re welcome. Also, how do you imagine to attach a rigid body to the softBody, and to be able to move the last one using the first?

    • somapanam says:

      What I have done in this demo is to use the rigid bodies to interact with the soft bodies. To do this you don’t have to set any forces to the soft body: all that is done by bullet. All I did was to use the rigid body as a tool and manipulate it using spring mass damper system and since bullet resolves the collisions between rigid and soft bodies, depending on how u setup the rigid body tool, you can nicely feel the soft body deforming. I will try to post the code soon.

  6. XMight says:

    I understood already this, thank you.

  7. XMight says:

    Hi,
    You may want to check what I did with the soft bodies on my blog. It’s not much, but anyway. The video is a bit too long, but you can skip some parts.

  8. rookie says:

    Hey, I got code working but now I wanted to attach texture to the sphere. Can you plase help me with that?? I am trying to use glTexCoord2fv(&objmodel->texcoords[2 * objmodel->triangles[i].tindices[2]]); but obviously that is incorrect. Please help me

    • somapanam says:

      If you want to texture the soft body, use the texture coordinates from bullet not from the obj model. If you use the texture coordinates from the obj file, then it will get messed up when deforming.

      • rookie says:

        How do I get the texture coordinates from bullet?? CalculateUV wouldn’t work for sphere or customized object files.

      • somapanam says:

        Sorry for not being clear in my previous reply. You have to generate your own uv coordinates using the vertices from bullet and then texture them at every instance the vertices move to deform. For a simple sphere you can easily perform sphere mapping and generate uv coordinates as shown in the following wesbite.

        http://vterrain.org/Textures/spherical.html

        Another easy way of texturing any shape / size deformable object is to use cube mapping. You can google to find a lot of hits for cube mapping. Here is a very nice example on cube mapping on the Nvidia wesbite.

        http://developer.nvidia.com/cube-map-ogl-tutorial

        Hope this helps.

      • rookie says:

        So you are saying I can texture a shirt or dress or any other cloth type in bullet physics using cube mapping?? I am new to this so just confirming. Thanks a lot for all your help.

      • rookie says:

        Is there a formula to calculate those texture coordinates because in the example mentioned on the nvidia website they have used glTexGen which wouldn’t work for my obj file??

  9. rookie says:

    I looked up both websites. It tells you how to use OpenGL functions. If you know how to calculate texture using vertices for every instance please let me know. I have tried every possible method I know. Maybe you can figure something which I couldn’t.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s