Animating the Gears

The objective of this tutorial is to create a simple Gear system that is simple to animate and easily modified. It would be far too tedious and time consuming to keyframe the rotation of gear01 - gear05 + TranslateY of door. It would be even more tedious to modify it several times if your supervisor required it.

For that reason, we'll create a system that only requires the animator (you) to animate gear01.
Select gear01 and create the following 2 keyframes (Fig.30).

Fig. 30

Play the animation and check that gear01 rotates 10 times.

Creating the MELScript

MELScript is the programming language used in Maya. An expression is a MELScript that runs every frame and allows you to create animation.

The next step is to write a MELScript that calculates the rotation value for each gear (gear[2] - gear[5]). We'll start by creating and explaining the MELScript first, and then show you how to use the Expression Editor later in the tutorial.

MELScript for gear02

In Fig.31, cog10 is paired to cog20. When cog10 is rotated, cog20 will rotate at 1/2 the speed.

Fig. 31

This can be summarized as a ratio: cog10/cog20=0.5 (10/20=0.5). The MELScript to rotate gear02 by 1/2 the rotation value of gear01, in the opposite direction is:

gear02.rotateX=gear01.rotateX*-0.5;

MELScript for gear03

In Fig.32, cog10 is paired to cog40. When cog10 is rotated, cog40 will rotate at 1/4 the speed.

Fig. 32

This can be summarized as a ratio: cog10/cog40=0.25 (10/40=0.25). The MELScript to rotate gear03 by 1/4 the rotation value of gear02, in the opposite direction is:

gear03.rotateX=gear02.rotateX*-0.25;

MELScript for gear04

In Fig.33, cog20 is paired to cog30. When cog20 is rotated, cog30 will rotate at 2/3 the speed.

Fig. 33

This can be summarized as a ratio: cog20/cog30=0.66 (20/30=0.66). The MELScript to rotate gear04 by 2/3 the rotation value of gear03, in the opposite direction is:

gear04.rotateX=gear03.rotateX*-0.66;

MELScript for gear05

In Fig.34, cog10 is paired to cog30. When cog10 is rotated, cog30 will rotate at 1/3 the speed.