Soft Body Simulation

Soft Body Simulation. This is a quick exploration of soft body simulation. I’m interested in simple, procedural methods for deforming meshes in response to their collision with other objects, specifically, character meshes made of jelly (slimes!). Soft Body is a meditative action game where you control two beautiful, gooey snakes at the same time. In the game, you paint the world with your body, and as you do so, the world changes around you and reveals new obstacles and challenges. Although the action is quite tense, the mood and aesthetic is contemplative and calm. Soft-body dynamics is a field of computer graphics that focuses on visually realistic physical simulations of the motion and properties of deformable objects (or soft bodies ). The applications are mostly in video games and films. Unlike in simulation of rigid bodies, the shape of soft bodies can change, meaning that the relative distance of.

A pig goes down the MINECRAFT mountain#Minecraft #softbodysimulationguy #softbody #pig #softbodysimulationguy #softbody.

RK4, spring coef. 8000, damper coef. 20

Overview

This project simulates a flexible cube falling on the floor, using a framework developed with C++ and OpenGL by GPLab, NCTU. For all the videos of result, please check out the last section.

The cube is constructed by a set of particles, which are connected with 3 kinds of springs. With these particles and springs, we can integrate the spring forces and damper forces to estimate the next positions for each particle. In this case, I implemented Explicit Euler Method and Runge-Kutta 4th-Order Method to solve the differential equations. This is a simple approach to simulate solid deformable objects.

Finally, because it’s a plane there, I also used a simple method to resolve the point-plane collision detection, which can bounce back the cube to the air.

Mass-Spring System

Cube of Particles

Simulation

As the image above, these particles constructs the cube. In this simulation, it took 1000 particles to form a 10x10x10 cube. Then, the images below shows each kind of the springs connected between particles.

Structural Springs

Structural Springs connect from each particle to its 6 adjacent neighbors, including up, down, left, right, forward, backward. These springs establish the basic structure of the cube.

Shearing Springs

Shearing Springs connect from each particle to its 20 diagonal neighbors. These springs can prevent the cube from excessive shearing.

Bending Springs

Bending Springs connect from each particle to its 6 second adjacent neighbors, kind of like the structural springs but these springs skip the first neighbor instead. They can prevent the cube from folding all over.

Integration

Euler Method

Illustration of the Euler Method (from Wikipedia)

The blue curve in this graph is the unknown real values, while the red one is the approximation by Euler Method. From A0 to A1, this method only takes the status at position A0 to estimate the position after a small time step. In this case, physically, the Euler Method takes the net force at A0 and derive the acceleration to approximate the position at A1 with a small time step.

Because the Euler Method is a first-order method, which means it needs a rather small time step, otherwise the local error (error per step) and the global error (error at a given time) would be very big resulting in unstable system. However, the Euler Method is rather low-cost and also a basic method which is easy to implement.

Runge–Kutta 4th-Order Method

Illustration of the RK4 (from Department of Physics, Drexel University)

First, we define the following equations (h is the step size, h > 0).

  • yn+1 = yn + (h/6)(k1 + 2k2 + 2k3 + k4)
  • tn+1 = tn + h

For k1, k2, k3 and k4:

  • k1 = f(tn, yn)
  • k2 = f(tn + (h/2), yn + (h/2)k1)
  • k3 = f(tn + (h/2), yn + (h/2)k2)
  • k4 = f(tn + h, yn + hk3)

Which means:

  • k1 is the increment based on the slope at the beginning of the interval, using yn.
  • k2 is the increment based on the slope at the midpoint of the interval, using yn + (h/2)k1.
  • k3 is the increment based on the slope at the midpoint of the interval, using yn + (h/2)k2.
  • k4 is the increment based on the slope at the end of the interval, using yn + hk3.

The RK4 method is a fourth-order method, meaning that it’s rather high-cost and more precise than the Euler Method. It’s local error is on the order of O(h5), while the global error is order O(h4).

Collision Detection

There is one thing left to handle is the point-plane collision when the cube is falling right on the plane. For every particle, once it satisfies the following conditions, it would be considered that the collision is happening.

  • The particle’s position is close enough to the plane.
  • The particle is moving toward the plane.

When the particle and the plane are collided, the system would revert the normal component of the velocity. A coefficient smaller than 1 to represent the energy loss could be applied to the reverted velocity. So this is an simple way to handle the point-plane collision.

Results

  • Euler Method, spring coef. 8000, damper coef. 20
  • Euler Method, spring coef. 800, damper coef. 60
  • RK4, spring coef. 8000, damper coef. 20
Soft body simulation online

Soft body simulation is used for simulating soft deformable objects.It was designed primarily for adding secondary motion to animation,like jiggle for body parts of a moving character.

It also works for simulating more general soft objects that bend, deform andreact to forces like gravity and wind, or collide with other objects.

While it can simulate cloth and other stiff types of deformable objects toan extent, the Cloth Simulation can do it betterwith a solver specifically designed for this purpose.

The simulation works by combining existing animation on the object with forcesacting on it. There are exterior forces like gravity or force fields andinterior forces that hold the vertices together.This way you can simulate the shapes that an object would take on in reality if it had volume,was filled with something, and was acted on by real forces.

Soft bodies can interact with other objects through Collision.They can interact with themselves through Self-Collision.

The result of the soft body simulation can be converted to a static object.You can also bake edit the simulation, i.e.edit intermediate results and run the simulation from there.

Typical Scenarios for using Soft Bodies¶

The wind cone is a soft body, as the suspension.

Soft bodies are well suited for:

  • Jiggle on moving characters.

  • Elastic and deformable objects made of materials like rubber or gelatin.

  • Tree branches moving in the wind, swinging ropes, and the like.

  • Flags, wide sleeves, cushions or other simple fabric reacting to forces.

The following videos may give you some more ideas:

Creating a Soft Body¶

Soft Body Simulation Game

Soft body simulation works for all objects that have vertices or control points(meshes, curves, surfaces, and lattices).

Soft Body Simulation Sans Undertale

To add a soft body simulation to an object,go to the Physics tab (bouncing ball icon) in the Propertiesand activate the Soft Body button.For a reference of all the settings see this page.

You start a soft body simulation by playback animation with Alt-A,and stop the simulation with Esc or Alt-A.

Soft Body Simulation

Interaction in Real-Time¶

Soft Body Simulation

To work with a soft body simulation, you will find it handy to use the Timeline editor.You can change between frames and the simulation will always be shown in the actual state.You can interact in real-time with the simulation,e.g. by moving collision objects or shaking a soft body object.

You can then select the soft body object while running the simulation and Applythe modifier in the Modifiers tab of the Properties.This makes the deformation permanent.

Tips¶

  • Soft bodies work especially well if the objects have an even vertex distribution.You need enough vertices for good collisions. You change the deformation(the stiffness) if you add more vertices in a certain region.

  • The calculation of collisions may take a long time. If something is not visible, why calculate it?

  • To speed up the collision calculation it is often useful to collide with an additional,simpler, invisible, somewhat larger object.

  • Use soft bodies only where it makes sense.If you try to cover a body mesh with a tight piece of cloth and animate solely with soft body,you will have no success. Self-collision of soft body hair may be activated,but that is a path that you have to wander alone. We will deal withCollisions in detail later.

  • Try and use a Lattice or a Curve Guide soft body instead of the object itself. This may be magnitudes faster.