Physical Simulation for Computer AnimationAssignment 2 Computer Science Department Entertainment Technology Center Carnegie Mellon University

INSTRUCTOR: Adam Bargteil (Office hours: By appointment, NSH 4229)
WEB PAGE: http://graphics.cs.cmu.edu/courses/15-869/
WIKI: http://graphics.cs.cmu.edu/courses/15-869/wiki

For this assignment you will implement a basic deformable body or cloth simulator. Though you are given the option here, I strongly encourage you to do deformable bodies unless you have a good reason to prefer cloth. The easiest approach is probably to follow Irving et al. You can also see Teran et al. for a few extra details.

Just to help get you started here is an overview of the simulator.

1. Initialization
1. Read input file and create lists of nodes and elements. Setting positions of the nodes and indices of each elements nodes.
2. Loop through the nodes and set their mass and velocity to zero
3. Loop through the elements and compute
• volume
• Beta/D_m^-1
• B_m: The matrix of summed area weighted normals used for computing forces.
4. Add 1/4 of the mass (volume * density) of the element to each of the element's nodes.
2. For (time=0; time<end_of_time; time+=dt)
1. Loop over the nodes and set force accumulator to zero (this is also a fine time to add external forces, e.g. gravity)
2. Loop over the elements
1. Compute X/D_s from the world positions of the element's nodes
2. Compute F = X * Beta
3. Compute SVD of F (details in Irving et al)
4. Compute stress (P) in the element
5. Compute forces for each node in the element
6. Add forces to each node's force accumulator
3. Loop over nodes and integrate forward in time by updating positions and velocities with an Euler step.
4. Handle Collisions
1. Loop over the nodes checking to see if the node has collided with anything. I suggest starting with just a plane and ignoring self-collisions at first.
2. If there has been a collision
1. Project the node onto the surface of the obstacle
2. Set the normal component of its velocity to the velocity of the obstacle (e.g. zero for a stationary obstacle). Don't do this if the node was already moving away from the obstacle (unlikely).
3. Apply friction
Here are some meshes to get you started. A line that begins with a "v" gives the 3D position of a node in the mesh. A line that begins with a "t" gives the indices (starting from zero) of the nodes of the element. The original star mesh had problems, here is a fixed version. The bunny may still have problems. I've just added some new meshes. If you are frustrated by small, slow timesteps, I recommend trying some of these meshes. The new meshes were generated with NetGen and should all be high quality. I used this code (pipe the .vol file to stdin in and pipe the output to the .mesh file, e.g. "netgenToMesh < foo.vol > foo.mesh") to convert from NetGen's format to my usual .mesh format. Feel free to make your own models with netgen. New Meshes

### Rendering

Its a good idea to render just the surface mesh. Here is some sample code to extract the surface mesh. Its ripped out of my source file, so it will probably not "just work." There is also code to read the input file here.

### Debugging Hints

Take a look at teh various quantities you're calculating. If your object is just floating in the air (i.e. no collisions, no external forces), F should be nearly the identity. The forces should be nearly zero. Etc. If you apply gravity, the forces should be equal to gravity. If you're simulation is exploding, try decreasing the timestep. Additionally, try applying known deformations, e.g. multiply all the positions by 2 and see that your object shrinks back to its rest state.