Soft Bodies

The MAGES SDK supports real time soft bodies as a part of its standard features

Note

Soft bodies are used to simulate soft and deformable surfaces like the human skin, liquids, internal organs, cloths and any other deformable surfaces.

You can read here more information about our soft bodies.

In this tutorial we will demonstrate how to setup the soft body behaviour on a human bowel model (small intest and mesenter).

Tutorial overview:

  1. Exporting the model from Maya

  2. Unity importing

  3. Soft body setup

  4. Run-time and interaction

  5. General discusson

Exporting the model from Maya

The image below shows the bowel model in Maya.

../../../_images/bowel_maya.png

This model has 5700 vertices. The number of vertices is really important in our soft body system both for the real-time simulation updates as well as the pre-load configuration and caching preprocessing time. Both operations (pre-processing and real-time updates) all depend heavily on the number of vertices under processing

Make sure to do a cleanup before exporting the FBX. In the cleanup window select the 4-sided faces, Faces with more than 4 slides and the Nonmanifold geometry.

../../../_images/bowel_maya_cleanup.png

Then export the model using the FBX format.

Unity importing

When you import the model to Unity make sure you check the following parameters:

  1. Mesh compression should be off

  2. Read/Write Enabled should be checked

  3. Set Optimize Mesh to Nothing.

../../../_images/bowel_import.png

If you face any other issues with the model e.g missing vertices when starting the application, consider reviewing those configurations. The underlying geometric topology plays an important role in the final quality of the simulation.

Soft body setup

Drag and drop your FBX model in the unity scene to create a prefab.

This particular model contains two mesh renderers. One for the small intest (left) and another one for the mesentery (right)

../../../_images/bowel_parts.png

For this reason we will configure both objects (in the same way). If your model contains only a single mesh renderer then you should configure only this one for the soft body behaviour.

The first step is to attach the CreateDeformMesh script under the mesh renderer.

These are the settings we used for the bowel model:

../../../_images/bowel_create_deform_mesh.png
  • For best results choose Distance_with_soft_interaction as the group method. This refers to the used method to group the soft body particles.

  • We selected Sphere for the collider type of our soft body particles.

  • The Particle Distance Layer refers to the distance between the particles. The higher the number the less particles will be generated.

  • The same principle applies for the Soft Interaction Distance.

  • Make sure the Use Local Simulation is checked.

Limiting particles with bounds colliders

There are cases where we don’t want the whole mesh to behave like a soft body. For example when you have liquid inside a cup, you don’t want the edge of the liquid to overpass the glass boundaries.

In this case we will utilize the Bounds Collider variable in CreateDeformMesh script. In our scenario we want our liquid betadine to stay inside the glass cup and simulate with particles only the liquid’s center region.

To implement this behaviour, we need a trigger collider (sphere) to limit the area where the soft body particles will be populated.

../../../_images/iodine_sphere.png

As you can see from the image above, the simulation generates soft body particles only in the intersection area between the liquid and the sphere.

Warning

Don’t forget to drag and drop your collider to the Bounds Collider variable in the CreateDeformMesh script.

The image below shows the limited particles around the center of the cup.

../../../_images/iodine_particles.png

Run-time and interaction

When you press the play button, the soft body simulation will generate the particles and attach them to the corresponding vertices.

Below you can see a screenshot showing the softbody particles generated on start.

../../../_images/bowel_particles.png

Around 180 particles were generated with those settings.

Those spheres will interact with other physical colliders within the scene to simulate soft skin movements.

Warning

The more particles you generate, the more time consuming this process will be.

If we increase the number of the Particle Distance Layer to 0.04 and the Soft Interaction Distance to 0.03, we can clearly see that the particles are have been reduced to approximately 70 particles.

To improve the visual fidelity, increase the number of particles.

../../../_images/bowel_less_particles.png

This slideshow shows the interaction with the bowel. The user took the pliers and a cotton swab to disinfect the area with betadine. The bowel softbody deformations are increasing the engagement with the virtual assets.

../../../_images/bowel_interaction.png

General discussion

Soft bodies introduce a powerful way to simulate deformable surfaces. The MAGES SDK offers a plug-and-play solution for particle-based soft bodies in Unity, ideal for medical or any other use.

It is important to consider that real-time soft body simulation uses advanced physics algorithms to calculate the object’s movement per vertex, paying respect to its original shape. This is why you need to be extra careful with the script configuration as well as the model’s topology for best results.