# 3D Tube or Pipe Forumula?

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, can someone tell me the formula for creating 3D tubes? (For example, to simulate a snake) I´ve tried to figure it out on paper, but i´m not sure how to put it into practive... Would be glad if you could give me some hints or a link to a website! Thanks gammastrahler

##### Share on other sites
Your question is a little bit vague. What is the goal?

I know there exist implicit formulations using an extrusion along a spline path. Perhaps for your app a facetted tube will be sufficient, so that an explicit mesh could be generated by "discrete" extrusion (i.e. going stepwise along a path and generate profiles that are to be connected to build up sections). If you choose a continuous curve as path, you may investigate curvature to get better looking results. If you have a piecewise linear path, well, then simply concatenate cones, possibly with spheres in-between to get closed joints.

##### Share on other sites
haegarr basically covered it, but I thought I'd mention that this was actually covered in some detail in the last couple of months. *goes to look for thread* ...Well, I'm not sure where the thread is, so that may be of no help to you. Anyway, the basic idea is to move a coordinate frame along a curve at regular intervals and create a 'circle of vertices' using the coordinate system at each point. These vertices can then be easily triangulated into a tube.

There are some details that have to managed though. What sort of curve you use is actually sort of secondary to the problem; all it really needs to provide is a position (evaluation) and tangent (first derivative) function. There's also the issue of parameterization; using arc length would give you slightly more even spacing at the expense of considerable code complexity, while using the parametric value directly would be much easier and would probably give perfectly adequate results.

The trickiest part is probably finding suitable frames along the curve. The Frenet frame may not be adequate, depending on the shape of the curve; a fixed-reference frame might work if the direction of the curve doesn't vary too widely; and a parallel transport frame might be the overall best choice. There's actually an article on curve frames that's very interesting, but I'm too lazy to go looking for it now. You might try googling for it though.

##### Share on other sites
To the OP,

The books Graphics Gems 1 and Game Programming Gems 2 both have two articles for exactly what you need

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 11
• 28
• 15
• 39
• ### Forum Statistics

• Total Topics
634836
• Total Posts
3019544
×