Texturing a rope bridge

Jul 18, 2009 at 6:04 PM

Hey all just a quick question (the solution is probably quite straight forward but my brain is not working correctly today): how would you go about applying a texture to a rope/chain you've made so that it follows the movements of the rope?

Jul 18, 2009 at 6:56 PM

Don't you think some simple lines would do it? if you add more bodies to your rope it will look more like a rope and the lines that makes up the rope will not look jagged. That is the simplest solution I can come up with without using algorithms that determine the arch of the rope using the applied impulses to each body.

You could also feed all the point positions into some sort of regression tool and up the detail on the function by taking each 5 px and find the function value for each interval and make a line between them.

More details:

The rope is basically a lot of points (body centers) and you draw it using a line from each point to the next. If your bodies are spaced 15px apart your rope might look jagged. You can then do one of two things:

1. Add more bodies to the rope. This is a question about "feel" of the rope. If you like how ropes feel with less bodies, you should go for solution number 2:

2. Use regression. Using regression you get a function that approximates the rope. Problem is that while this solution will give you a 99% correct drawing of the rope/bridge/other, it can be quite expensive in CPU time as you can end up with a high order polynomial.


Anyway, I would simply try to make a line between the bodies and see if it works out. If you make the rope too thick you will get see the corners of the rope "links" where the links meet. You can somewhat prevent this by using thin rectangles with rounded borders instead.

Jul 19, 2009 at 3:06 AM

I've managed to get a really nice looking curvy rope going using these two classes: http://pastebin.com/f66215662. It is pretty cpu intensive and I'm not sure how well it will integrate into a SpriteBatch only game, but the results are beautiful.

To use it:

  1. Create a Curve2D and a TexturedStrip
  2. Fill it's Keys. Use the the body positions and anchor position(s) of your rope / chain
  3. Each frame update the key positions and call BuildTangents()
  4. Each frame call CreateVertsFromCurve() on the TexturedStrip
  5. Draw the textured strip.


Jul 19, 2009 at 6:07 AM

Another idea might be using a skinned mesh and using the body's orientations and positions to drive the joints of the mesh's skeleton.