Animation progression

So, since luckily this is a fairly light week for me, I'm getting some work done on this whole animating-the-cockroach-feet bit. Programming is fun but time-consuming.

Of course, the problem I'm working on right now is smooth, realistic keyframed animation. I was worried it would involve programming all kinds of ugly calculus for the interpolation, but a conversation with the president of our student chapter of the ACM, who knows something about practically any type of programming you care to mention, quickly dispelled that fear. You do it with Bézier curves, which are essentially (this is my inexpert take on it) weighted sums of localized polynomials over a set of control points.

If that made no sense, don't worry. I couldn't for the life of me do anything in-depth with the math or tell you why it works, but it's reasonably easy to apply once you know the algorithm. The upshot is that you get pretty curves, as follows.

We Got Splines

The green line is linear interpolation -- actually another Bézier curve, but it reduces to a line because it's only summed over the endpoints. The purple line is an actual curve (obviously) specified with four control points: the two endpoints and two extra points in between. This actually is a point-by-point graph of my Bézier function -- I'm not using GL's built-in evaluators because I need to retrieve specific values along the plot for use inside my program.

For those of you who aren't graphics programmers or animators: If you picture this as a graph of position (y) against time (x), you can see that position changes very slowly at first, then rapidly toward the middle, and then slows down again as it approaches its final position. In fact, the curve can be varied quite easily in a number of directions, allowing me to achieve the proper rate of change in the roach's movements at any given moment. All I have to do is use the output of this function in my animation routines.

Unfortunately, this necessitates a rewrite of my animation routines and keyframe-specification files. But hey, I thought the curve was going to be the hard part, and it only took me an hour and a half to program. Programming this may not be nearly as difficult as I feared. Specifying the keyframes and the curves between them, on the other hand...

Trackbacks

Trackback URL for this entry is: http://blog.case.edu/maw33/mt-tb.cgi/894

Comments

Post a comment