
Cloth Sample
Programming Project Four: Cloth Simulation
Due Thursday, Feb 27th, 5pm
Assignment
Write a program that simulates a piece of cloth made from particles, spring-dampers, and triangular surfaces. It should include the effects of uniform gravity, spring elasticity, damping, aerodynamic drag, and simple ground plane collisions. Some particles of the cloth must be ‘fixed’ in place in order to hold the cloth up, and there must be simple controls to move these fixed points around, as well as controls to adjust the ambient wind speed.
Suggestions
- Create separate classes for Particle, SpringDamper, and Triangle, where each implements the appropriate physics for that component. Then a Cloth class would just have an array of each of the three component types.
- The Cloth class should have one or more initialization functions that sets up the arrays and configures the connectivity. That way, different init functions could set up different sizes of cloth, different material stiffness properties, or different configurations like ropes, and more.
- Tune the different forces one by one. Start with just gravity and observe the cloth falling down at an appropriate speed. Then gradually bring up the spring constant until the cloth is able to hold itself up. It may jiggle around a bunch, but shouldn’t lose control. Then bring up the damping factor until the cloth comes to rest properly. Then you can work on aerodynamic drag and ground collisions.
-
The Triangles will need to compute their normal every Update in order to do the physics. This normal can
be used for rendering as well. In addition, one can implement dynamic smooth shading, where the normals
are averaged at the vertices (Particles). A simple way to do this is:
- Loop through all particles and zero out the normal
- Loop through all triangles and add the triangle normal to the normal of each of the three particles it connects
- Loop through all the particles again and normalize the normal
- To implement the ‘fixed’ particles, just add an additional bool to each Particle to indicate it’s fixed. Modify the Particle::Update() to do nothing if the fixed bool is true. To do the user controls, add a control function to the Cloth that responds to keyboard presses and loops through all the particles and adjusts the position of only the fixed particles accordingly. The fixed bool is set through the Cloth initialization process, so that you can experiment with fixing different parts of the cloth (such as an entire row of vertices or just the corners, etc.).
Grading
This project is worth 15 points:
5: Basic cloth physics with Newtonian particles, gravity, and spring-dampers
5: Aerodynamic interactions & adjustable wind speed
3: Ground plane collision handling
2: Fixed particles and effective user manipulation
15: Total
Extra Credit:
+1: | Add the ability to simulate ropes and solid objects and do a simulation that combines all of these together such as a cubic crate dropping with a parachute. |