Continuing a Track with Expressions


Ever have your track point disappear before you're done with it? Perhaps you were tracking a point moving across the screen with the target offset such that the tracked point exited frame before the target. Maybe your track point was obscured at some point in the scene, obscured too badly for the tracker to extrapolate motion.

Other effects software might have an option for continuing the track, but in After Effects, you use a simple expression to do it. This will work only in cases where your tracked item is traveling more or less steadily in more or less a singular direction. A classic example is the sign on the side of a bus moving across frame because whether or not you do it with a corner pin, the point you're tracking is likely to exit frame before your added sign (Figure 8.31).

Figure 8.31. The wheel of the bus provides a good track target, and offsetting the track point to the fender panel behind the wheel means that our track comes into frame right from offscreen. Unfortunately, the wheel disappears behind the van that it's passing before even exiting the frame. Note the evenness of the track points. This is a perfect candidate for continuing the track.


Here I'll offer the simple trick for continuing positional data; for a more thorough explanation of what's going on, and variations on the theme (looping incoming frames, repeating a movement pattern, or looping in and looping out) take a look at Chapter 10.

For now, make sure there are no unwanted keyframes at the end of your animation, where the tracked area of the clip moved offscreen; the expression you will create pays close attention to the final two keyframes to make its estimate of what will happen next.

Find the property that contains the keyframe motion you want to continue (Position in this case), and Alt/Option-click on its stopwatch. In the text field that appears, replace the current text (position) by typing in loopOut("continue"). Yes, that's right, typing; don't worry, I won't tell anyone you were typing code in After Effects (Figure 8.32). With a corner pin, you might apply this expression to two or even all four of the corner properties.

Figure 8.32. Ladies and gentlemen, a miracle: A broken motion track has been healed with a mere line of code, and the orange target now exits frame with the bus.


Would this trick work with other parameters that don't deal with position? Of course. Figure 8.33 shows it being applied to the tail end of the track for Figure 8.26, in which Position, Rotation, and Scale were tracked to simulate 3D tracking on a zoom. In fact, this expression will work in any case where the last two frames of animation reflect a delta (change) in values that you wish to continue, ad infinitum. In Chapter 10 you'll see how it's not even restricted to the last two frames, nor is continuing the only option.

Figure 8.33. It's easy to get away with a continue loop over a short number of frames like this. What you lose over time is all of that lumpy, bumpy organic motion that you see in the graphs.




Adobe After Effects 6. 5 Studio Techniques
Adobe After Effects 6.5 Studio Techniques
ISBN: 0321316207
EAN: 2147483647
Year: 2006
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net