INSTRUCTOR: Adam Bargteil (Office hours:
By appointment, NSH 4229)
WEB PAGE: http://graphics.cs.cmu.edu/courses/15-869/
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.
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.
- Read input file and create lists of nodes and elements. Setting
positions of the nodes and indices of each elements nodes.
- Loop through the nodes and set their mass and velocity to zero
- Loop through the elements and compute
- B_m: The matrix of summed area weighted normals used for
- Add 1/4 of the mass (volume * density) of the element to each of the element's nodes.
- For (time=0; time<end_of_time; time+=dt)
- Loop over the nodes and set force accumulator to zero (this is also a fine time to add external forces, e.g. gravity)
- Loop over the elements
- Compute X/D_s from the world positions of the element's nodes
- Compute F = X * Beta
- Compute SVD of F (details in Irving et al)
- Compute stress (P) in the element
- Compute forces for each node in the element
- Add forces to each node's force accumulator
- Loop over nodes and integrate forward in time
by updating positions and velocities with an Euler
- Handle Collisions
- 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
- If there has been a collision
- Project the node onto the surface of the obstacle
- 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).
- Apply friction
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.
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.