Jump to content
  • Advertisement
Sign in to follow this  
Mystery

Cloth simulation

This topic is 5091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Came across this over the net. Realized that it can done using a sort of physics mechanics - mass spring model. There is a something I couldn't understand though. What should be the initial values of the each particle like mass and velocity? I think mass should be easy since we can assume all particles have the same mass. But what the velocities? On first thought, I would initialize it to 0(Resting position). However on second look at the formula, it will not move at all if I do that. I realized also that we can external forces like gravity but it seems to affect only the z-component. Seems to me like the position of x and y components will not move at all. Am I missing something here?

Share this post


Link to post
Share on other sites
Advertisement
if you have wind effects, things get very dynamic. Also, if the cloth is attached to something, that might make a good starting velocity.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think neverwinter nights uses something like this. You should ask some modders for the jist of how its implimented. Dangley mesh I think they were calling it.

Share this post


Link to post
Share on other sites
Initial velocity is 0 but you can have it drop under influence of gravity and change its velocity through that no?

Share this post


Link to post
Share on other sites
Quote:
Original post by Intamin AG
Initial velocity is 0 but you can have it drop under influence of gravity and change its velocity through that no?


Yes. That was I thought so. But I think by using gravity, we can only affect the z-component of the velocity.

I believe in a 3D space, the velocity is made of 3 components rite?

Share this post


Link to post
Share on other sites
This is the formula I am talking about:

L - spring vector
l - length of the spring (scalar)
ks - spring constant
kd - damping constant
v1,v2 - velocities of spring's ends
r - rest length of the spring

F = -{ks(l-r) + kd[(v1-v2)*L]/l}*L/l

Each v should have 3 components right, x-axis, y-axis, z-axis?
So what should we initialize it at the beginning of the simulation?

If the same velocity is given to all particles, v1-v2 = 0, also l-r = 0 since the displacement is the same resulting in no extension. In the end, force is equal to 0.

This is getting really confusing.

Share this post


Link to post
Share on other sites
Alright, I may not understand all the physics involved completely (obvious if you see my other posts), but here is the general idea. Your colth looks like this with dots being masses, lines being springs, and the plusses are a flag pole to which the cloth is connected:

*-*-*-*-*-*-*-*-*+
| | | | | | | | |+
*-*-*-*-*-*-*-*-*+
| | | | | | | | |+
*-*-*-*-*-*-*-*-*+
| | | | | | | | |+
*-*-*-*-*-*-*-*-*+
+
+

Now, considering it starts off with zero velocity, gravity applies a downward force to all the masses. You're right, gravity gives each one an initial velocity of (0,0,-whatever). But, the masses on the flag pole can't move, so they stay still. The springs connected between the mass on the flag pole and the one next to it stretch. When the spring can strecth no more, it pulls the mass connected to the flag-pole-mass towards the flag pole. This, in turn, pulls each mass connected to it closer to the flag pole. See where I'm going?

If you had a cloth that was not connected to a flag pole and dropped it, in your virtual world (no wind, perfect hand timing when dropping it) then each mass would fall down at the same speed staying the same distance from each other.

Considering that the springs aren't actually springs at all, but just "connectors". If they were springy, then the top masses would fall faster upon release because the cloth was stretched due to gravity while being held up.

Basically, it's a chain reaction. One mass stays still, the others strecth away and then come back, pulling all the others with it, too. You may want to check out SodaPlay's SodaConstructor to see how masses and springs interact. Build a flag, like the one drawn with a few fixed points, then turn on gravity and you'll see what I mean.

Share this post


Link to post
Share on other sites
Quote:
Original post by DuncanBojangles
Alright, I may not understand all the physics involved completely (obvious if you see my other posts), but here is the general idea. Your colth looks like this with dots being masses, lines being springs, and the plusses are a flag pole to which the cloth is connected:

*-*-*-*-*-*-*-*-*+
| | | | | | | | |+
*-*-*-*-*-*-*-*-*+
| | | | | | | | |+
*-*-*-*-*-*-*-*-*+
| | | | | | | | |+
*-*-*-*-*-*-*-*-*+
+
+

Now, considering it starts off with zero velocity, gravity applies a downward force to all the masses. You're right, gravity gives each one an initial velocity of (0,0,-whatever). But, the masses on the flag pole can't move, so they stay still. The springs connected between the mass on the flag pole and the one next to it stretch. When the spring can strecth no more, it pulls the mass connected to the flag-pole-mass towards the flag pole. This, in turn, pulls each mass connected to it closer to the flag pole. See where I'm going?

If you had a cloth that was not connected to a flag pole and dropped it, in your virtual world (no wind, perfect hand timing when dropping it) then each mass would fall down at the same speed staying the same distance from each other.

Considering that the springs aren't actually springs at all, but just "connectors". If they were springy, then the top masses would fall faster upon release because the cloth was stretched due to gravity while being held up.

Basically, it's a chain reaction. One mass stays still, the others strecth away and then come back, pulling all the others with it, too. You may want to check out SodaPlay's SodaConstructor to see how masses and springs interact. Build a flag, like the one drawn with a few fixed points, then turn on gravity and you'll see what I mean.



Hi Duncan

Thanks for the link to the SodaConstructor. It is really cool.

Coming back to the cloth simulation, so we have an initial velocity of (0,0,-whatever) due to the gravity. The Z-component of the velocity has a value now and it will result in some kind of displacement to the particle. This will result in a stretch in the spring and so on. We can then get the force, then acceleration and finally a new velocity. SO far so good over this area. But what about the x, y component? SOmehow I don't see how it can be changed since they is no stretch in those directions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!