0
\$\begingroup\$

I have my rope, and I have my rectangles.

The rope is similar to the implementation found here: http://nehe.gamedev.net/tutorial/rope_physics/17006/

Now, I want to make the rope properly collide with the rectangle such that the rope will not pass through a rectangle, and wrap around the rectangle and all that good stuff.

Currently, I have it set so no rope node can pass through a rect (successfully), however, this means a rope segment can still pass through a block. Ex:

enter image description here

So the question is, what can I do to fix this?

What I have tried:

I create a rectangle between two nodes of a rope, calculate rotation between the nodes, and get myself a transformed rectangle.

I can successfully detect a collision between rope segments and a (non-transformed) rectangle.

Create a new node or pivot point around the corner of the block, and rearrange nodes to point to the corner node. Trouble is determining what corner the rope segment is passing through. And then the current rope setup goes wonky (based on verlet integration, so a sudden change in position causes the rope to wiggle like a seismograph during a magnitude 8 earth quake.) Among other issues that might be solvable, but its turning into a case by case thing, which doesn't seem right.

I think the best answer here would just be a link to a tutorial (I simply can't find any, most lead to box2D or farseer, but I want to at least learn how it works before I hide behind an engine).

\$\endgroup\$
2
\$\begingroup\$

You should use a method of collision response to ensure that your rope segments are always not overlaping your blocks. This tutorial is a good starting point: http://www.metanetsoftware.com/technique/tutorialA.html.

It mentions 3 types of collision response techniques: projection, penalty-force and impulse-based. Projection is simpler, but doesn't take into consideration important physical info (such as velocities and accelerations), which can make the rope behave non-realistically.

Penalty-force is a mid-way on simplicity and accuracy. These methods try to avoid penetration by generating a restoring force. There is a good reference in the tutorial, which was used on Hitman: Using Verlet Integration and Constraints in a Six Degree of Freedom Rigid Body Physics Simulation (unfortunately I could not found the doc free on the web...). If you want to do this continuously (so you cannot miss collisions), check: http://gamma.cs.unc.edu/CPF/paper.pdf.

Finally, as the tutorial suggests, you can read http://graphics.stanford.edu/courses/cs468-03-winter/Papers/ibsrb.pdf for an impulse-based method, which is the more accurate.

In your case I whould try penalty-based or impulse-based methods, since you already have forces in your mass-spring system and can also take them into consideration.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Good stuff. I'm not sure that this applies to my situation unfortunately. I want to treat the line segments as a rope, whereas these would require me to treat the segments as rectangles, in which case the segment would not "wrap" around the block, it would only be pushed away from it. This would leave it with an flat segment that does not bend (not like a rope at all). \$\endgroup\$ – Colton Nov 12 '13 at 23:14
  • \$\begingroup\$ But, wasn't your rope implementation a mass-spring system? Usually, springs in these kind of systems do not bend. What you could do is to subdivide your rope on-the-fly so you can add complexity on the parts that have to simulate bend. Another idea could be to use bezier curves, but I don't know if the physical concepts of a mass-spring system whould mix well with them. \$\endgroup\$ – dsilva.vinicius Nov 13 '13 at 1:19
  • \$\begingroup\$ Yeah, I attempted to subdivide the rope at the exact point of the bend. It works, but it messes up the verlet integration (as far as I can tell), so I gave up on that idea for now. \$\endgroup\$ – Colton Nov 13 '13 at 2:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.