Maya Tips & Tricks - Mouse Capture

Few people know it, but there’s a way for roughing in animation using the movement from your cursor.

In a previous post I shared this technique for MotionBuilder. Now I’ll be showing how to do it inside Maya.

I used very simple MEL scripts. Some nodes* are deleted to make sure our scene is ready for a clean recording:

$if ( `objExists record1` )
$    delete record1;
$if ( `objExists record2` )
$    delete record2;
$if ( `objExists record3` )
$    delete record3;

Then all you have to do is pick the attribute you want to control. For translation:

$SetKeyTranslate;
$recordAttr -at "translateX" -at "translateY" -at "translateZ";
$play -record;

For rotation, the unit being used must be radians. The following code assures such condition:

$SetKeyRotate;
$string $curAngleUnits = `currentUnit -q -a`;
$currentUnit -a rad;
$recordAttr -at "rotateX" -at "rotateY" -at "rotateZ";
$play -record;
$currentUnit -a ($curAngleUnits);

Finally, for scale:

$SetKeyScale;
$recordAttr -at "scaleX" -at "scaleY" -at "scaleZ";
$play -record;

It’s possible to control other attributes, but I recommend using an auxiliary controller, as demonstrated on the second part of the video. This will lead to a better response from the software.

* The code looks for and deletes three nodes in the assumption of the user probably controlling up to three axis of movement. But adjustments might be necessary accordingly.

comments powered by Disqus