Create a tunnel in 3D space

Started by
4 comments, last by Hawkblood 7 years, 6 months ago

Hello

I am trying to create a tunnel in 3D space as follows:

1. Use a series of 3D control points to form a 3D curve.

2. Use some algorithm (?) to produce geometry for its surface, assuming a constant radius.

Is it possible, what's the level of difficulty and where do I start?

Thanks in advance for helping out.

Advertisement

More information is needed. Are we talking procedural generated content? or are you looking for a Blender tutorial?

But to answer with the answer most relating to the forum, I would use a series of Cubic or Quadratic Bezier curves, as the control points, and then spawn edge loops along the way, each with the same amount of vertices, so they are easy to connect with triangles.

If you want the tunnel to turn, rather than just sliding from side to side, you can use the derived Bezier curve to calculate the tangent. (https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Specific_cases)

Keep in mind that these curves are not inherently uniform, but if you keep the midpoints evenly distributed, it should be fairly uniform.

What framework are you using?

Thanks for the reply. What kind of information do you require?

I want to implement an algorithm that creates a tunnel in 3D space that bends and curves.

The tunnel's (i.e. cylinder's) geometry is generated procedurally. Some module X takes the series of cubic/quadratic Bezier curves as input and produces the tesselated surface area of the tunnel which I can then render.

Each point interval along the curve (you decide the interval) is a 3D point in space. If you take 2 points you can define a line segment. That line segment could have any number of points around it in a circle perpendicular to the line segment (you decide the number of points). Those points would be one or two vertices of a triangle primitive. The next line segment, using the same idea would be the other side making a set of complete triangles. Repeat this as long as the curve goes and render. You will need to make sure of the vertex ordering so it renders with faces toward the camera; or you could tell DX to cull none.

If you need code, I can help, but not till I'm home.

Thanks for the reply. Your solution is very elegant.

I think I understand it but I'll enumerate the steps anyway.

1. Form a 3D curve from a series of control points.

2. At 'n' interval, pick a point on the curve and calculate the tangent to the curve, then the unit normal.

3. Using the unit normal, form a circle around the initial point (of radius 'r') that consists of a fixed number of points.

4. At 'n+1' interval, repeat the process above.

5. Use the points on the two successive circles to form patches of geometry (quads or triangles).

6. Repeat for the entire length of the curve.

I do need code (or pseudocode) for this because the devil is in the detail.

glad to help.

This topic is closed to new replies.

Advertisement