The Daily Click ::. Downloads ::. Miscellaneous ::. Simple Bézier Curve Example
 

Simple Bézier Curve Example
Author: Pixelthief Submitted: 31st December, 2008 Favourites:0
Genre: Miscellaneous Downloads: 400
Rated:


I noticed there was a lack of any examples for DeadmanDine's great Bézier Curve article, so I thought I'd throw this together since a lot of people seemed to want one. Its just an extremely basic, single event example of how to do a Bézier Curve; Cubic in this one. I wanted to throw together a recursive engine for N-Degree curves, but it really seemed unnecessary, since nobody is ever going to use anything above 2 "Helper Points". If anyone really needs one, I could throw one together on request; its just a matter of appropriating enough variables, something I could probably do using the MagicDeque object.

Also, I included a Snippet for Sketchy's Snippet Manager, which is ENORMOUSLY useful if you intend to actually use Bézier Curves for projectiles in your game. Doing this, you can easily put them together without needing any extra active objects.

1st Frame is a naive, 'all object' implementation, 2nd Frame is the derived formula that DeadmanDines included in his article. Massive kudos to both of those characters

Review This Download



 


http://claniraq.googlepages.com/Bezier.zip (11.76 kb )



Posted by Pixelthief 1st January, 2009

that snippet might prove too long for the MMF2 evaluator. I might post a new one where you have to use 'two halves' of the equation, storing it as a temporary variable to work around
 
Posted by -J- 1st January, 2009

This is great

Maybe you could design a Bezier Curve Widget and use the N-Degree curves thing? These curves are so handy, and you can calculate the object's average position over "time" and get another object to move on a linear bezier towards that point constantly, which would create a cool "following" object that could follow the main object around but never actually hit it.. or something

Also, wikipedia has one of those crazy undecipherable formulas on it's bezier curve page that can apparently calculate a bezier curve to the Nth Degree. I don't know if it's possible to translate into MMF language, I didn't really look at it that much...

Here's a semi-complicated thing I made with bezier curves, it only uses 3rd order but it looks pretty cool

http://download47.mediafire.com/peua3md0yzgg/mwyznzn2vme/Bezier+Curves.mfa
Comment edited by -Julian- on 1/1/2009
 
Posted by Sketchy 1st January, 2009

Someone still uses Snippet Manager!

It's always nice when someone makes an example to help people understand complicated ideas, so thanks

Bezier curves still confuse me though - how do you know where the "helper" points go?
 
Posted by -J- 2nd January, 2009

It doesn't really matter where they go, the curve will always go from the first helper to the last helper, with the helper/s in between redirecting it based on where they are. So you can put them anywhere but their position in relation to each other will affect the curve in different ways
 
Posted by Pixelthief 2nd January, 2009

imagine bezier curves as a function that gives a funky line from point A to point B. The line will ALWAYS pass exactly through points A & B, but will curve towards any helper points you define. So you can put the helpers anywhere, and the line will still always go from A to B.
 
Posted by Pixelthief 4th January, 2009

Hey I took time to use the factored version of that equation to make a much better snippet, because that other one was too long and will make 'expression too complex' errors. This should work muuuuuch better:

http://claniraq.googlepages.com/BezierCurve.zip

Comment edited by Pixelthief on 1/4/2009
 

 



Author

Favourite



Advertisement

Worth A Click