This is a simple Expression setup that animates a single child between two moving parents. The issue of multiple parents was first raised when I needed to extend a greenscreen camera track (imported from SynthEyes) into a much longer entirely-CG intro. The last half of the animation had to match the 3D tracking information from the live action, but the first half needed to extend far beyond the original motion path both in terms of distance and length of time.
One possible option was to parent a second camera to the first, and animate the extension from there. However, the motion couldn’t blend from the smoothly animated intro to the more organic motion of the live action camera track, nor would it be easy to make the necessary adjustments for the first half (where the live action camera was off to the side of a scene that was supposed to be centered).
Lightwave has a keyframable parenter, but it can’t interpolate between the parents; it just jumps from one to the other.
The best solution I’ve found so far is to use Lightwave’s expression system to blend between two values based on the value of a third object. It’s like variable parenting, but doesn’t use parenting and best of all isn’t limited to strict relationships!
This will blend between the X channels of Null1 and Null2, based on the Y position of Null3. Lightwave often operates in meters, so
Y=0 m will parent fully to Null1, and
Y=1 m will parent fully to Null2. The code can be applied to any channel, so long as the Position/Rotation values are correctly changed (Position.X, etc… Rotation.H, and so on…).
Set up your scene, two parent objects, target object, and control object; for this tutorial I’ll be using Camera1, Camera2, CameraFinal, and NullMix, but any naming convention will work. The objects don’t even have to be cameras, Lightwave doesn’t care so long as the names are unique.
It helps if the objects are animated, otherwise you’re not going to see much from the code below! Keep in mind that NullMix should only move between 0m to 1m, in whatever axis you want to use to control the blending. The example code below uses the Y axis.
The First Expression
With CameraFinal selected, open up the Graph Editor and select the Expressions tab. Create a new expression and paste the following into the
Value field (all one line):
Pressing the return key will enter the code. Once that’s done, you should probably rename the expression to something meaningful, such as CameraX.
Make sure the CameraFinal X channel is selected in the Graph Editor, and choose “apply” from the expressions menu. This will link the code to the channel, and let you preview the resultant X positions in the graph.
Find your four items in the Objects tab, and shift-doubleclick each of the channels to load them into the Graph Editor. This will let you compare the two parents’ paths and edit the NullMix values to smooth the transitions in the resulting motion.
The Rest of the Expressions
Repeat the code for Position.Y, Position.Z, Rotation.H, Rotation.P, and Rotation.B. You should end up with six expressions:
That’s it! The final camera will smoothly transition between the two parents based on the animation of the mixer null. You can change the mixer null channels as well to give more detailed control per expression, such as using
[NullMix.Position.Z] for the Rotation expressions, allowing the timing and animation curves of the mix to vary from channel to channel.
When I’m dealing with motion tracking data, it is sometimes helpful to parent the tracked camera to a null, allowing me to move the entire block of animation in the scene, usually to better align it with the digital scene. The expressions, however, will ignore the parented position of the camera and use object space instead. To adjust for this, you can add the parenting null with code similar to this: