🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Tube extrusion along spline path

Started by
16 comments, last by Alessandro 4 years, 7 months ago

Did not read the thread, but made this to prevent flipping a wile back: 

 

Advertisement

@Alessandro: It looks like the code JoeJ provided uses the parallel transform frame, so if you're looking for an example, that might be of help to you. (Be aware that JoeJ's code includes some other things as well, like correction for seamless looped cylinders, etc. If you don't need those features, your code can be quite a bit simpler, as there isn't that much to the parallel transport frame itself.)

9 minutes ago, Zakwayda said:

Be aware that JoeJ's code includes some other things as well

Yeah, likely the code section below the comment: // distribute the angle defect correction over the whole spline - otherwise the last segment could appear twisted mismatch the first

It is needed if the spline forms a closed loop to ensure the vertices are connected and there is no visible gap.

It is also needed, e.g. if there would be user control to set both starting and ending orientation of the shape on a open spline.

Thank you very much @Zakwayda and @JoeJ, but honestly I have difficulties understanding all the code posted in the link above and how to adapt it to my situation. I'm going to re-read what you guys suggested, run some more experiments and show how things go...

17 minutes ago, Alessandro said:

Thank you very much @Zakwayda and @JoeJ, but honestly I have difficulties understanding all the code posted in the link above and how to adapt it to my situation. I'm going to re-read what you guys suggested, run some more experiments and show how things go...

There aren't that many steps involved in the solution in question, but it might help to break things down. Here's one way it could be broken down:

- First, you need the positions along the curve that you want to use, and the tangent at each position. If you haven't already done so, it might be worth computing just that data and then visualizing it to make sure it's correct (e.g. draw the curve as a series of line segments connecting the positions in one color, and draw line segments representing the tangents in another color).

- You'll need a way to build an initial (partially arbitrary) orientation given the first tangent vector. JoeJ showed one way to build such an orientation in matrix form.

- The rest is easier to do with quaternions, so you'll need a matrix-to-quaternion function in order to convert the initial orientation from matrix to quaternion form. You'll need quaternion-to-matrix as well. (Most math libraries include quaternion-to-matrix, although matrix-to-quaternion is a little less common.)

- You'll need a quaternion 'rotation arc' function. JoeJ's code appears to include a version of this. (Maybe the math library you're using includes it as well.)

If you get all that covered and are still stuck, feel free to ask, as the rest is fairly straightforward and should be fairly easy to explain.

Thank you very much for all the help, really. You are right, I need to visually debug what's going on, otherwise is difficult to understand things. I already have a suspicion, as you suggested, that the normal vector get messed up along the spline points, so I'm going to display those and get back with more information...

Thanks to all the suggestions and help, the issue is finally fixed. I basically built the tangent and two bi-normals, and used these last to calculate the new ring points at each position. Now the tubes are generated correctly without anymore twist issues.

This topic is closed to new replies.

Advertisement