CMSC 491/691: Computer Animation

Assignment 4
Spring Mass System
Due Nov 06, 2017 at 11:59 PM

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. I have put sample input files and a skeleton program (mostly i/o) in your git repositories.

Input file format

The main input file will be in the wonderfully awesome super extensible .json format. You might want to use this format in future projects. Every since I discovered it I use it in every serious project I do. This file will specify the main simulation parameters and one or more spring-mass geometry files. Spring-mass geometry files

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 run my program here:

~adamb/public/MassSpring/massSpring input.json output-%02d-%05d.obj

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 strain limiting.

For 50 extra points implement position-based dynamics.

For 50 extra points implement clustered shape matching.

What to turn in

Turn in this assignment electronically by pushing your source code to your class git repository by 11:59 PM 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.