CMSC 491/691: Computer Animation

Assignment 5
Spring Mass System
Due April 28, 2016 at 1:00 AM

Before you start

You will be doing your work this semester in a class git repository. Before you get started on any of the assignments, you should fetch yourself a copy of your personal repository following these directions. Your personal class respoitory on the UMBC GL/Linux systems is /afs/umbc.edu/users/a/d/adamb/pub/491/your-user-name.git

The Assignment

For this assignment, you must write a C or C++ program that will perform spring mass simulations. Here is a sample input file to test your system.

Input file format

Each line will begin with with either a m, s, or t. m is for mass-point, s is for spring, t is for triangle. Each m line will include the x, y, z initial position of the mass-point, and the mass of the mass-point.
m x y z volume
Each s line will give the index of node i, the index of node j, and rest length for the spring.
s i j l
Each t line will give the indices into the mass-point array of a surface triangle (which will be used for output as in the previous assignment).
t a b c
Unlike the obj format, all indices will be given assuming zero-offsets.

You can (will be able to) run my program here:

~adamb/public/MassSpring/massSpring input.ms density spring_stiffness spring_damping delta_t total_simulation_time output-%05d.obj
The command:
~adamb/public/MassSpring/springmass input.ms 10 100000 1 0.003333 1 output.%05d.obj
eems to produce reasonable output.

More details

The object will fall under gravity (starting with zero initial velocity, gravity in the z direction) and collide with a plane at z=0. Treat collisions as constraints. That is, after updating positions set masspoint.z = max(masspoint.z, 0.0). Use symplectic Euler to update the simulation through time.
v(t+delta_t) = v(t) + a(t) * delta_t
x(t+delta_t) = x(t) + v(t+delta_t) * delta_t
For force use
f_ij = stiffness * (mag(p_j-p_i) / l - 1) * (p_j-p_i) / mag(p_j-p_i) + damping * (v_j -v_i)
for the force on node i when there is a spring between nodes i and j.
Each timestep you should zero out force accumulators, then loop over springs applying forces, then update velocities and positions of mass points. If it has been more than 1/30 of a second since the last output frame, write a new obj file with the current positions.

Extra Credit

For 30 extra points implement position-based dynamics.

What to turn in

Turn in this assignment electronically by pushing your source code to your class git repository by 1:00 AM on the day of the deadline. Do your development in the proj1 directory so we can find it. Be sure the Makefile will build your project when we run 'make' (or edit it so it will). Also include a README.txt file telling us about your assignment. Do not forget to tell us what (if any) help did you receive from books, web sites or people other than the instructor and TA.

Check in along the way with useful checkin messages. We will be looking at your development process, so a complete and perfectly working ray tracer submitted in a single checkin one minute before the deadline will NOT get full credit. Do be sure to check in all of your source code, Makefile, README, and updated .gitignore file, but no build files, log files, generated images, zip files, libraries, or other non-code content.

To make sure you have the submission process working, you must do at least one commit and push by the friday before the deadline.