I don't know what Cut The Rope did, but it looks pretty simple to me. You can implement a rope in either 2D or 3D like this with some very simple position based dynamics. Say your rope is, like you said, an array of points that are all connected from one to another. I'm assuming we can use one end of the rope as the "anchor" that will be attached to something, like the level or a character.
Lets define a distance constraint that will make sure that for any point a on the rope, the next point b will stay within a specified distance:
void SolveSegment( point a, point b )
dist = distance( a, b );
if ( dist != 0 )
Vector correction = (MaxDistance / dist - 1.0) * (b - a);
if ( a is not anchor )
a.position -= 0.5 * correction;
b.position += 0.5 * correction;
b.position += 0.8 * correction;
You can continually run this on all the pairs of segments. Care should be taken to make sure the "anchor" point, or the first point on the rope is always passed in as the a parameter.
Each point on your rope should look something like this:
Now all that's left is to integrate the positions of the rope based on their velocity. You can calculate velocity based on a point's previous and current position. You can probably get away with symplectic Euler and don't need to do any fancy integration.
So when you solve the entire rope you'll do something like this:
void Rope::SolveRope( dt )
// Use velocity to integrate all points. They can have different masses if you like.
// Apply gravity in here too.
Integrate( dt );
for each point a and b in rope
SolveSegment( a, b );
// Use previous and current position to set velocity
CalculateVelocity( 1.0f / dt );
This is about all you'd need for a pretty nice rope! It can be attached to the world or onto a moving character, and will wave around appropriately and not stretch a whole lot. You can adjust behavior by changing the SolveSegment function to do whatever you like. You can also add in some kind of collision detection on the segments, if you were interested in doing this. It might be simpler to have pretty short segments and just approximate the collision detection with a circle on each point.
You can thank Erin Catto for providing resources I learned from, which let me write this post
Edited by Randy Gaul, 11 June 2014 - 11:48 PM.