CS 184: Computer Graphics and Imaging, Spring 2018

Project 4: Cloth Simulator

Michael Lu, CS184-aaz



Overview

Give a high-level overview of what you implemented in this project. Think about what you've built as a whole. Share your thoughts on what interesting things you've learned from completing the project.

Part I: Masses and springs

I iterated through the grid, column first then through the row in order to order the point masses in row-major order, check if the point mass is pinned, calculate its position depending on the orientation of the mesh, and create the point mesh. For the springs, I loop through all the point masses and create the structural, shearing, and bending springs based on the grid location of the point masses.


Wireframe - no shearing constraints
Wireframe - only shearing constraints
Wireframe - all constraints

Part II: Simulation via numerical integration

I first assigned a starting value of the gravitational force to each point mass. Then I applied the spring force to each point mass by iterating through all the springs and making the appropriate calculation. Then I used Verlet integration to approximate the position update for each point mass. Finally I applied a clamp to each of the springs by 10% longer than each spring's rest length.

Increasing the ks of the springs makes the cloth stiffer and droop less; on the other hand, a low ks makes the cloth looser and fold easily. Changing the density of the cloth has a similar effect where the higher the density, the more the cloth folds as it falls. Changing the damping affects how fast the cloth tends toward its rest state, the higher the damping percentage, the slower it moves.

pinned4 cloth

Part III: Handling collisions with other objects

For the collisions, I simply calculate the point of intersection where the point mass should collide and move the position of the point mass in the direction of the intersection point, with an offset for the plane, scaled by a friction constant, instead of in the direction of the external forces applied to the cloth.

Changing the ks of the springs changes the cloth's stiffness. For a low spring constant, the cloth is looser and therefore droops lower around the sphere. Additionally, the folds in the cloth are thinner and hang more downwards than outwards. On the other hand, the higher spring constant cloth is stiffer and folds higher up on the sphere.


Sphere collision - ks: 5000 N/m
Sphere collision - ks: 500 N/m
Sphere collision - ks: 50000 N/m
Plane collision