Getting more control points in my bezier

Started by
3 comments, last by Dark_Streak 21 years, 9 months ago
Hello, I have a few questions about bezier curves. I am planning on using bezier curves (which I have just discovered) in my game in order to give my camera fluid curved motion and my baddies a nice realistic path to follow. However, I feel the formulas I am currently using are rather restrictive, due to the limited number of control points. I am using the following bezier curve formulas: 3 control points B(u) = P0 * ( 1 - u ) 2 + P1 * 2 * u ( 1 - u ) + P2 u2# 4 control points B(u) = P0 * ( 1 - u )3 + P1 * 3 * u * ( 1 - u )2 + P2 * 3 * u2 * ( 1 - u ) + P3 * u3 Is it possible to use an unlimited number of control points, and if so would this have an exponential affect on performance? Could anyone perhaps post a bezier formula which uses, say, 10 control points? Is this the way to go about it, or should I join up multiple ''four control point'' curves in order to create larger ones? How do I do this? Cheers guys.
Advertisement
Check out nehe.gamedev.net''s bersier tutorial.

To create a spline with x control points use:

((t + 1) - t) ^ x = 1 (i think)

and each term should represent 1 control point. Usually for more control points, however, people usually string together spliens with 4 control points and connect the control points to create a smoth curve. This would allow you to create am infinitely continuous curve, without having to expand like crazy.


"Free advice is seldom cheap."
Your best bet is to move to B-splines. They are essentially a superset of Bezier curves, but you have far more control over the shape of the curve.

There are many books and online resources about them, with varying degrees of readability for the layperson. David Rogers'' book is fairly accessible.
http://www.amazon.com/exec/obidos/ASIN/1558606696/qid=1024888790/sr=8-2/ref=sr_8_2/002-7795354-4559217

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
You can also use multiple cubic beziers. It is easiest for the user if they are just plotting the end points of the beziers just like they were drawing line segments since the bezier only actually goes through the end points. As they plot the end points of the segments you procedurally generate the other two control points. At the first and last points ploted by the user the slope would be towards the second and second to last points plotted. The slope at the points in between would be the average of the direction to the previous and next point. You then just use a default distance to generate the other control points. Visually you draw a line from p2 to p3 of the first segment to p0 to p1 of the second and draw a control handle at p2 of the first segment and p1 of the second. That lets them drag the other control points around and gives them good feedback on just what they are doing which is controlling the slope through the points they plotted. You can also allow them to decouple the interior control points of the segment from the previous/next segment so they can create spikes if they want to. By default they should be tied together.
Keys to success: Ability, ambition and opportunity.
Like LilBudyWizer said it''s possible to concatenate Beziers.

For the sake to completeness I''ll answer your other question: Infinite Beziers:

For controlpoints p_0 (p with subscript 0) to p_n (p with subscript n) the Beziercurve is defined as
        nr(t) = SUM B_n,k (t) * p_k       k=0           with                  n!       k      n-kB_n,k (t) = (----------) t  (1-t)              k!(n-k)! 


Not very quick to implement, as you''d need to compute
3 factorials and
2 exponentials and that for each of the n+1 loops
you could optimize, but using splines is much easier and more efficient.





---------------------------
I may be getting older, but I refuse to grow up
I may be getting older, but I refuse to grow up

This topic is closed to new replies.

Advertisement