The goal for this project was to utilized spring physics to expand multiple simulated ropes into a cloth simulation. The cloth will be responsive in a 3D environment to input from the user.
A cloth can be simulated as multiple ropes/springs that connect both vertical and horizontal nodes into a squared lattice.
The cloth also can interact with an environment object, in this case a blue sphere.
Originally the cloth was created in 2D space in order to implement the more simple spring/rope mechanics. The simulation was then updated to 3D
I chose an interesting texturing mode from Processing by calling blendMode(SUBTRACT) in setup(). Processing describes this mode as "subtractive blending with black clip: C = max(B - A*factor, 0) ". I thought the result was unique and interesting since the colors were seemingly inverted. This was more pronounced after lowering the alpha levels and helped to show to 3D interactions of the cloth with the sphere.
We had previously used a Camera class written by Liam Tyler for CSCI 5611. I only tuned a few parameters for a better starting camera location. All credit for this goes to Liam Tyler.
I wanted to create a continuous interactive simulation, rather than simply letting the cloth fall onto an object. Therefore, I use a sphere to interact with the hanging cloth that is moved around in the x and y coordinate while holding the mouse button down and change the z coordinate by use of the mouse wheel. If you lose your sphere or just want to reset the simulation, you can press "r" to do so. The simulation starts paused and you can press the spacebar to pause/unpause it.
Due to difficulties (which are explained in a later section), my simulation best interprets the cloth as a heavier blanket/curtain.
Time - Feature
0:00 - Cloth Simulation/Multiple Ropes
0:15 - User Interaction
0: 23 - 3D Implementation and Rendering
0: 43 - Realistic Speed
3D Implementation - I originally started using a custom Vec2 class used many times in CSCI 5611. The simulation was looking great until I moved into 3D with the built-in PVector class. Everything slowed down considerably and I had to do a lot of debugging to figure out how. This wasn't an FPS issue, but rather the simulation was simply updating so slowly it was like the cloth was static with no forces acting on it. After adjusting the frame rate and the number of times the simulation updates in draw(), I was able to get a more realistic updating simulation.
Air Drag for Cloth - I don't think my implementation was correct, so I left this out of my final iteration. Commented or uncommented, my simulation looked to run the exact same!
Parameter Tuning - The bane of my existence, or at least for my unit 2 project. There's so many variables and equations to consider with this project that it seemed like I had tumbled into a rabbit hole. I wasn't able to go back to my previous version that was working (mainly the switch from 2D to 3D. Also noted that git could have been real helpful here) and I was so lost in my parameters, I needed to go consult someone who knows what they were doing. Many thanks to Dan for his invaluable help in debugging my program.
Continuous Collision Detection - This was something I wanted to implement at the end in hopes that it would enhance the realism of my project. Unfortunately I didn't have enough time to thoroughly tune this, even when I was sure my equation and code were correct. In the end I decided against trying to implement this as I feared I would only end up in the same rabbit hole as my other parameter tuning experience had done to me.
Equations for spring forces and collisions are based on similar code provided by CSCI 5611 here. The camera class included was developed by Liam Tyler for CSCI 5611 with only some parameters tuned by me.