Bending a pipe by 'x' degrees?

Blitz3D Forums/Blitz3D Programming/Bending a pipe by 'x' degrees?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This is the easiest way to do what you want.

Assuming your cylinder is vertical:

Place a pivot in the center of the first segment of the cylinder. Ie, the middle of the circle of vertices that forms the bottom.

Place a pivot in the center of the next segment. Make it a child of the first pivot.

Place a pivot in the center of the next segment. Make it a child of the second pivot.

Repeat until all segments have a pivot that is parented to the previous pivot.

Now, create one pivot for each vertex in the second segment. (The vertices in the first segment will not move so we do not need to do that one.) Make each of these a child of the second segments pivot. Repeat this for the rest of the vertices, attaching them to their segment's pivot.

You're almost done!

Divide desired curvature by number of segments in the cylinder-1. Ie, if there are six segments in your cylinder, counting the top and bottom, and you want a 90 degree curve, divide 90 by 5. This gives us 18. So ROTATION = 18.

So, assuming a 9 degree bend, starting at the second segment, rotate each segment's pivot by 18 degrees on either the Z axis if you want a bend to the right, or the X axis if you want a bend from front to back.

Once you have done this, simply copy the new global position of each vertex's pivot to the vertex. You now have a curved cylinder.

This works because each child will rotate around the parent, and you've created a chain of children starting from the bottom of the cylinder, and the vertex pivots are parented to each section of this chain, so they rotate with it as expected as well.

It's possible to do this without one pivot per vertex, or even using just a single pivot, but it's just way easier for you to do it this way and should be plenty fast enough for your needs.