Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Getting more control points in my bezier

This topic is 5812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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."

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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

r(t) = SUM B_n,k (t) * p_k

n! k n-k
B_n,k (t) = (----------) t (1-t)

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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!