Thursday, August 18, 2011

My First Animation Editor (With Bezier Curves)

I've been working on this on and off for a while now. Ever since I got Maya talking with the Arduino. I thought to myself, "wouldn't it be nice if there was a free app that wasn't bloated and designed just for animating parameters?" Well, I just hit my first milestone for this goal. Eventually I would like to add multi-segment Bezier Curves. Then I would like to have multiple channels of animation. It's all written in Processing so serial communication with the Arduino should be simple. The trickiest thing to get working was the lookup of the Y value on the curve based on where the Time Slider is. Many thanks to Ben Paschke for finding the function I needed in the Blender Source Code and helping me port it to Processing.

There is another Processing Tool out there called Timeline but it's heading in a different direction than I am and I wasn't a fan of it's mixed languages and non-realtime Y lookup function. Plus, I thought this would be a good challenge to set for myself considering the industry I am working in :)

Hotkeys:
Spacebar = Play/Pause
J = Play Forward
K = Play Backward
L = Pause
Left Arrow = Step Backward 1 Frame
Right Arrow = Step Forward 1 Frame 

Click and Drag to Position the Handles or Timeslider

10 comments:

benp said...

Mate, that's wicked!
It sure was mind-bending trying to work it out, eh?
Processing draws that bezier soo nicely! Do you draw the bezier with lots of linear segments, or is there an implicit bezier line primitive?
Nice work!

Dan Thompson said...

Thanks man!

It's an implicit bezier line. But still have to do full bezier curve calculations for the lookup function anyway.

Marcel said...

Very nice Dan. Well done.

I'm still plugging away at my basic moco rig. It's had a complete hardware and software rebuild/rewrite.

The main problem I've had, and I'd welcome your thoughts on this, is it's one thing to know where the dolly needs to be, but it's another thing to get it there smoothly with steppers. It's not such a problem with servos because they have absolute values.... "go to 47 degrees".

It's a fairly simple thing for timelapse but when it's realtime it's another game altogether.

Presently, my steppers know where they should be and will adjust their speed up or down depending on how far off the target they are. It works reasonably well but it means they're never ON the curve - always lagging behind it. For what I'm doing I think it'll be good enough but I'd like to know how I could improve it.

kr

Marcel

Anonymous said...

Assuming your stepper motor starts out on the curve, the speed should be based on the derivative of the curve, not on your distance from the target. Fortunately, it's easy to compute derivatives of Bezier curves.

Dan Thompson said...

Hi Marcel,

Yes real world physical limits are always a pain when you compare it to computer animation where there are no limits! :)

Steppers and servos can both have position control systems. But yes there is a big leap from an A - B transition to a multi-keyframe move. Position Feedback loops are what you need in this case. Google PID control and you'll find heaps of info about it. Let me know once you've figured it all out. Then you can teach me too! :P

Tisham Dhar said...

When building our quadcopter we did some hardware in loop PID tuning with Matlab + Simulink. I have been meaning to put together a similar solution with opensource components, but currently stuck in Java + Gl land.

dail8859 said...

Wow! Way to go Dan! That's pretty impressive. I had been wanting to do something like this for a while but always dreaded porting the code from Blender. I might have to play around with this now ;)

Dan Thompson said...

Yeah I'm pretty excited about the possibilities too. Still needs lots of optimisation. I want to nail frame rate playback conrol and implement image buffers for efficient redraw of curves. Then I feel like there will be a nice scalable foundation to work from.

Kolin Pope said...

Hey Dan! You have some really incredible stuff here on the blog. I'm an animator recently working with some arduino/servo stuff and i'd love to ask you a couple questions about your upcoming projects -- where can I get in touch with you? (or just shoot me an email at kolin@tmog.net) Thanks man!

Anonymous said...

Why you didnt use build function bezierPoint()?