A 3D curved pipe is generated centered on a Smooth Spline curve.
A lot of friends on the Internet asked for this, so they wrote a demo. Of course, it was just a guide. In fact, the algorithm used to calculate the curve vertex is not very good, in some cases, the image will be distorted. I have never found the best solution, but I only have a compromise. Maybe, if there is a high hand in the number system, it may give me some theoretical guidance.
Code: |
// A class used to draw a spline curve tube, 3D curved pipe // Float ctrlpoint [8] [3] = {0.2f, 0.00f, 0.0f}, {0.3f, 0.00f, 0.0f }, {0.4f, 0.10f, 0.0f}, {0.5f, 0.20f, 0.0f}, {0.6f, 0.10f, 0.0f }, {0.7f, 0.00f, 0.0f}, {0.8f, 0.10f, 0.0f}, {0.90f, 0.0f, 0.0f }};// // M_tube.putpointdata (point, 0.02f, 0.05f ); // // // M_tube.draw (FACE); face: graphic card, line: line display // // // // |
Sample Code download: http://www.physdev.com/phpbb/viewtopic.php? T = 121