Lecture 6

Physically-Based Modelling


Witkin, Baraff, and Kass, Physically Based Modelling, SIGGRAPH 2001 Course Notes.
 http://www.pixar.com/companyinfo/research/pbm2001/


Today I'm going to continue with my overview of basic techniques in computer animation so you can get some ideas about what topics you would like to explore more deeply when we get to the paper presentations. Two of the more important things to talk about are springs and collision detection.

Springs

Last lecture we talked about particle systems where the particles acted on their own, unaffected by any other particles. Much more sophisticated effects can be produced when particles are linked together into 1D, 2D, and 3D matrices.

Hook's law spring - binary force between points a and b connected by a spring:

fa = force on a

fb = force on b

dx = position of a - position of b

r = rest length = | initial position of a - position of b |

ks = spring constant

kd = damping constant

dv = derivitive of dx with respect to time = va - vb

fa = -[ks * (|dx| - r) + kd * dv * dx / |dx| ] * dx / |dx|

fb = - fa either they are both ends being forced apart, or both being forced together

if the spring length is greater than the rest length then the particles are pulled closer together, if the string length is less than the rest length then the particles are pushed apart. The spring force is proportional to the difference between the current length of the spring and its rest length. The damping force is proportional to the difference in the velocity of the two particles

The springs will try to get themselves back into the minimum energy state, however the masses at the end of the springs may very well have other forces acting on them such as gravity, wind, or more springs.

At each timestep all of the current positions, velocities, masses, accelerations are used to work out what the new positions, velocities, masses and accelerations will be at the beginning of the next step.

Good for modelling cloth, fluids , jello, and faces.

While the springs are useful in keeping neighbouring points apart more work is needed to keep the matrix from interpenetrating itself.

some small spring exampls at http://www.myphysicslab.com/
and some nice different shaped ones at http://www.jcraft.com/jspringies/jspringies.html


Nice small cloth example at jrc313.com/processing/cloth/  This code is slightly out of date for the current version of processing but only a few lines need to be modified to get the source code working. I put a fixed copy at Cloth3.pde


More on hook's law at http://en.wikipedia.org/wiki/Hooke's_law


Collisions

Lets say we have a ball dropping onto the floor ... we can assume that the floor doesn't move. If the ball is rigid then it keeps its shape through the collision - we can assume that the collision happens instantaneously and that the velocity vector of the ball changes instantaneously. If the ball is flexible then it will deform during the small but finite time of the collision.

If the collision happens instantaneously then the velocity changes instantaneously and that's very bad for the solver so we need to stop the solver work out the new velocities and then restart the solver.

We also have the problem of a ball sitting on a brick which is sitting on tthe floor. The ball should not fall unless the brick is pulled away.

Need to detect the collision

Need to respond to the collision

Start with the simple case of a particle and the floor

at time ti it is above the floor

at time ti+1 it is below the floor

so at some time tc the point collided with the floor.

It would be nice to rollback the simulation to time c, deal with the collision, and then start the simulation up again. The easy thing to do is just move the particle back up to just above the floor and deal with the collision. One typical method falling inbetween these two is to try and find the time when the particle is within some distance epsilon of the floor. Knowing that there was no collision at time ti but that there was a collision at time ti + h then try at ti + (h/2). Keep bisecting the search space until a time is found when the particle is within epsilon distance of the floor.

Now what if we have objects instead of particles. Lets say we have convex objects - if not we can break them up into a set of convex objects and proceed. We start by computing the bounding box of each object (side of the box parallel to the coordinate axis). Then we only need to look at objects whose bounding boxes overlap. This could still be a lot of work, so we want to re-use as much information from the last time-step as possible. As long as the time steps are 'reasonably' small, the objects in the simulation should not move 'a lot' during each frame - geometric coherence (remember coherence from CS 488?).

Witness - some piece of information that can be used to quickly answer yes or no to the question 'are polyhedra A and B disjoint'

Two polyhedra do not interpenetrate if and only if there exists a separating plane between them (not this is not true of concave objects)

A given plane is a separating plane if all of the vertices of A lie on one side of the plane and all the vertices of B lie on the other side.

First time the bounding box test fails we need to try and find a separating plane - do this by exhaustively going through the faces and edges of the polyhedra in question and finding the defining face or edges

- either plane contains a face of one of the polyhedra

- or plane contains an edge from one polyhedra and is parallel to an edge of the other polyhedra

Then we can keep using the defining face or edges in subsequent time steps where the bounding box test fails and verify that it is still valid

If this test fails then we try and find another defining face or edge.

If we can not find a new defining face or edge then we know that the polyhedra have inter-penetrated. We can cache the vertex or edge that has interpenetrated and roll back the simulation to see when the collision occurred.

Simple collision example at http://www.myphysicslab.com/

Lots of detail at http://www.pixar.com/companyinfo/research/pbm2001/pdf/slidesh.pdf

A very nice recent example of a structure breaking into particles is the destruction of the tower of Barad-dur at the end of Return of the King.



You may also want to look into rigid body (no deformation [only soft bodies are deformable]) dynamics with tools such as the Open Dynamics Engine - ODE (www.ode.org) that are good for real-time simulations. With the processing power of modern computers these can produce some pretty realistic effects.

If you haven't dealt with Octrees before then you may want to look into them as well as they are very useful in multi-resolution work.
http://en.wikipedia.org/wiki/Octree



Now if you really want to make computer graphics look realistic then the math starts to get much more complex but the results can be extremely impressive. This research has some very nice videos showing more modern / complex / realistic versions of the simple spring and collision demos from above, and papers that go into detail about how it was done:
http://graphics.stanford.edu/~fedkiw/


 For more modern (complex) work on rigid body collision detection you can check out:
http://graphics.stanford.edu/~fedkiw/papers/stanford2005-09.pdf

and here is another good paper of his on water:
http://graphics.stanford.edu/~irving/papers/irving2006_rle.pdf

and if you have more interest in fluid dynamics then you can find lots of info on navier stokes equations which are used to find flow fields here:
http://www.navier-stokes.net/ and http://en.wikipedia.org/wiki/Navier-Stokes_equations


Coming Next Time

Kinematics / Motion Tracking / People


last revision 1/31/08