Jump to content
  • Advertisement
Sign in to follow this  
Xero-X2

2d Rope

This topic is 5055 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

Just to start off I'd like to state that I have no experence in physics, but I need to learn how to make a 2d rope simulation. Ive been trying it all day long, with 20 particles, I tried useing springs, but I belive my inmplmentation was incorrect, because the spring system didn't work, and the rope became infinitly long, and soon after the system crashed. so I've decided to ask for some help, and start from scratch, perticuarlly im not even sure I was doing the particles in the rope correcly, In fact I could vouch it was wrong in some why, so thats my first question, 1. could I have an explination of how Gravity, Position, Velocity and the TimeStep size interact. in the past I used something like this: Vel=Vel+Acc(gravity usually); Pos=Pos+Vel*Time; but those were simple visual particle effects and it worked fine for my requirements. 2. givin that my rope is made of seperate particles I am suppost to keep them together with a springs correct? I found the formula F=-K*(Distance-OptimalDistance) I just added this into my velocity originally, but the spring didn't seem to have enought effect to keep the particles close and the system exploded. thanks in advance for any help.

Share this post


Link to post
Share on other sites
Advertisement
I once wrote simulator that simulates big rope with really many particles. It's written in pascal but should be readable for c++ programmers.

Share this post


Link to post
Share on other sites
for every particle
vForce = 0
for every neighbour
vForce += fK * ( fDistToNeighbour - fRestDistToNeighbour ) * vDirToNeighbour
end for every neighbour
vAcc = vForce / fMass
vVel += vAcc * fDt
vPos += vVel * fDt
end for every particle

Force between neighbours is the same but opposite if the neighbours are connected with springs so there's room for optimization here.

JD

Share this post


Link to post
Share on other sites
Many thanks for both of your help, I have it working decently,

the springyness of the rope is slightly bugging me, but its not unreasonable. I did have some rather nasty problems where the program crashed from Floating Point Underflows, but I belive I have corrected it.

thanks again.

Share this post


Link to post
Share on other sites
to have a much more rigid rope (no spring), you can use Jackobsen's technique.

http://www.ioi.dk/Homepages/thomasj/publications/gdc2001.htm

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!