Assignment 3: Cloth Simulation
Due Date: Nov 3
Grade Value: 15%

Overview:

In this assignment, you'll implement a cloth simulator and use it to suit up a moving human figure. Cloth is modeled using a spring mass damper system, with springs and dampers for stretch, shear and bend.  The human figure is represented using a hierarchy of cylinders, one for each link of the body. The motion of the cylinders is obtained from optical motion capture (ASF and AMC format). We provide code to display and animate the human figure, and a basic particle system. Our particle data structure allows you to store a system of particles in 3D and add a spring between any two points. Our starter code shows you how to add a stretch spring between two points using this data structure, you'll have to implement shear and bend using this framework.  We provide code to incorporate gravity forces on the particles, you'll have to implement forces due to spring forces, namely:

In addition, you'll have to handle collisions between the cloth and the human figure. For this, you'll have to first detect collisions between a particle and a cylinder, and then perform collision response using penalty functions.  Our starter code gives you structures for positioning, displaying and  animating cylinders from AMC files. We also give you functions to constrain (attach) a rectangular piece of cloth to the hands of a walking "cylinder man".


Source Code:

The starting source code for the assignment is at /afs/cs.cmu.edu/academic/class/15464-f05/asst3/src_clothSim/

You may have to do the following to get the code running:
setenv LD_LIBRARY_PATH /afs/cs/academic/class/15464-f05/lib/


Description of code:

You'll be writing various functions within the following two classes: CCloth and CPhysEnv.

CCloth implements a cloth simulation system and has functions for creating and displaying the cloth. It has the function  CreateClothPatch that creates an array of particles (stored in the structure t_Visual) arranged in either a rectangular pattern or a skirt pattern. You'll have to modify this function to add springs to the array of particles. The function RunSim initializes and starts the particle simulator. This class also has functions for loading, displaying and setting the collision cylinders from the AMC files.

CPhysEnv implements the guts of the spring mass damper system. It has structures for springs, particles, collision cylinders, integrators, etc.  You'll have to write the function ComputeForces that will compute all the forces acting on the particle system. The starter code shows you how to implement gravity forces, you'll have to implement all the other forces acting on the particle system (springs, dampers). Our starter code implements constraint forces (to attach a piece of cloth to the moving cylinders). You have to write functions to detect and resolve collisions between the cylindrical objects and the particle system. Fill up the necessary sections of the functions: DistPointCylinder, CheckforCollisions, ResolveCollisions and ResolvePenetrations. We recommend using penalty-based methods to handle penetrations (by using a stiff spring). Finally, you should write the function Simulate that steps the simulation forward in time by integrating the particle system that you create using your choice of integrator (we provide you with Euler, midpoint and RK-4). This function sums up all the forces on the particles (including ones due to collision)  and integrates forward by one step.
Note: We have provided the function arguments with some functions (that you are supposed to fill) and not with others. Please feel free to modify them according to your style and convenience.

Interface:
Steps: First Load the actor (ASF file) , then load the motion (AMC file), load Cloth and then press the Simulate button. If everything works, the rectangular piece of cloth should swing around and be attached to the hands of the cylinder man. As the human moves around (when you press the play button), the cloth should collide against the cylinders of the legs and should move in a physically correct way. We provide you with an executable from our implementation, with all forces and collisions implemented (look for the executable clothSimFinal in the src_clothSim directory). This should run on the cluster machines. Your result should look like the one in clothSimFinal when you are done with this assignment.


 



Requirements:

Hand in:




Extra Credit:




Last Updated: Oct 13, 2005