motionModify Plugin

Description

The plugin we wrote allows the user to change the path of a set of objects that have already been animated via keyframes, while maintaining their positions and orientations relative to the path. It was inspired by similar work by Professor Gleicher.

The plugin works with objects that are ungrouped and have already been animated, a situation that the built-in motion path facilities of Maya don't easily accomodate. The plugin creates a NURBS motion curve (using Maya's builtin functions) that the user can edit to change the objects' path. It then calculates each object's position and orientation relative to the motion curve throughout the requested timeframe and sets things up so that these relative parameters will be preserved as the motion path is changed. For example, for an animation of a person walking sideways, if the originally-straight path is curved by the user, the figure should continue to walk sideways along the curve.

Implementation

The first step is to create a NURBS curve that follows the path of the selected objects. This is not as easy as it sounds. When multiple objects are being affected, each may have its own path slightly different from the rest. Do you pick one object near the center to follow? Or do you try to follow the center of mass of all the objects? In this implementation, we chose the easy method of following the first selected object. Another question is how closely to follow the motion of the objects. Do you want to capture every precise move? Or do you want to capture only the general direction of movement? Again, we chose an easy method: follow the object's path exactly at the keyframes.

Getting a NURBS curve to closely follow an object's path can be difficult. Our approach was to have the curve match the object's postion at all the keyframes and hope it stays close in between. However, this was not always the case. Sometimes, added keyframes helped; sometimes, they made it worse. Sharp turns can be especially bad.

Once we have the motion curve, we need to calculate each object's position and orientation relative to the curve. For each parameter, we look at every keyframe, find the appropriate place on the curve, and calculate the relative value. The parameter's AnimCurve is then modified to reflect these new values.

These calculations are based on the Frenet frame for the appropriate place on the curve. We get the Frenet frame using the tangent to the curve and the y axis. To get the object's relative rotations, we take the rotation matrix of the Frenet frame and multiply the object's rotation matrix by its inverse. To get the relative translations, we take the difference of the object's position and the point on the curve and project it onto the axes of the Frenet frame.

Next, a new transform node is created. Its inputs are attached to the NURBS curve via a motion path node (with follow turned on). The objects' transforms (which now have relative translations and rotations) are then reparented under the new transform.

The Experience

Getting the plugin to work right took a lot of trial and error. The hardest part was calculating the relative rotations. We tried many methods (as can be seen in the code) which worked on simple test cases but broke on more complicated objects and movements. These problems plagued us up until the last minute.

Our original plan was to have a ballerina dancing around and jumping in the air, and then have him do the same moves along a different course. But we discovered too late that the human figure we had wouldn't work properly with the plugin as written. The plugin assumes that all the objects it's animating are independent. This wasn't the case with our human since the objects we were modifying--the body, hands, and feet--were connected. We found that any major turning of the body in the original motion resulted in the figure becoming a contortionist after the plugin ran. Jumps caused the the NURBS curve vary radically from the original motion. We had to settle for a straight-line walking motion as the original movement.

Files

Return to main page