Animation: 2D Deformation Simulation

Hey everyone! 🎓

Currently, I’m working on a simulator for a 2D deformable Gingerman using three different constitutive models in a computer graphics class. The starter code provided by professor comes with a GUI system with Edit and Simulation modes. In Edit Mode, you can pin vertices, and in Simulation Mode, you can create spring-like forces to deform the Gingerman.

Making the Gingerman Move 💃

Here's a step-by-step breakdown of how I made the Gingerman move and bend. It looks quiet straight forward but it actually takes a lot of time on debugging many details..

  1. Compute the deformation gradient: I needed to compute the reference (F0) and current (F) deformation gradients for each element using the vertex positions and triangle indices. The deformation gradient is represented by F = dφ/dX where φ is the mapping between the initial and deformed configurations.

  2. Compute the first Piola-Kirchhoff stress tensor: Next, I had to calculate the stress tensor for three constitutive models: corotated linear, St. Venant-Kirchhoff (StVK), and Neo-Hookean. Also, I needed to create fields for Lame parameters λ and μ and compute them from Young's Modulus E and Poisson's Ratio ν using these formulas:

    λ = (E * ν) / ((1 + ν) * (1 - 2 * ν)) μ = E / (2 * (1 + ν))

  3. Compute forces: This part was fun! I calculated the forces exerted on each triangle and mapped them to the triangle's vertices. To do this, I needed to figure out the derivatives of the area dA and stress tensor P.

  4. Compute symplectic Euler time integration: Finally, I implemented the time integration while accounting for pinned vertices, spring forces, and GUI boundaries. I also added damping to the simulation by scaling the velocity with a factor close to 1 (like 0.99) to ensure the motion would eventually settle down.

Testing Your Implementation 🧪

Here we have an extra starter code to test our implementation. This code provides a test scenario of stretching and compressing a rectangle so that we can see the differences between the three constitutive models and play with different values of Young's modulus and Poisson's ratio.

Plug in the Gingerman Obj👨‍🦰

Our last step would be plug our gingerman model in, and also add some explaination and user interface. Here is the result!

That's it! We made a fun and interactive 2D deformable Gingerman simulator! 🎉

Previous
Previous

AIGC: Stable Diffusion Game Assets Generation

Next
Next

Animation: 3D Cloth Collision Simulation