Una herramienta innovadora para abordar las trampas de la pobreza

Para contribuir con el compromiso de Honduras de lograr las metas de la Agenda 2030, el Programa de las Naciones Unidas para el Desarrollo (PNUD), en alianza con otras agencias e instituciones, está…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Miniproject 2

Option 1. Spring-Mass Cloth simulation

I created a basic mass spring cloth simulation in Unity. At a high level, I did this by first creating a cloth mesh in Blender with the required structure. Then in Unity I accessed each vertex in the Mesh data structure and created a Mass object for it, and then for each edge in the mesh I created a Spring object for it that keeps track of which Mass objects it is attached to. Then for every Mass and every Spring per update, I updated the forces of the masses and then updated the mesh vertices’ positions based on it. The caveat of this approach is since Unity orders the mesh data based on triangles, I had no easy way of accessing the i+2th vertex for each mass for the bending springs so I just omitted them. It did not seem to have a significant effect, but is still something that my system is lacking.

I played with stiffness and damping to see the effects on the cloth.

The same cloth with spring stiffness of 1000, 5000, and 25000 respectively.

First was stiffness — the cloth on the left stretches much more, and it dips down more than the other examples. The one on the right with higher stiffness, however, looks quite rigid and has less range of movement. It seemed that stiffness affected how much the cloth was able to deform.

The same cloth with damping constants of 0.001, 0.5, and 2.5 respectively.

For damping, the cloth on the left is much bouncier, having more ripples in the fabric throughout the animation and taking much longer to settle. The one on the right with more damping immediately sinks to its resting position. To me this seemed that damping affected the bounciness of the cloth, but not its range of motion.

Cloth colliding with a sphere with stiffness 5000 and 25000.

A small extension I did was handling collisions on spheres. To sum it up, I did this by detecting that if any point was inside the sphere, then take the vector from the sphere’s center to that point, and repel the point along that vector until it was outside of the sphere again.

I noticed that the cloth acted odd when stiffness was low. It looked like at some point the cloth stretched over some threshold, which then caused the weird-looking fall from the sphere. The example on the right keeps the cloth more intact, probably because there is less stretchiness.

I also did try to play with time step and speed of simulation since I noticed that my results were kind of in slow-motion, but every time I tried altering them my system exploded, so I kept that untouched.

I implemented 3 integrators in total — Euler explicit, Verlet, and Symplectic Euler.

Euler, verlet, and symplectic integration on the same cloth.

For a relatively stable set of parameters, euler and symplectic look pretty similar. There is some jittering at the corners with euler that hints at instability, but for the most part they are comparable. Verlet integration on the other hand looks kind of whacky — the cloth is super ripply and bouncy compared to the other two.

Euler, verlet, and symplectic integration on the same cloth.

For a more unstable set of parameters, the difference becomes more apparent. After some time, euler integration explodes due to its tendency to gain energy throughout the simulation. Verlet stays stable but still has a more unrealistic look. Symplectic is both more stable and more realistic than its counterparts.

So I think that overall, euler looks pretty ok but is not very functional for a wide variety of parameters. Verlet is stable and it’s nice that it doesn’t use velocity but I guess that’s a tradeoff between realism because its results don’t look as nice. And then symplectic is both stable and nice looking, probably because it is the semi-implicit method out of the three.

Overall, it was fun to make my own cloth simulator and really see for myself how these different parameters and integration methods can greatly impact simulation.

Add a comment

Related posts:

Why the Indian Middle Class will get poorer this time

The Indian middle class, which has traditionally been a driving force behind the country’s economic growth, is facing a number of challenges that are likely to lead to a decline in its overall…

AI vs Human Writers

Artificial intelligence has brought about a significant transformation in the field of writing. The availability of chatGPT has allowed many people with no writing experience to enter this field…

Gangsters And Criminals

Around me I see the irrational insanity,. “Gangsters And Criminals” is published by Rebecca Stevens A. in Be Unique.