Verlet Rope

Blitz3D Forums/Blitz3D Programming/Verlet Rope

Buggy(Posted 2008) [#1]
Hey all. For maybe the 5th time I sat down and vowed to get a verlet demonstration working... and I'm pleased to say that this time I got farther than ever before. My problem (well, one of them) is that my verlet ropes/chains seem to have a lot of excess energy in them and they take a good minute or so of thrashing around before they settle down. I'm not sure if this is the problem, but I have one link in the chain that's "pinned" to the background and shouldn't move. Looking at examples, it seems that the way to do this is to set the chain's acceleration at zero. But of course when I do this, the tugging of other chain links moves it around slightly. How to I keep it firmly pinned?

Thanks in advance.


Stevie G(Posted 2008) [#2]
Introduce an inverse mass property to each particle. The anchor point should have invmass = 0 and constraint relaxation should be weighted based on each particles invmass meaning that the anchor stays in place.

You will also have to ensure that particles with invmass = 0 are ignored during the update verlet phase.

Also, do you introduce drag into the system? If not then you should to ensure that the energy in the system disipates quicker.

If that doesn't make sense, post your code.

Stevie


Buggy(Posted 2008) [#3]
Thanks a lot for the reply.

Oops! I see in my above post that I said "set the chain's acceleration at zero," when I meant the chain link's acceleration.

That being said, all of the examples I've seen with an invmass just use it to make the pinned link's mass "infinity" (zero acceleration) and the other links have normal acceleration, which I think is what I'm doing, but without a mass value.

When you say that the pinned link should be ignored, is this for the phase where neighboring links "tug" at it? I think I tried to ignore this, but I got weird things, like the chain mysteriously growing to an infinite length.

Yes, I use drag.

I'll keep fiddling, and if I can't do it, I'll post some code.


Buggy(Posted 2008) [#4]
So I got it to work... finally!

I had been using the 2D constraint code that's on Wikipedia, but it had for some reason been giving me a lot of excess energy in the system that would make things thrash and float around weirdly. I changed my code to something like the verlet chain constraint code that someone posted, and it works like a charm (99% of the time).

My new question is more of a brainstorming one... say I have a chain, and I want a projectile to break the chain and have the chain react (not just breaking, but also being pushed in the direction of the projectile). What are some ways to accomplish this?

My ideas are to (a) test for collisions between the chain links and the projectile. If there is a collision, set the colliding link's velocity (lastX and lastY values) to match the projectile's, update the chain (so that nearby chain links are also affected), and then break the chain off at that link. The problem with this method is that nothing will happen if the projectile slips between the chain links.

Alternatively, I could (b) test for collisions between the projectile and the line between the links. If there's a collision, change both nearby links' velocities, and then break the chain there.

I could also (c) test for collisions between the projectile and the line between the links, but if there's a collision, add two identical new links at the point of collision, set their velocities, and break them apart.

I'm pretty sure C would be most realistic, but also the most difficult to code and the most likely to cause errors. Right now I'm leaning towards B, but I'd like to know what you guys think. I've never really done this stuff before, so there's most likely a much better way to do it all, and I'd be interested to hear what others have done in the past.

Also, in rereading this post, I see that I've done a horrific job trying to explain things, and I apologize.