CS448A Final Project - Rigid Body Simulation




Not so fun without the video, huh?

Objective
My goal for this project was to create a solid framework for simulations of rigid body dynamics, based on the ideas and algorithms of the paper Nonconvex Rigid Bodies with Stacking by Eran Guendelman, Robert Bridson, and Ronald Fedkiw. My first idea was to get some boxes bouncing around, but after reading up on the algorithms necessary for collision detection between boxes using oriented bounding boxes and plane separation techniques, I decided I'd rather focus on the physics than the collision detection. So, boxes turned to spheres. I decided that my goal would be to have absolutely general frictional impulses acting on collisions between spheres and generating physically plausible animations from my results. I developed using C++ with OpenGL for the rendering.

The burning question - Why?
A lot of people asked me why on earth I would want to build a rigid body simulator that could do stuff you could probably hack up in less than 100 lines of code. The main reason is: it's all about the framework. Sure, I can write 10 lines of code that will bounce two spheres together realistically, but will that same code work if I change the initial conditions, or add more spheres, or change the angle of the floor? Probably not. And thus I embarked on a quest to make as general a simulator as possible so it would be easy to extend in the future, yet still provide physically plausible results.

Details

Results So does it work? Bring on the physics!

What this project is This project is thus far a simple simulator for rigid body dynamics, although it is a solid framework for future extensions with other types of primitives, nonconvex objects, and more complicated collisions and stacking problems. As it stands, it runs real-time simulations (on my ancient PII 350 with 32MB GeForce2 running Windows XP Pro) for simple scenes and environments that give pretty realistic results.

What this project isn't This project is not a simulator nearly as powerful as the physics engine in (1). It cannot do stacking or complicated contact resolution, and it cannot handle arbitrary convex and nonconvex objects.

Conclusions This project was a great learning experience. Although frustrating at times, I came out of it with a much better understanding of rigid body dynamics, and more importantly, a great foundation simulator for future work in rigid body physics. I recommend to anyone interested in realistic physics for computer games or simulations to spend the time to get acquainted with the formulas and build a little physics engine like this to play with.

References

  1. Nonconvex Rigid Bodies with Stacking by Eran Guendelman, Robert Bridson, and Ronald Fedkiw
  2. Physically Based Modeling Online Siggraph 2001 Course Notes
  3. Magic Software (matrix, vector, and quaternion code)