Masses and Springs
We're springing the massive trap, aha! (Was that a pun on setting up the data???)
In this part, we set up the basic model for our cloth that allows us to build upon it. We built a model based on a grid of masses and springs where the cloth is divided up into evenly spaced point masses connected with springs. To implement this, we first created the correct number of masses based on our cloth dimensions, assigned them positions (with a small offset if the cloth is vertical), and added those point masses in row-major order to a point_masses vector. Pinned masses were also set up. Then, springs with specific spring types were created between each appropriate pair of point masses (with pointers).
Here's how a mass at the center needs to connect to neighbors (via springs):
Here is a zoomed image of the grid in action:
Here is without shearing constraints:
Here is with only shearing constraints:
Here is with everything enabled: