Skip to main content
GameDev.net gamedev.net
🔒 Locked

2d rope physics

Started by Hikaru May 13, 2004 at 1:08 PM 5 replies 5.9k views
Original Post
Hikaru
Hikaru
I''m currently making a little jump n'' run game, using VC++ and SDL. I need some 2d-rope physics(observe 2d not 3d) for a whip/chain and I don''t have a clue how to do this. Does anyone have some advice or an example(maybe?) thanks // Hikaru
bucheron
bucheron
It''s quite easy if you know how springs work. Create a chain of springs connected together and solve the physics at each node. You will need to find the force applied on each node (gravity and Hooke''s law) , extract the acceleration out of this and integrate over time to find the velocity, integrate again to find the position. This is a simple Euler scheme though it''s not stable with springs, you may want to look for a better integration scheme. Check this :

http://freespace.virgin.net/hugo.elias/models/m_string.htm
oliii
oliii
yeah, springs are ok, but ''springy''. the jakobsen method works wonders for that kind of stuff.

http://newads.cmpnet.com/html.ng/site=gamasutra&pagepos=button

http://www.ioi.dk/Homepages/thomasj/publications/gdc2001.htm
Everything is better with Metal.
d000hg
d000hg
If you have a mass on the end of a rope, there are two casews to consider: the rope is taut or isn''t. If it is, draw it straight and do simple mechanics to get path of mass.
If not, treat the mass as a free-flying particle under gravity. You have the positions of both ends of the rope, and the direction the moving end is travelling in. You also know the length of the rope (assuming inelastic) and from this data you should be able to generate a smooth curve as an equation.

This requires no physics apart from free-particle under gravity, and particle/stiff rod calculations which are very simple indeed.
bucheron
bucheron
You could use this idea, yeah. A rope follows a cosh function shape.

http://mathworld.wolfram.com/Catenary.html
Squirm
Squirm
A search on google for "cloth simulation" should find all you want and more. A rope is just a 1D cloth.
Hikaru
Hikaru
thanks for the help guys

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.