I am trying a couple of tutorials from http://nehe.gamedev.net, in order to learn openGL programming, I would like to position spheres along a Bezier curve such that they appear as a string of pearls. how can I position such spheres along the curve. I am drawing the curve using de Casteljau’s algorithm and hence can get the XYZ points on the curve.
I am trying a couple of tutorials from http://nehe.gamedev.net , in order to learn
Share
If your spheres are small enough relative to the overall length of the Bezier curve, you can just position your spheres at even intervals to get an appearance similar to a string of pearls. (If the spheres are relatively large then you’ll have to start worrying about sphere overlap more — not an easy problem, and probably not very instructive for learning OpenGL.)
The parameter value
tof a Bezier curve varies from0to1. To evaluate your Bezier curve at 10 locations (the ends and eight interior points) you can do something like this:Where
EvalBezier( t, x, y )fills in(x,y)for a givent. Just pickradiusto give you a pleasing result. If you want to try to pickradiusautomatically, just use half the minimum distance from the pointito pointsi-1andi+1as a rough estimate. If you do this, remember to handle the end points specially, using either only the next or previous points (whichever you have).