Chapter 5. Animation

Animation in Maya is accomplished through a variety of tools and techniques. The goal of this chapter is to show you how to use the tools in Maya to animate the attributes of various nodes. Gaining an understanding of how you can solve problems in Maya is essential to animating characters and scenes in a believable and entertaining way.

In this chapter you will learn to:

  • Create a simple rig with joints and constraints

  • Use Inverse Kinematics

  • Animate with keyframes

  • Use the Graph Editor

  • Preview animations with Playblast

  • Use driven keys

  • Animate with expressions

  • Animate with motion paths

  • Use animation layers

Using Joints and Constraints

Most of this chapter is devoted to exercises that animate a simple mechanical bug model. Animation and rigging are closely related skills. Even if you don't intend to do much of your own rigging, you'll have an easier time understanding how to animate if you know what goes into creating a rig. Chapter 7 delves into more advanced rigging concepts; in this chapter you'll learn some basic tools and techniques for rigging to get you started.

When rigging mechanical objects and robots it's not always necessary to use joints; you can parent the parts of the object together in an organized fashion and then set keyframes directly on the geometry. However, because of the built-in hierarchy of joints as well as the many kinematic controls available, using joints can make rigging and animating mechanical objects easier, even if you don't intend to bind or skin the geometry so that it is deformed by the joints.

Joint Basics

You create joints using the Joint tool (from the Animation menu set choose Skeleton

Joint Basics
Two joints are placed on the grid.

Figure 5.1. Two joints are placed on the grid.

Joints are most often animated by rotating the parent joint or using Inverse Kinematics, which orients the joints based on the position of a goal called an End Effector. This is discussed later in this chapter. Joints can also be animated by placing keyframes on Translate or Scale channels; however, this is slightly less common.

Joints are usually placed in a hierarchical relationship known as a joint chain. Joint chains can have many branches and numerous controls depending on the complexity of the model.

A joint is a type of deformer that typically influences the shape of nearby components depending on how the components of the geometry are bound, or "skinned," to the joints. Since the bug in these examples is mechanical, the joints do not need to deform the geometry of the model. You can simply parent the pieces of the leg geometry to the individual joints. Skinning geometry to joints is explored further in Chapter 7.

Point Constraints

A point constraint uses the world space position of one object to control the world space position of another object. World space coordinates tell exactly where an object is in relation to the rest of the scene. This is different from object space coordinates, which are relative to the object's initial position.

For instance, if you move an object on the grid, the Translate channels in the Channel Box indicate where an object is in object space. If you freeze the transformations on an object (Modify

Point Constraints

If you create a joint in a scene and then reposition it and freeze transformations, you'll notice that the Rotate channels all become zero for its new orientation; however, the Translate channels are not affected by freeze transformations. If you want to place a joint exactly at the position of another object, you can't rely on the object's Translate channels as an accurate description of the object's location in world space. One way to get around this is to use a point constraint to position the joint according to the object's world space coordinates.

You'll use point constraints to place joints precisely at the pivot points of the leg parts. Once the joints are positioned you can delete the constraints.

  1. Open the mechBugRig_v01.ma scene from the chapter5scenes directory on the DVD.

    The bug model is a combination of NURBS and polygon geometry. The bug's parts have already been parented in the Outliner to form a basic hierarchy (see Figure 5.2).

    The mechanical bug is created from NURBS and polygon surfaces. Its various parts are organized in the Outliner.

    Figure 5.2. The mechanical bug is created from NURBS and polygon surfaces. Its various parts are organized in the Outliner.

    The model consists of two main groups: the legs and the bugBody. At the moment these two groups are separate. The legs and body are placed on two different display layers so their visibility can be turned off easily while working.

  2. In the Layer Editor, turn off the BODY display layer so only the legs are visible.

  3. Switch to the Animation menu set, and turn on Grid Snapping. Choose Skeleton

    The mechanical bug is created from NURBS and polygon surfaces. Its various parts are organized in the Outliner.
  4. In the Outliner, expand the legs group. Select the frontleftLegBase object. Ctrl+click joint1 and choose Constrain

    The mechanical bug is created from NURBS and polygon surfaces. Its various parts are organized in the Outliner.

    When you create a constraint node, it appears in the Outliner parented to the constrained object. The icon looks like an exclamation point (see Figure 5.5). In this particular situation, you're only using the constraint to quickly position the joint at the same spot as the geometry, so once the joint is repositioned you can remove the constraint. This technique is a fast and easy way to make one object snap to the world space position of another. Using constraints as an animation tool is discussed later in the chapter.

  5. In the Outliner, expand joint1. Select joint1_pointConstraint1, and press the Delete key to remove the constraint.

    Place three joints on the grid.

    Figure 5.3. Place three joints on the grid.

    The options for the point constraint

    Figure 5.4. The options for the point constraint

    The point constraint appears as an exclamation point parented to the constrained object in the Outliner.

    Figure 5.5. The point constraint appears as an exclamation point parented to the constrained object in the Outliner.

  6. Repeat steps 4 and 5 (or use the shelf button created in the "MEL In Action" section) to reposition joint2 to the frontLeftFoot object.

  7. Turn on Point Snapping (turn off Grid Snapping), and position joint3 at the very tip of the frontLeftFoot.

  8. Rename joint1 frontLeftLegJoint. Rename joint2 frontLeftFootJoint, and rename joint3 frontLeftEndJoint.

  9. Make sure all point constraints on the joints have been deleted. Parent the frontLeftLegBase object to the frontLeftLegJoint, and parent the frontLeftFoot to the frontLeftFootJoint (see Figure 5.6).

    Parent the parts of the leg to the leg joints.

    Figure 5.6. Parent the parts of the leg to the leg joints.

  10. Create similar joint systems for the remaining five legs. Remember to rename your joints in a descriptive manner (see step 8) to avoid confusion when animating.

  11. When you have finished creating all of the joints, place them in the legs group. To do this MMB-drag each of the top joints in the chain into the legs group in the Outliner (see Figure 5.7).

  12. Save the scene as mechBugRig_v02.ma. To see a version of the scene to this point, open the mechBugRig_v02.ma scene from the chapter5scenes directory.

Create joint chains for each of the legs.

Figure 5.7. Create joint chains for each of the legs.

Aim Constraints

An aim constraint constrains the orientation of an object relative to the position of one or more other objects.

  1. Continue with the scene from the previous section or open the mechBugRig_v02.ma scene from the chapter5scenes directory on the DVD.

  2. Turn on the display layer for BODY; turn off the LEGS layer so the legs are hidden and the body is displayed.

  3. Create a locator and name it eyeAimLoc. Set the eyeAimLoc's Translate X, Y, and Z channels to 0, 0, and 2, respectively.

  4. In the Outliner, expand the bugBodyGroup. MMB-drag eyeAimLoc into the bugBody group.

  5. Select the eyeAimLoc and choose Modify

    Aim Constraints
  6. Expand the frontBody group, the head group, and the face group.

  7. Select the eyeAimLoc and Ctrl+click the eyeBase group (see Figure 5.8). From the Animation menu set choose Constrain

    Aim Constraints
  8. In the options choose Edit

    Aim Constraints
    Select the eyeAimLoc locator and the eyeBase object in the Outliner.

    Figure 5.8. Select the eyeAimLoc locator and the eyeBase object in the Outliner.

    The Aim Constraint Options window

    Figure 5.9. The Aim Constraint Options window

  9. Move the locator around in the scene, and you'll see that the eyes follow it (see Figure 5.10). Because the locator is parented to the bug body, when you animate the bug, the locator will move with it.

    The eyes follow the position of the eyeAimLoc locator.

    Figure 5.10. The eyes follow the position of the eyeAimLoc locator.

  10. Create two new locators named leftAntennaAimLoc and rightAntennaAimLoc.

  11. Set leftAntennaAimLoc's Translate X, Y, and Z to 1, 0, and 3, respectively, and rightAntennaAimLoc's Translate X, Y, and Z to −1, 0, and 3.

  12. Freeze transformations for both locators. Shift+click both locators and group them together. Name the group antennaAim. Leave the pivot point for the group at the center of the grid.

  13. In the Outliner, MMB-drag antennaAim into the bugBody group.

  14. Expand the antennaAim group. Expand the face group (in the bugBody/frontBody/head group). Aim constrain the leftAntenna to the leftAntennaAimLoc locator and the rightAntenna to the rightAntennaAimLoc locator.

    When you move each antennaAimLoc locator, the antennae follow; when you rotate the antennaAim group, the locators move and the antennae follow. This gives you a way to animate the antennae separately and together (see Figure 5.11).

    You can animate the antennae separately or together based on the grouping of the antennaAimLoc locators.

    Figure 5.11. You can animate the antennae separately or together based on the grouping of the antennaAimLoc locators.

  15. Save the scene as mechBugRig_v03.ma. To see a version of the scene to this point, open the mechBugRig_v03.ma scene from the chapter5scenes directory on the DVD.

Inverse Kinematics

Kinematics is the study of the motion of objects. This is related to but distinguished from dynamics in that kinematics does not study the cause of the objects' motion, only the way in which the objects move. In 3D computer graphics the term kinematics describes how joints can be moved to animate objects and characters. There are two main types of kinematics: Forward Kinematics and Inverse Kinematics.

Forward Kinematics refers to a situation in which each joint in the chain inherits the motion of its parent joint. So if you have four joints in a chain, when you rotate the root, the three child joints move based on the rotation of the root. When you rotate the second joint, the third and fourth joints inherit the motion of the second (see Figure 5.12).

Forward Kinematics can be useful in many situations; for instance, it is often used for basic arm animation for characters. However, it can be tedious and difficult to work with for other types of animation, particularly when animating the legs of a character walking or jumping. Constant adjustments have to be made to ensure that as the root joints are animated, the limbs of the character do not penetrate the floor or slide during a walk cycle.

When using Forward Kinematics, each joint inherits the rotation of its parent.

Figure 5.12. When using Forward Kinematics, each joint inherits the rotation of its parent.

Inverse Kinematics (IK) causes the joints in a chain to orient themselves based on the position of a goal known as the End Effector (see Figure 5.13). Inverse Kinematics can be a more intuitive technique in many situations. When used on legs, the Sticky option for Inverse Kinematics can prevent joints from penetrating the floor or sliding during a walk cycle. When animating an IK chain, you can simply change the position of the End Effector using the Inverse Kinematics (IK) Handle, and all of the joints in the chain will orient themselves based on the position of the End Effector. The End Effector itself is positioned using the IK Handle; the End Effector is not actually visible or selectable in the viewport (it can be selected in the Hypergraph window).

Inverse Kinematics cause the joints in a chain to rotate based on the position of a goal.

Figure 5.13. Inverse Kinematics cause the joints in a chain to rotate based on the position of a goal.

There are controls for blending between Forward and Inverse Kinematics known as FK/IK Blend. You can switch between Forward and Inverse Kinematics and even blend between the two.

Maya's kinematic controls work very well for many standard situations. Most professional riggers prefer to create their own custom controls and solutions. Creating custom controls is discussed in Chapters 6 and 7. In this section a very basic, simple IK technique is used on the legs of the mechanical bug. This makes animating the legs easier and more intuitive because you need only worry about the position of a single goal when animating all the parts of one of the legs.

IK Handle Tool

In this section you'll add Inverse Kinematics to each of the legs on the mechanical bug.

  1. Continue with the scene from the previous section, or open the mechBugRig_v03.ma scene from the chapter5scenes directory on the DVD. In the Layer menu, turn off Visibility for the BODY layer.

  2. From the Animation menu set choose Skeleton

    IK Handle Tool

    The other option is the Rotate Plane solver (RPsolver). This solver has extra controls that can be used to solve joint-flipping problems, which can occur with more complex joint arrangements. If you create an IK Handle using the ikSCsolver and your joints behave unpredictably, try switching to the RPsolver (you can do this after creating the handle using the menu options in the IK Handle's Attribute Editor). The various types of IK solvers are discussed in Chapter 7.

    In general, when adding Inverse Kinematics to a joint chain using the IK Handle tool, you don't want the joints to be aligned in a straight line. There should be a small bend in the joint chain. This helps the solver figure out how the joints should bend as they attempt to rotate based on the position of the End Effector. It's also a good idea to freeze transformations on the joints so their X, Y, and Z rotation channels are set to zero before adding the IK Handle (in the mechBug_v03.ma scene this has already been done).

  3. Turn on Solver Enable and turn off Snap Enable. Snap Enable causes the IK Handle to snap back to the position of the end joint when you release it. You'll create a custom handle using a curve, so this option should be off.

  4. Turn on Sticky. Sticky keeps the IK Handle's position constant as you pose the rest of the skeleton. This is very useful for keeping feet from moving through the floor when animating the other parts of the skeleton (see Figure 5.14).

    The options for the IK Handle tool

    Figure 5.14. The options for the IK Handle tool

  5. The other settings can be left at the default. With the IK Handle tool activated, click on the frontLeftLeg joint (the joint at the root of the front left leg); then click on the joint at the end of the frontLeftLeg chain. The IK Handle appears at the end of the joint chain (see Figure 5.15).

  6. Try moving the IK Handle; you'll see the rest of the joint rotate based on the position of the handle.

  7. Click Undo until the IK Handle returns to its original location.

    It's usually a good idea to use a curve or another easily selectable object as a control for the IK Handle. This makes it easy to select the handle directly in the scene without having to hunt around in the Outliner.

  8. Create a NURBS circle (Create

    The options for the IK Handle tool
    The IK Handle tool creates an IK solver for the front left leg.

    Figure 5.15. The IK Handle tool creates an IK solver for the front left leg.

  9. Use the objSnp shelf button created earlier in the chapter (see the "MEL in Action" section) to position the circle at the location of the IK Handle. To do this, select the ikHandle1 object, Ctrl+click the nurbsCircle1, and click the objSnp button in the Custom shelf.

  10. Select the nurbsCircle1 and rename it frontLeftFootCtrl. Choose Modify

    The IK Handle tool creates an IK solver for the front left leg.
  11. Select the frontLeftFootCtrl, and Ctrl+click the ikHandle. Create a point constraint so the handle is constrained to the frontLeftFoot circle (Constrain

    The IK Handle tool creates an IK solver for the front left leg.
  12. You can turn off visibility of the ikHandle1 object. To animate the leg, select the frontleftLegCtrl circle and move it around. To reset its position, set its Translate X, Y, and Z channels to 0.

  13. Repeat steps 2 through 12 to create controls for the other five legs (the options for the IK Handle tool should already be stored, so you can just activate the tool and use it to add IK to the other legs).

  14. When you have finished making the controls for the other legs, select the control circles and group them. Name the group legsControlGroup.

  15. Select the legsControlGroup group, and choose Modify

    The IK Handle tool creates an IK solver for the front left leg.
  16. Make another NURBS circle; name the circle legsCtrl. Use the objSnp button to place the circle at the position of the legControlGroup's pivot. Freeze transformations on the legsCtrl.

  17. Select the legsCtrl circle, and Ctrl+click the legsControlGroup. Choose Constrain

    The IK Handle tool creates an IK solver for the front left leg.

    Now you have a selectable control for moving all of the legs as well as each individual leg. This will mean less time hunting around in the Outliner.

  18. Finally, you can straighten up the Outliner by grouping the IK Handles. Name the group feetIkhandles. Group the legs and bugBody together, and name this group bug.

  19. Save the scene as mechBugRig_v04.ma. To see a version of the scene to this point, open the mechBugRig_v04.ma scene from the chapter5scenes directory on the DVD.

Create a Master Control

To finish the rig you can create a selectable control to animate the position and the rotation of the bug body and then group all of the parts of the bug together so that it can be easily moved or scaled in the scene.

  1. Continue with the scene from the previous section or open the mechBugRig_v04.ma scene from the chapter5scenes directory on the DVD.

  2. Create a new display layer named CONTROLS. Turn off the visibility of the LEGS and BODY display layers, select the NURBS circles, and add them to the CONTROLS layer.

  3. Turn off the Visibility of the CONTROLS layer so the scene is blank.

  4. Turn on the Visibility of the grid. Turn on Grid Snapping. Choose Create

    Create a Master Control
  5. Switch to the top view, and use the curve to draw a shape like the one in Figure 5.16. The shape should be a cross with an arrowhead at each end of the cross. Press Enter to complete the curve.

    Create a cross with an arrow at each end using a linear CV curve.

    Figure 5.16. Create a cross with an arrow at each end using a linear CV curve.

  6. Center the pivot of the curve and name it bodyCtrl.

  7. In the Outliner, expand the bug group. Click the objSnp button to snap the bodyCtrl curve to the center of the bugBody object. Scale the bodyCtrl curve in X, Y, and Z to 3.5.

  8. Freeze transformations on the curve.

    Next, you want to move the curve above the body so you can easily select it. This curve controls the translation and rotation of the bugBody. However, you want to keep the pivot point of the control at the center of the bug body. Since you snapped the curve to the center of the bugBody, the pivot point of the curve is at the same position as the bugBody. So how do you move the curve without moving the pivot point? Simple—you move all of the CVs of the curve above the bug body. This moves the curve without changing its pivot point.

  9. Select the bodyCtrl curve and switch to CV selection mode (right-click on the curve and choose CVs). Drag a selection marquee over all of the CVs of the curve. Switch to the Move tool, and drag up on the Y axis to position the CVs of the curve above the body. Since the pivot point has not changed, it doesn't matter how high you place the curve above the bug; it just has to be easily selectable (see Figure 5.17).

  10. Select the bodyCtrl curve in the Outliner, and Ctrl+click the bug group. Choose Constrain

    Create a cross with an arrow at each end using a linear CV curve.
    Move the CVs of the bodyCtrl curve above the bugBody; the pivot point of the curve remains at the center of the bugBody.

    Figure 5.17. Move the CVs of the bodyCtrl curve above the bugBody; the pivot point of the curve remains at the center of the bugBody.

    The parent constraint constrains both the translation and rotation of one object to another object.

  11. Turn on the LEGS layer. Select the bodyCtrl curve and try moving and rotating it. The legs stay on the ground (within a certain range).

    At this point you should have a nice set of simple controls for both the body and the legs of the bug. All this work will make animating the bug a much more pleasant experience.

  12. Finally, select everything in the Outliner except the ground plane, and group them together. Name the group mechanicalBug.

  13. Add the bodyCtrl curve and the three locators for the eyes and antenna controls to the CONTROLS layer.

  14. Save the scene as mechBugRig_v05.ma. To see a version of the scene to this point, open the mechBugRig_v05.ma scene from the chapter5scenes directory of the DVD (see Figure 5.18).

    The completed bug rig is ready for animation.

    Figure 5.18. The completed bug rig is ready for animation.

One last control you can add to the bug is a selectable rotational control for the antennaAim group. Use the same techniques used to create the bodyCtrl curve. The mechBug_v01.ma scene has an example of this control.

Keyframe Animation

The simplest way to animate an object in Maya is to use keyframes. A keyframe records the value of an attribute at a point in time on the timeline. When two keyframes are set for an attribute at different points in time, Maya interpolates the value between the two keyframes on the timeline, and the result is an animation.

Keyframes can be set on almost any attribute in Maya. You can use keyframes to animate an object's position, the color of the shader applied to the object, the visibility of the object, whether the object becomes dynamic, and so on.

Now that you have a rig for the mechanical bug that can be animated, you can get to work bringing him to life.

Creating Keyframes

In this exercise you'll see the various ways you can set and manipulate keyframes in the Maya interface.

  1. Open the mechBug_v01.ma scene in the chapter5scenes directory on the DVD.

    The mechanical bug in this scene has been rigged using the techniques discussed in the first part of the chapter. The major difference is that a circle has been added between the two antenna controls that you can select and animate to control both antennae at the same time.

    The controls are color coded so they are more organized visually. The visibility of the joints is turned off in the Show menu of the perspective view; however, they are still present in the scene.

Keyframes can be placed on the individual channels of an object using the Channel Box. It's usually a good idea to keyframe on the channels that need to be animated rather than all of the channels and attributes of an object. To keyframe individual channels, follow these steps:

  1. In the perspective view, select the blue bodyCtrl curve above the bug (the curve that looks like a cross with an arrow on each end; see Figure 5.19).

    Select the bodyCtrl curve above the bug.

    Figure 5.19. Select the bodyCtrl curve above the bug.

  2. Move the current frame in the timeline to frame 20 by clicking and dragging the timeline until the marker is at frame 20. Alternatively, type 20 into the box to the far right of the timeline.

  3. With the bodyCtrl selected, highlight the Translate Y channel in the Channel Box by clicking on it; then right-click and choose Key Selected from the pop-up menu (see Figure 5.20).

  4. Set the timeline to frame 48. Use the Move tool to pull the bodyCtrl curve up to about two units, and set another keyframe on the Translate Y channel. The keys are represented on the timeline by a thin red vertical line (see Figure 5.21).

  5. Rewind and play the animation; you'll see the bug start moving upward on frame 20 and stop on frame 48.

Set a keyframe on the Translate Y channel of the bodyCtrl.

Figure 5.20. Set a keyframe on the Translate Y channel of the bodyCtrl.

Keyframes are represented on the timeline by a thin red vertical line.

Figure 5.21. Keyframes are represented on the timeline by a thin red vertical line.

For the most part, setting keyframes is pretty straightforward. If you want to set a keyframe on all of the Translate channels at the same time, the hot key is W. To set a keyframe on all Rotate channels at once, use E. To set a keyframe on all the Scale channels at once use, use R.

Auto Keyframe

The Auto Keyframe feature automatically places keyframes on an object when a change is made to one of its attributes. For Auto Keyframe to work, the attribute must already have an existing keyframe. To turn Auto Keyframe on, click the key icon to the right of the timeline. This exercise shows you how to use Auto Keyframe.

  1. On the timeline for the mechBug_v01.ma scene, set the current frame to 20.

    An easy way to do this is to use the Step Back One Key or Step Forward One Key buttons to the right of the timeline. The hotkeys for moving back and forth one key are Alt+comma and Alt+period.

  2. Shift+click all six of the small purple leg control circles below the bug's feet (see Figure 5.22).

    Select the leg control circles.

    Figure 5.22. Select the leg control circles.

  3. With the control circles selected, press the W hot key to place a keyframe on the Translate channels for all the selected curves.

  4. Click the Key icon to the far right of the timeline to turn on Auto Keyframe.

  5. Set the timeline to frame 40. Select each of the circles and move them in toward the center (see Figure 5.23).

  6. When you play the animation, you'll see that the legs move inward without your having to set a keyframe in the Channel Box.

    Using Auto Keyframe is certainly a matter of personal preference. You can easily set unwanted keys on an object by mistake using this feature, so remember to use it with caution.

  7. Save the scene as mechBug_v02.ma. To see a version of the scene to this point, open the mechBug_v02.ma scene from the chapter5scenes directory on the DVD.

Move the leg control circles in toward the center of the bug.

Figure 5.23. Move the leg control circles in toward the center of the bug.

Move and Scale Keyframes on the Timeline

You can reposition keys on the timeline interactively by selecting the key markers and sliding them back and forth.

  1. Continue with the scene from the previous section or open the mechBug_v02.ma scene from the chapter5scenes directory on the DVD.

  2. In the Perspective window, select the blue bodyCtrl curve. Hold the Shift key and drag a selection directly on the timeline. You'll see a red area appear as you drag. Keep dragging this area so it covers both keyframes set on the bodyCtrl curve (see Figure 5.24).

    Hold the Shift key and drag on the timeline to select a range of keys.

    Figure 5.24. Hold the Shift key and drag on the timeline to select a range of keys.

  3. To move the keys forward or backward in time, drag on the two arrows at the center of the selection. Drag on these arrows to move the keys so the first key is on frame 10.

    To scale the keys, drag on one of the arrows on either side of the selection. The other end of the selection acts as the pivot for the scaling operation; you may need to reposition the keys on the timeline again after scaling.

  4. Scale the keys down by dragging the arrow on the right side of the selection toward the left. After scaling the keys, drag on the arrows at the center to reposition the keys so the animation starts on frame 10.

    You can move an individual key by Shift+clicking the key marker on the timeline and then dragging on the arrows to move the key.

    Repositioning and scaling keys directly on the timeline is usually good for simple changes. To make more sophisticated edits to the animation, you can use the Graph Editor discussed later in the chapter.

    When you play the animation, you'll see that the bug jumps up fairly quickly and much sooner than before. You'll also notice that the animation of the legs has not changed.

  5. Spend a few minutes practicing these techniques on each of the legBase objects. Changes made to the position of the keyframes affect selected objects. You can edit each legCtrl circle separately or all of them at the same time.

  6. Save the scene as mechBug_v03.ma. To see a version of the scene to this point, open the mechBug_v03.ma scene from the chapter5scenes directory on the DVD.

Copy, Paste, and Cut Keyframes

There are a number of ways you can quickly copy, paste, and cut keyframes on the timeline and in the Channel Box.

  1. Continue with the scene from the previous section or open the mechBug_v03.ma scene from the chapter5scenes directory on the DVD.

  2. Select the bodyCtrl curve in the perspective view. On the timeline, Shift-drag a selection over both of the keyframes.

  3. Right-click on the selection and choose Copy (see Figure 5.25).

  4. Deselect the keys by clicking on the timeline, move to frame 70, right-click on the timeline, and choose Paste

    Copy, Paste, and Cut Keyframes
    You can copy keyframes directly onto the timeline.

    Figure 5.25. You can copy keyframes directly onto the timeline.

  5. The keys for the Translate Y channel are pasted on the timeline at frame 70. If you play the animation, you'll see that the bug jumps up, moves back down, and then jumps up again.

    Other options include the following:

    • Paste Connect pastes the copied key with an offset starting at the value of the previous key.

    • Cut removes the keyframes from the timeline but copies their values to the clipboard so they can be pasted anywhere on the timeline.

    • Delete removes the keys.

    • Delete FBIK deletes the Full Body IK keys.

      You can copy and paste keys from two different channels by using the options in the Channel Box.

  6. Select the bodyCtrl curve in the perspective view. In the Channel Box, right-click on the Translate Y channel. Choose Copy Selected (see Figure 5.26).

  7. Highlight the Translate Z channel, right-click, and choose Paste Selected.

    This pastes the values (including keyframes) copied from the Translate Y channel to the Translate Z channel. The starting point of the pasted keyframes is based on the current time in the timeline. When you play the animation, the bug moves forward as it moves up. The forward motion will be offset (in time) depending on the current frame in the timeline.

    You can copy keyframes using the menu options in the Channel Box.

    Figure 5.26. You can copy keyframes using the menu options in the Channel Box.

    You can also cut and delete keyframes in the Channel Box. The Duplicate keyframe operation allows you to copy keyframes from one object to another.

  8. Create a NURBS sphere and set its Translate X to 5.

  9. Select the sphere and then Shift+click the bodyCtrl curve. Right-click on the Translate Y channel, and choose Duplicate Values. This connects the keyframes on the Translate Y channel of the bodyCtrl curve to the NURBS sphere. If you change the values of these keys, both the bodyCtrl curve and the sphere will reflect the changes made to the keys.

When duplicating keyframes, the order in which you select the objects is important. Select the object you want to use as the source of the duplicate keyframes last. If you graph the objects on the Hypergraph, you'll see that the same keyframe nodes are attached to both objects.

The Graph Editor

The timeline and the Channel Box offer a few basic controls for creating and editing keyframes. However, when you're refining an animation, the controls in the Graph Editor offer greater flexibility as well as visual feedback on the interpolation between keyframes. To open the Graph Editor, choose Window

The Graph Editor

Animation Curves

Animation curves visually describe how the values between two keyframes are interpolated over time. A keyframe is represented by a point on the curve. The portion of the curve on the graph to the left of a keyframe represents the animation before the key, and the line and the portion on the right represent the animation after the key. The keys themselves have handles that can be used to fine-tune the shape of the curve and thus the behavior of the animation both before and after the key. The shape of the curve to the left of the key is known as the incoming tangent (or in tangent); the shape of the curve to the right of the key is known as the outgoing tangent (or out tangent), as shown in Figure 5.27.

Each animated channel has its own curve on the graph. You can use the menu in the Graph Editor to edit the keys and change the way the curves are displayed on the Graph Editor.

In this exercise, you'll use the Graph Editor to refine a simple animation for the mechanical bug. In this animation the bug will leap in the air, hover for two seconds, lean forward, and then fly off the screen in a gentle arc. You'll start by setting keys on the Translate channels of the bug. To make things easier you'll use Auto Keyframe.

The curves on the Graph Editor represent the interpolation of values between keyframes for a selected object.

Figure 5.27. The curves on the Graph Editor represent the interpolation of values between keyframes for a selected object.

The setting applied to the tangents of the curves sets the overall shape of the curve before and after each key. You can apply a tangent setting to one or more selected keys on the graph, and the in and out tangents can also have their own setting.

The settings are listed in the Tangents menu in the Graph Editor and are also represented visually by the icons at the top of the Graph Editor. Clicking one of these buttons or applying a setting from the Tangents menu changes the interpolation of the selected key(s) or tangent handles (see Figure 5.28).

The icons for the tangent settings at the top of the Graph Editor

Figure 5.28. The icons for the tangent settings at the top of the Graph Editor

When blocking out an animation, it's common to use the Stepped tangent setting. The Stepped tangent setting creates no interpolation between keys, so an object's animated values do not change between keyframes; instead the animation appears to pop instantly from key to key. Using stepped keys when you block out the animation gives you a clear idea of how the object will move without the additional motion that can be added by curved tangents. Once you're happy with the blocking, you can switch to another tangent type and then refine the animation.

  1. Open the mechBug_v01.ma scene from the chapter5scenes directory on the DVD.

  2. Open the Preferences window by choosing Window

    The icons for the tangent settings at the top of the Graph Editor
  3. Make sure Auto Keyframe is enabled. Press Save to save the preferences (see Figure 5.29).

    The animation preferences are established in the Settings/Preferences window.

    Figure 5.29. The animation preferences are established in the Settings/Preferences window.

  4. Set the length of the timeline to 120. Set the current frame to 20.

  5. Select the blue bodyCtrl curve in the perspective view. Press W and E to set keyframes on the Translate and Rotate channels.

    When blocking out the animation, the only object that needs to be keyframed at this point is the bodyCtrl curve.

  6. Set the timeline to frame 25, and move the bodyCtrl curve down so the Translate Y channel is about −0.78.

  7. Set the timeline to frame 35. Drag up on the bodyCtrl curve until the Translate Y channel is around 7 units.

  8. Set the timeline to 45. Rotate the bodyCtrl slightly, and move the bug a little forward and to the side. This gives the bug a slight wobble as he hovers. Try these settings:

    • Translate X: −0.68

    • Translate Y: 4.968

    • Translate Z: 0.532

    • Rotate X: −11

    • Rotate Y: 7

    • Rotate Z: 10

    Many of these values were arrived at by simply moving and rotating the bodyCtrl curve in the scene. You can use these exact values or something that's fairly close. Most of the time when blocking in the animation you'll move the objects in the scene rather than type in precise values, but the keyframe values are included here as a rough guide. Remember, right now the only object being keyframed is the bodyCtrl curve.

  9. Set the frame to 60. The bug is starting to turn as he decides which way to fly. Rotate him to his left a little and add a bit more variation to his position. Try these settings:

    • Translate X: −.057

    • Translate Y: 4.677

    • Translate Z: −1.283

    • Rotate X: −18.137

    • Rotate Y: 20.42

    • Rotate Z: −13.628

  10. Now the bug is starting to fly away. Rotate him so he is facing downward slightly. Try these settings:

    • Translate X: 1.463

    • Translate Y: 3.664

    • Translate Z: −.064

    • Rotate X: 31.488

    • Rotate Y: 35.304

    • Rotate Z: 1.545

  11. Set the time slider to frame 95. The bug is beginning his flight, so he turns more to the left and dips down a little. Try these settings:

    • Translate X: 4.421

    • Translate Y: 3.581

    • Translate Z: 1.19

    • Rotate X: 1.593

    • Rotate Y: 46.833

    • Rotate Z: 1.935

  12. In the final keyframe on frame 120 the bug is flying away. Try these settings:

    • Translate X: 11.923

    • Translate Y: 9.653

    • Translate Z: 6.794

    • Rotate X: 48.999

    • Rotate Y: 62.691

    • Rotate Z: 24.392

  13. Play back the animation a few times. You'll see the bug pop from one position to another. Make changes if you like, but try not to add any more keys just yet. It's best to use as few keys as possible; you'll let the curves do all the work in a moment.

  14. Select the red legsCtrl circle, and keyframe its Translate channels so it follows the flight of the bug. To keep it interesting, place the keys at different frames than the bodyCtrl curve. Remember to set an initial keyframe before using Auto Keyframe.

    You can set keys on the individual foot controls, but at this point let's keep things simple and focus on just the bodyCtrl curve and the translation of the legsCtrl curve.

  15. In the Perspective View menu, choose Panels

    The animation preferences are established in the Settings/Preferences window.
  16. Select the bodyCtrl curve, and hold the cursor over the Graph Editor. Press the f hot key so you can see all the animation curves for the bodyCtrl object. Since the tangents are set to Stepped, they look like straight lines in a stepped pattern (Figure 5.30).

  17. Save the scene as mechBug_v04.ma. To see a version of the scene to this point, open the mechBug_v04.ma scene on the chapter5scenes folder of the DVD.

The Graph Editor is in its own panel in the interface; the keys for the bodyCtrl curve appear as straight lines.

Figure 5.30. The Graph Editor is in its own panel in the interface; the keys for the bodyCtrl curve appear as straight lines.

Editing Animation Curves

At this point you're ready to start refining the animation curves using the tangent tools. Keep things simple and add keys only when absolutely necessary.

  1. Continue with the scene from the previous section or open the mechBug_v04.ma scene from the chapter5scenes directory on the DVD.

  2. In the Display Layers menu, turn off the visibility of the LEGS layer so you can just focus on the animation of the body.

  3. Select the bodyCtrl curve, and in the Graph Editor drag a selection marquee over all the translation and rotation keys. Test how the animation looks when different tangent types are applied to the keys.

  4. On the menu bar of the Graph Editor, click the first tangent icon or choose Tangents

    Editing Animation Curves
  5. In the Graph Editor zoom in closely to the selected keys (MMB+Alt-drag).

    You'll notice that spline tangents add a bit of overshoot to some of the keys, as shown in Figure 5.31, which results in a smooth, natural motion. However, in some cases this may add extra motion where you don't want it. It depends on how much precise control you want over the animation.

    Switching to spline tangents adds a slight overshoot to the animation curves. Notice how the curve dips below the lowest value of some of the keyframes.

    Figure 5.31. Switching to spline tangents adds a slight overshoot to the animation curves. Notice how the curve dips below the lowest value of some of the keyframes.

  6. Try switching to the clamped-type tangent (second tangent icon, or choose Tangents

    Switching to spline tangents adds a slight overshoot to the animation curves. Notice how the curve dips below the lowest value of some of the keyframes.

    Clamped tangents are very similar to spline tangents; in fact, you'll notice a difference between spline and clamped tangents only when two values in a curve are very close together. Clamped tangents remove any overshoot that may cause sliding or slipping in an object. In the current animation example, you won't see much a difference at all except for a couple keyframes (see Figure 5.32).

    Clamped tangents are very similar to spline tangents except for values that are very close. In this figure spline tangents (left image) are converted to clamped tangents (right image).

    Figure 5.32. Clamped tangents are very similar to spline tangents except for values that are very close. In this figure spline tangents (left image) are converted to clamped tangents (right image).

    Aside from spline, clamped, and stepped tangents, you can also try using one of these tangent types. A single curve can use any combination of tangent types as well.

    • Linear tangents create straight lines between keyframes, resulting in a very sharp and direct motion.

    • Flat tangents make the tangents completely horizontal. Flat keyframes are very useful when you want to create a slow ramping effect to the values, known as "easing in" or "easing out." "Easing in" means that the animation curve starts out flat and then gradually becomes steeper; "easing out" is the opposite.

    • Plateau tangents create smooth curves between keyframes. However, the overshoot that occurs with spline and clamped tangents is eliminated, so the peaks of each curve do not go beyond the values you set when you create the keyframes. Plateau tangents offer a good balance between smooth motion and control.

  7. With all of the keys selected in the Graph Editor, click on the last tangent icon, or choose Tangents

    Clamped tangents are very similar to spline tangents except for values that are very close. In this figure spline tangents (left image) are converted to clamped tangents (right image).

    A good place to start editing the animation is the initial leap that occurs at frame 20.

  8. Make sure you can see both the Graph Editor and the body of the bug in the perspective view. The bugCtrl object should be selected so you can see its animation curves.

  9. In the left column of the Graph Editor, highlight Translate Y to focus on just this individual curve.

    The leap has a slight anticipation where the bug moves down slightly before jumping in the air. At the moment the motion is uniform, making it look a little uninteresting. You can edit the curve so the bug leaps up a little faster and sooner. Start by moving the third keyframe closer to the second.

  10. Select the third keyframe, and click the move key icon (first icon on the far left of the menu bar) or use the w hot key. To move the key, hold the MMB and drag to the left (see Figure 5.33). To constrain the movement horizontally so its value is not changed (only its time), hold the Shift key while dragging with the MMB.

    Move the third keyframe on the bodyCtrl's Translate Y channel to the left, closer to the second keyframe.

    Figure 5.33. Move the third keyframe on the bodyCtrl's Translate Y channel to the left, closer to the second keyframe.

    You can enter numeric values into the Stats field for precise control. The first field is the keyframe's time in frames; the second field is the value for the keyframe.

  11. Slide the keyframe to the left so it is close to the second keyframe; the curve in between should become more of a straight line. If you want the keys to snap to whole values, select the key and choose Edit

    Move the third keyframe on the bodyCtrl's Translate Y channel to the left, closer to the second keyframe.

    There are two magnet icons on the menu bar of the Graph Editor (these may be visible only when the Graph Editor is maximized). These icons turn on horizontal and vertical snapping, respectively. The keyframes are then snapped to the grid in the Graph Editor (see Figure 5.34).

  12. You can change the shape of the curves by editing the tangents directly. Drag a selection box around the handle to the right of the third key. Press the w hot key to switch to the Move tool. MMB-drag upward to add overshoot to the out tangent (see Figure 5.35).

    The magnet icons turn on horizontal and vertical snapping.

    Figure 5.34. The magnet icons turn on horizontal and vertical snapping.

    MMB-drag on the tangent handles to directly edit the curve shape.

    Figure 5.35. MMB-drag on the tangent handles to directly edit the curve shape.

    You'll notice that as you drag upward on the tangent handle, the handle on the opposite side of the key moves downward, maintaining the shape of the curve through the key. You can break the tangency of the curve handles if you want a different interpolation for the in and out tangents.

  13. Drag a selection around both handles of the second key on the Translate Y channel. Choose Key

    MMB-drag on the tangent handles to directly edit the curve shape.
  14. Drag a selection handle around the in tangent, and MMB-drag it upward so there is a slight bump and then a sharp dip in the curve (Figure 5.36).

    When you play the animation, the bug moves up slightly, down quickly, and then leaps into the air. You can unify the tangents by choosing Keys

    MMB-drag on the tangent handles to directly edit the curve shape.
  15. Save the scene as mechBug_v05.ma. To see a version of the scene to this point, open the mechBug_v05.ma scene from the chapter5scenes directory on the DVD.

When you break the tangency of the handles, you can move the tangent handles on either side of the keyframe independently of each other.

Figure 5.36. When you break the tangency of the handles, you can move the tangent handles on either side of the keyframe independently of each other.

Weighted Tangents

You can convert the tangents to weighted tangents, which means you can further refine the in and out tangents by pulling on the tangent handles.

  1. Continue with the scene from the previous section or open the mechBug_v05.ma scene from the chapter5scenes directory on the DVD.

  2. Select the bodyCtrl curve, and in the Graph Editor select the Translate Y channel to isolate the curve. Press the f hot key so the entire curve fits in the Graph Editor.

  3. Drag a selection around the fourth key, and use the MMB to drag it down a little to create a slight dip in the curve (upper left of Figure 5.37).

  4. With the key selected choose Curves

    Weighted Tangents
  5. Select the handles and choose Keys

    Weighted Tangents
  6. MMB-drag on the handles left or right to extend the length of the handles; notice the change in the shape of the curve (lower-left of Figure 5.37).

  7. Break the tangents on the selected handles (Keys

    Weighted Tangents
  8. Pull the outcoming tangent of the fourth keyframe down and to the right (lower-right image of Figure 5.37).

  9. Play the animation, and see how changing the length of the handles affects the way the bug jumps.

  10. Save the scene as mechBug_v06.ma. To see a version of the scene to this point, open the mechBug_v06.ma scene from the chapter5scenes folder on the DVD.

Weighted tangents allow you to edit the curves by pulling and pushing the tangent handles.

Figure 5.37. Weighted tangents allow you to edit the curves by pulling and pushing the tangent handles.

Additional Editing Tools

In addition to moving keyframes and tangents, you can also use the Scale tool to stretch and shrink a number of selected keys at once.

  1. Continue with the scene from the previous section or open the mechBug_v06.ma scene from the chapter5scenes directory on the DVD.

  2. Select the bodyCtrl curve in the perspective view and open the Graph Editor. Press the f hot key so all the curves are visible on the editor.

  3. Drag a selection marquee over all the keys to the right of the third key.

  4. From the Graph Editor menu bar, choose Edit

    Additional Editing Tools

    When the Scale Keys tool option is set to Gestural, the position of the cursor on the graph is the pivot for the scaling operation.

  5. Hold the cursor over the fourth key. MMB-drag back and forth to scale the keys horizontally. Increasing the scale horizontally slows down the animation; decreasing the horizontal scale speeds up the animation (see Figure 5.38).

  6. Drag the lower-left corner of the Scale Keys tool to the right a little to extend the animation and slow it down after the fourth keyframe.

    The Scale Keys tool stretches or shrinks the distances between selected keys on the graph.

    Figure 5.38. The Scale Keys tool stretches or shrinks the distances between selected keys on the graph.

    If you want to scale just the values, you can drag up or down. Small changes made with the Scale Key tool can have a large effect, so use this tool with caution.

    Another way to edit the keys is to use the Lattice Deform Keys tool.

  7. With the keys still selected, choose Edit

    The Scale Keys tool stretches or shrinks the distances between selected keys on the graph.
    The Lattice Deform Keys tool creates a lattice around selected keys to manipulate groups of selected keys.

    Figure 5.39. The Lattice Deform Keys tool creates a lattice around selected keys to manipulate groups of selected keys.

    To change the number of rows and columns in the lattice, open the Tool Options box while the Lattice Deform Keys tool is active. If the lattice does not update properly when you change the settings in the Tool Options box, try reselecting the keys in the Graph Editor.

    The Insert Keys tool inserts a key in one or more animation curves. To use this tool, first select one or more animation curves in the Graph Editor, click the Insert Key icon in the Graph Editor toolbar, and MMB-click on the curve.

    The Add Key tool is similar to the Insert Keys tool except that wherever you click in the Graph Editor will be used as the value for the added key. Both tools require that you MMB-click in the Graph Editor (see Figure 5.40).

    You can copy and paste keys on the graph; pasted keys are placed at the current location on the timeline. This means that if you select a group of keys that start at frame 40, then move the timeline to frame 60 and paste, the keys will be pasted at frame 60. For more precise copying and pasting, use the Copy and Paste options in the Graph Editor's Edit menu.

  8. Practice editing the keys on the Graph Editor for the bodyCtrl curve (both Translate and Rotate channels). When you're happy with the animation, make the legs visible and edit the keys set on the legCtrl circle.

    If you decide to use Auto Keyframe when refining the animation for other parts of the robot, switch the default in and out tangents to spline, clamped, or plateau in the preferences. Otherwise Maya inserts stepped keyframes while Auto Keyframe is on, which can be frustrating to work with at this point.

    You can add natural-looking motion to the way the bug hovers by simply shifting the keys placed on the different channels back and forth in time so they don't occur on the same frame (see Figure 5.41).

  9. To see a version of the scene where the keys have been edited, open the mechBug_v07.ma scene in the chapter5scenes directory on the DVD.

The Insert Key tool (left) inserts a key into a selected curve when you MMB-click. The Add Key tool (right) adds a key to a selected curve wherever you click on the graph.

Figure 5.40. The Insert Key tool (left) inserts a key into a selected curve when you MMB-click. The Add Key tool (right) adds a key to a selected curve wherever you click on the graph.

Shift the keys for the various channels back and forth in time so they don't occur on the same frame. This creates a more natural motion.

Figure 5.41. Shift the keys for the various channels back and forth in time so they don't occur on the same frame. This creates a more natural motion.

Breakdowns and In-Betweens

A breakdown is a special type of helper keyframe. The breakdown itself is just like a keyframe; what makes it special is how the breakdown affects the other keys on the curve. When you insert a breakdown and then move keys before or after the breakdown, the position of the breakdown moves as well to maintain a proportional relationship with the other keys on the curve. Normally when you move a keyframe, the other keys are not adjusted.

Try this short exercise to understand how breakdowns work.

  1. Open the mechBug_v07.ma scene from the chapter5scenes directory on the DVD.

  2. Turn off the visibility of the LEGS layer so you can focus on just the bug body.

  3. Select the blue bodyCtrl curve and open the Graph Editor. Select the Translate Y channel so it is isolated on the graph.

  4. Drag a selection around the third key on the graph. Switch to the Move tool (hot key = w). Hold the Shift key and drag back and forth on the graph. The other keys on the graph do not move; this is the normal behavior for keys.

  5. Drag a selection around the second key on the graph. From the menu in the Graph Editor, choose Keys

    Breakdowns and In-Betweens

    You won't notice any difference in the key itself or its tangent handles. The color of the key tick mark on the graph changes to green, but other than that it looks and acts the same.

  6. Drag a selection around the third key on the graph, and try moving it back and forth.

This time you'll notice that the second key adjusts its position to maintain a proportional relationship in the shape of the curve with the changes made to the third key. The same behavior occurs if you change the first key (see Figure 5.42).

You can convert any key to a breakdown using the Edit menu. To insert a breakdown, set the timeline to the frame where you want the breakdown, right-click on one or more channels in the Channel Box, and choose Breakdown Selected. You can add a breakdown to all the channels by choosing Breakdown All.

Breakdowns are special keys that maintain theproportions of the curve when neighboring keys are edited.

Figure 5.42. Breakdowns are special keys that maintain theproportions of the curve when neighboring keys are edited.

Breakdowns are useful for adding very precise animation to an object's channels without affecting the tangents of the surrounding keys. This can be important if you have perfected an animation but need to make a small change to a single key.

An in-between is a point on the curve that does not have a keyframe. In other words, each frame between two keys is known as an in-between. When you add an in-between, you shift all the keys to the right of the current point in the timeline one frame to the right. When you remove an in-between, you shift all the keys to the left.

Pre- and Post-Infinity

The Pre- and Post-Infinity settings can be used to quickly create simple repeating motions. To animate the flapping wings, you can set three keyframes and then set the Post-Infinity settings to Cycle.

  1. Open the mechBug_v07.ma scene from the chapter5scenes directory on the DVD.

  2. Set the timeline to 10.

  3. In the perspective view, zoom in closely to the body of the bug; on its left side, select the small piece of geometry that holds the wing to the body. The object is called leftWingMotor (see Figure 5.43).

  4. Right-click on the Rotate X channel in the Channel Box, and choose Key Selected.

  5. Set the frame in the timeline to frame 12. Set Rotate X to 60, and create another keyframe.

  6. Set the timeline to frame 14, set Rotate X to 0, and create another keyframe.

  7. With the leftWingMotor selected, open the Graph Editor. Select Rotate X in the column on the left, and press the f key so the editor focuses on the animation curve for this channel.

  8. Select all the keys, and choose Tangents

    Pre- and Post-Infinity
    Select the leftWingMotor on the side of the bug.

    Figure 5.43. Select the leftWingMotor on the side of the bug.

  9. Zoom out a little in the Graph Editor (drag using Alt+RMB on the editor).

  10. With the curve selected choose Curves

    Select the leftWingMotor on the side of the bug.
  11. Choose View

    Select the leftWingMotor on the side of the bug.
  12. Play the animation in the perspective view. The wing starts flapping in frame 10; it continues to flap at the same rate for the rest of the animation.

    You can view how the keyframes will cycle by choosing View Infinity. The animation curve after the last keyframe is shown as a dotted line.

    Figure 5.44. You can view how the keyframes will cycle by choosing View

    You can view how the keyframes will cycle by choosing View Infinity. The animation curve after the last keyframe is shown as a dotted line.
    Infinity. The animation curve after the last keyframe is shown as a dotted line.

    To make the wing flap faster, simply scale the keyframes.

  13. Repeat steps 7 through 11 for the rightWingMotor.

  14. Save the animation as mechBug_v08.ma. To see a version of the animation to this point, open the mechBug_v08.ma scene from the chapter5scenes directory on the DVD.

The Pre-Infinity options work just like the Post-Infinity options, except the cycling occurs before the first keyframe. The Oscillate option cycles the keyframes backward and forward.

Cycle With Offset cycles the animation curve with an offset added to the cycle based on the value of the last keyframe (see Figure 5.45).

Cycle With Offset adds an offset to the cycle based on the value of the last keyframe.

Figure 5.45. Cycle With Offset adds an offset to the cycle based on the value of the last keyframe.

The Linear option extends the curve, based on the tangency of the final keyframe, into infinity. So if you wanted the bug to continue to fly upward forever, you can select the Translate Y channel and set Post Infinity to Linear.

Playblast and F Check

A playblast is a way to create an unrendered preview of an animation. When you create a playblast, Maya captures each frame of the animation. The frames can be stored temporarily or saved to disk. You should always use playblasts to get a sense of the timing of the animation. What you see in the Maya viewport window is not always an accurate representation of how the final animation will look.

F Check (or Frame Check) is a utility program that ships with Maya. This program plays back a sequence of images with some very simple controls. When you create a playblast you have the option of viewing the sequence in your operating system's media player or in F Check. F Check is usually the better choice because of its simplicity and support for a variety of image formats.

Create and View a Playblast

This exercise will show you how to preview an animation using Playblast and F Check.

  1. Open the mechBug_v08.ma scene from the chapter5scenes directory on the DVD.

  2. Switch to the shotCam camera in the perspective view.

  3. Choose Window

    Create and View a Playblast
  4. Set Display Size to From Window and Scale to 0.75 (see Figure 5.46).

    The options for Playblast

    Figure 5.46. The options for Playblast

  5. Click Playblast to record the image sequence. In the case of the bug animation, this should take only a few seconds. A scene that has a lot of dynamics or a lot of geometry may take longer.

  6. Once the playblast is complete, F Check should open automatically and play the sequence. You can also open a sequence in F Check by choosing (from the main Maya menu bar) File

    The options for Playblast

The movie-viewing controls are at the top of the menu bar. The Alpha and Z Depth display options work only for rendered sequences that have alpha or Z Depth channels included.

In Windows, you can scrub back and forth in the animation by clicking and dragging directly on the image in F Check. You can also RMB-drag on the image to draw quick notes and annotations. The notes remain on the frame as long as F Check is open (see Figure 5.47). You can use F Check's File menu to save and load animation sequences.

The Mac version of F Check uses a separate control panel called Fcheck Info. You can scrub through the movie by dragging left or right in the window. In the Mac version you cannot draw on the images as you can with the Windows version. The Mac version may also display a blank image for a minute or so while it loads the sequence into memory. Once it has loaded, press the t hotkey to see the sequence play at the correct frame rate, otherwise the sequence may play too quickly.

F Check is a utility program that plays back image sequences. In Windows, you can draw on the frames displayed in F Check using the RMB.

Figure 5.47. F Check is a utility program that plays back image sequences. In Windows, you can draw on the frames displayed in F Check using the RMB.

Driven Keys

Driven keys are keyframes that are driven by the attributes of another object rather than time. Standard keyframes describe a change for an object's attribute at two different points in time. For example, a cube may have a Translate Y value of 0 at frame 10 and a Translate Y value of 30 at frame 50. When the animation is played, the cube moves up 30 units between frames 10 and 50. When you create driven keys, you create a relationship between any two attributes. For example, you could have the Rotate X channel of a cone control the Translate Y channel of a cube. So when the cone's Rotate X is at 0 degrees, the Translate Y channel of the cube is at 0. When the Rotate X channel of the cone is 90 degrees, the Translate Y channel of the cube is at 50. The cone is referred to as the driving object, and the cube becomes the driven object. You can even have the attribute of one object drive one or more attributes on the same object.

Driven keys are often used in rigging to automate the animation of parts of the model, which saves a lot of time and tedious keyframing when animating the rest of the model.

Creating a Driven Key

In this section, you'll create driven keys to automate the walking motion of the mechanical bug's legs so that when the bug moves forward or backward on its Z axis, the legs automatically move.

  1. Open the mechBugWalk_v01.ma scene from the chapter5scenes directory on the DVD.

  2. In the perspective view, use the Show menu to turn off visibility of the joints so it's easier to select the leg controls.

    Driven keys are set through a separate interface. You'll set up the walk cycle for one leg and then copy and paste the keys to the others.

  3. From the Animation menu set, choose Animate

    Creating a Driven Key

    The upper part of the Set Driven Key window lists the driving object (there can be only one at a time) and its attributes. The bottom part of the window lists the driven object(s) (there can be more than one at a time) and their attributes. The first step is to load the driving and driven objects. Figure 5.48 shows the Set Driven Key window with objects loaded already; you'll load the objects and attributes in the next few steps.

    The Set Driven Key interface lists the driver objects at the top and the driven objects on the bottom.

    Figure 5.48. The Set Driven Key interface lists the driver objects at the top and the driven objects on the bottom.

  4. Select the bodyCtrl curve and click the Load Driver button.

  5. Select the frontLeftFootCtrl curve and click Load Driven.

    To create the walk cycle for the front left leg, the Z translation of the bodyCtrl curve will drive the Z translation of the front left foot (making it move forward) and the Y translation of the front left foot (making it move up as it moves forward). You need to create the first key to establish the starting position of the front left leg.

  6. Select the frontLeftFootCtrl curve, and set its Translate Z channel to −1.

  7. In the Set Driven Key window, select Translate Z in the upper-right corner (this indicates the Translate Z of the bodyCtrl curve as selected in the upper left of the box). Shift+click the Translate Y and Translate Z channels in the lower right (this indicates the Translate Z and Translate Y of the frontLeftFootCtrl curve (see Figure 5.48).

  8. Click the Key button at the bottom of the Set Driven Key window.

    When you click the Key button, the current value for the channel selected in the upper right is the driver for the values of the channels in the lower left. So in step 8, the Translate Z of bodyCtrl is set to 0, the Translate Z of frontLeftFootCtrl is set to −1, and the Translate Y of frontLeftFootCtrl is set to 0. A keyframe relationship is set up between the Translate Z of bodyCtrl and the Translate Z and Translate Y of frontLeftFootCtrl. When frontLeftFootCtrl is selected, its Translate Y and Translate Z channels are colored orange in the Channel Box, indicating a keyframe has been set on these channels.

  9. Select the bodyCtrl curve again and set its Translate Z to 1. Select the frontLeftFootCtrl curve, and set its Translate Z to 1 and its Translate Y to 0.8.

  10. Make sure that in the Set Driven Key window, the Translate Z channel is selected in the upper right and both the Translate Y and Translate Z channels are selected in the lower right. Click the Key button again to set another key.

  11. Set the Translate Z of bodyCtrl to 2. Set the Translate Z of frontLeftFootCtrl to 3 and the Translate Y to 0. Click the Key button again.

  12. Set the Translate Z of bodyCtrl to 4. Don't change either setting for Translate Z or Translate Y of frontLeftFootCtrl. Set another key.

    The IK applied to the front left leg keeps it stuck in place, which makes the walk cycle easy to animate.

  13. In the perspective view try moving the bodyCtrl rig back and forth on the Y axis. You'll see the front left foot take a step.

  14. Save the scene as mechBugWalk_v02.ma. To see a version of the scene to this point, open the mechBugWalk_v02.ma scene from the chapter5scenes directory on the DVD.

Looping Driven Keys

To make the foot cycle you can simply use the Pre- and Post-Infinity settings in the Graph Editor.

  1. Continue with the scene from the previous section or open the mechBugWalk_v02.ma scene from the chapter5scenes directory on the DVD.

  2. Select the frontLeftFootCtrl and open the Graph Editor (Window

    Looping Driven Keys

    You'll see the animation curves appear on the graph. Since these are driven keys, the horizontal axis does not represent time; rather it is the Translate Z channel of the bodyCtrl curve. So as the graph moves from left to right, the value of the bodyCtrl's Translate Z channel increases. Moving from right to left, the value decreases.

  3. In the Graph Editor menu, choose View

    Looping Driven Keys
  4. Select the green Translate Y curve. Choose Curves

    Looping Driven Keys

    By doing this you create a repeating cycle for Translate Y. The foot moves up and down in the same pattern as the bodyCtrl curve moves back and forth. The Translate Z channel is a little different. Since it is moving along the Z axis in space, you need to offset the value for each step so the foot continues to step forward.

  5. Select the blue Translate Z curve and choose Curves

    Looping Driven Keys
  6. Move the bodyCtrl curve back and forth on the Z axis, and you'll see that the front left leg now walks with the bug.

  7. Save the scene as mechBugWalk_v03.ma. To see a version of the scene to this point, open the mechBugWalk_v03.ma scene from the chapter5scenes directory on the DVD.

The Pre- and Post-Infinity values of the Translate Z channel are set to Cycle With Offset so it continually steps as the bug is moved back and forth.

Figure 5.49. The Pre- and Post-Infinity values of the Translate Z channel are set to Cycle With Offset so it continually steps as the bug is moved back and forth.

Copying and Pasting Driven Keys

The trick at this point is to create the same driven key arrangement for the other five legs in the easiest way possible. You can achieve this using Copy and Paste. The important thing to remember is that to paste driven keys from a channel on one object to another, you should have one driven key already created for the target objects.

  1. Continue with the scene from the previous section or open the mechBug_v03.ma scene from the chapter5scenes directory on the DVD.

  2. From the Animation menu set, choose Animate

    Copying and Pasting Driven Keys
  3. Select the bodyCtrl curve and load it as the driver. Select all of the leg control curves except the frontLeftLegCtrl. Press the Load Driven button.

  4. Make sure the Translate Z channel of the bodyCtrl curve is at 0. Set the Translate Z of the five leg control curves to −1.

  5. Select the Translate Z channel in the upper right of the Set Driven Key window. In the lower left, make sure all the leg control curves are selected.

  6. Select the Translate Y and Translate Z channels in the lower right. Click the Key button to create an initial key for the five legs. You can close the Set Driven Key window (see Figure 5.50).

  7. Make sure the bodyCtrl curve's Translate Z channel is at 0. Select the frontLeftFootCtrl curve. In the Channel Box, highlight the Translate Y and Translate Z channels. Right-click and choose Copy Selected.

  8. Shift+click the five other leg control curves. Highlight the Translate Y and Translate Z channels, right-click, and choose Paste Selected.

    Set an initial driven key on the Translate Y and Translate Z channels of the five remaining legs.

    Figure 5.50. Set an initial driven key on the Translate Y and Translate Z channels of the five remaining legs.

    When you move the bodyCtrl curve back and forth, the other legs take one step. You need to loop the driven keys of the other legs in the Graph Editor.

  9. Select the leg control circles for the five remaining legs, and open the Graph Editor. Ctrl+click the Translate Y channels of all the leg controls in the left column of the editor. Drag a selection over the keys on the graph, and choose Curves

    Set an initial driven key on the Translate Y and Translate Z channels of the five remaining legs.
  10. Ctrl+click the Translate Z channel for each of the leg controls in the Graph Editor. Drag a selection around the keys on the graph, and choose Curves

    Set an initial driven key on the Translate Y and Translate Z channels of the five remaining legs.
  11. Drag the bodyCtrl curve back and forth on the Graph Editor. All the legs take a step; however, they all do so at the same time, which looks a little silly.

  12. To create a more convincing walk cycle for the bug, select each leg control, and open the Graph Editor. Select the keys on the graph and use the Move tool to slide them a little backward or forward in time so each leg has its own timing. See Figure 5.51.

  13. As you change the position of the Translate Z keys on the Graph Editor, you may need to also slide the curves up or down a little to make sure that they remain within the proper leg length range as they step. You can generally figure out the proper setting through experimentation.

    Add variation to the movement of the legs by sliding the keys for each leg control on the Graph Editor.

    Figure 5.51. Add variation to the movement of the legs by sliding the keys for each leg control on the Graph Editor.

    Creating a walk cycle this way is a little tricky and will take some practice. You can set keyframes on the Translate Z channel of the bodyCtrl curve so the bug walks forward and then adjust the position of the legCtrl curves as the animation plays. You can also change the position for the keyframes on the Graph Editor for pairs of legs so the midLeftLegCtrl, frontRightLegCtrl, and rearRightLegCtrl all move together, alternating with the remaining leg controls. Study the mechBugWalk_v04.ma scene in the chapter5scenes directory on the DVD to see how this walk cycle was accomplished.

  14. Save the scene as mechBugWalk_v04.ma. See Figure 5.52. To see a finished version of the walking bug, open the mechBugWalk_v04.ma scene from the chapter5scenes directory on the DVD.

    The completed walk cycle is completely automated for the bug.

    Figure 5.52. The completed walk cycle is completely automated for the bug.

Animation Using Expressions

Mathematical expressions can be used to automate animation of an object's attributes. Expressions can be very simple or quite complex. There is almost an infinite variety of expression types and applications. In this section, you'll see how to add a few simple and common expressions to animate the bug's antennae.

  1. Open the mechBugExpressions_v01.ma scene from the chapter5scenes directory on the DVD. This scene has an animation of the mechanical bug walking.

  2. Select the yellow circle in front of the bug. This is the antennaCtrl, which controls the rotation of the antenna control group.

  3. In the menu above the Channel Box, select the Rotate Y channel so that it is highlighted. Choose Edit

    Animation Using Expressions
  4. In the Expression section type rotateY=sin(time);. Click the Create button to add the expression to the antennaCtrl object (see Figure 5.53).

    This expression creates a relationship where the rotation of the antennaCtrl group moves back and forth over time. The sin function creates a smooth curve using time as the input. The value of sin moves between −1 and 1. The value of the Rotate Y channel is expressed in degrees, so this expression does not create a very visible motion. It oscillates between −1 and 1 degrees. To fix this, you can add a multiplier to the expression.

    Enter an expression for the antennaCtrl curve in the Expression Editor.

    Figure 5.53. Enter an expression for the antennaCtrl curve in the Expression Editor.

    When you click the Create button, Maya fills in the detailed path to the antennaCtrl channel. The original expression is replaced with antennaCtrl.rotateY=sin(time). As long as an object is selected when you open the Expression Editor, you can type the name of the channel, and Maya will understand that the channel is connected to the selected object. Otherwise, you must specify the path to the channel by typing objectName.channelName. Each statement in the expression should end with a semicolon.

  5. In the Expression Editor, change the expression to read antennaCtrl.rotateY=30*(sin(time));. Click the Edit button to change the expression.

  6. Rewind and play the animation. The antennae swing back and forth.

  7. If you want the motion to move faster, create a multiplier for time. Change the expression so that it reads antennaCtrl.rotateY=30*(sin(time*2));. This makes the rotation occur twice as fast.

    If you want to slow down the motion, multiply the time by a fraction. time*0.5 makes the rotation move at half the original speed.

    You can add an expression to the Translate Y of the antennaCtrl group to make the antenna move up and down.

  8. Select the antennaCtrl and open the Expression Editor (if it's not still open). In the Expression section, type translateY=cos(time); below the first expression (see Figure 5.54). Click the Edit button to create the expression.

    Add the expression for the Y translation as a second line in the Expression Editor.

    Figure 5.54. Add the expression for the Y translation as a second line in the Expression Editor.

    This moves the antennaCtrl group up and down, making the antennae rotate upward and downward (recall that the locators in the antennaCtrl group are aim locators for the antennae geometry). The cos function (cosine) works like the sin function (sine) except the cosine is the opposite of sine, so when sine is at −1, cosine is at 1 and vice versa.

    To make the motion more interesting, you can add a noise function to each of the locators in the antenna control group. The noise function creates a continuous random pattern that moves between −1 and 1 (as opposed to the rand function, which creates a discontinuous random motion between −1 and 1).

  9. Select one of the yellow locators in the perspective view. In the Channel Box, highlight the Translate Y channel, and choose Edit

    Add the expression for the Y translation as a second line in the Expression Editor.
  10. In the Expression section type translateY=noise(time*4);. Then click the Create button to make the expression. Play the animation; you'll see the antenna move somewhat randomly.

  11. Add a similar expression to the Translate Y of the other yellow locator. To make the motion slightly different, try translate=noise(time*5);.

  12. Save the scene as mechBugExpressions_v02.ma. To see a version of the scene, open the mechBugExpressions_v02.ma scene from the chapter5scenes directory on the DVD.

Conditional Statements in Expressions

You can make expressions even more sophisticated by adding variables and conditional statements. A simple conditional statement looks like this in the Expression Editor:

if (x is true){
     Perform action;
}
else
{
     Perform a different action;
}

There are other ways to state conditionals, but this is the most common and simplest way to do it. To make the motion of the antennae more interesting, you'll make the antennae move faster when they are closer to the ground.

  1. Continue with the scene from the previous section or open the mechBugExpressions_v02.ma scene from the chapter5scenes directory on the DVD.

  2. Select one of the yellow locators in front of the bug, and open the Expression Editor using the Edit menu in the Channel Box.

    To create a condition, you'll make a variable that can hold a value. The value will be different depending on the outcome of the test performed by the conditional statement. In this case, the variable can hold a value, which will be a multiplier for time in the noise(time) statement applied to the locator's Translate Y channel. Before you can use the variable, you should declare it at the start of the expression. This lets Maya know what type of data the variable will hold. In this case, the variable can be an integer (a number without a decimal). The variable you will create is called $antSpeed, for antenna speed. All variables must be preceded by a dollar sign.

  3. In the Expression Editor, select the text and press the Backspace or Delete key to clear the Expression field. Type int $antSpeed; in the field.

  4. Press the Return key (the Return key on the keyboard, not the Enter key on the numeric keypad), and enter the following lines:

    if (antennaCtrl.translateY<0){
         $antSpeed = 10;
    }
    else
    {
         $antSpeed=2;
    }
    translateY = noise(time*$antSpeed);

    Since the expression is testing to see the height of the antennaCtrl group, you need to specify the path to the antennaCtrl group's Translate Y channel. Expressions for channels are self-contained, so unless you specify the path to another object's channel, Maya won't understand what you're talking about. Figure 5.55 shows the expression in the Expression Editor.

    Create a conditional statement as an expression to make the antenna move faster when it's closer to the ground.

    Figure 5.55. Create a conditional statement as an expression to make the antenna move faster when it's closer to the ground.

  5. Add the same expression to the other locator in the group. Use different values for the $antSpeed variable so that the two antennae move in different ways.

  6. Save the scene as mechBugExpressions_v03.ma. To see a finished version of the scene, open the mechBugExpressions_v03.ma scene from the chapter5scenes directory on the DVD.

Motion Path Animation

You can animate the movement of an object by attaching the object to a curve and then sliding down the length of the curve over time. This is known as motion path animation.

Create a Motion Path

  1. Open the mechBugPath_v01.ma scene from the chapter5scenes directory on the DVD.

  2. Turn on the grid display and choose Create

    Create a Motion Path
  3. Draw a curve on the grid using any number of points; make sure the curve has some nice twisty bends in it.

  4. Right-click on the curve and choose Control Vertex. Use the Move tool to move the CVs of the curve up and down so the curve is three-dimensional (see Figure 5.56).

  5. In the Outliner, select the mechanicalBug group and Ctrl+click the curve. From the Animation menu set, choose Animate

    Create a Motion Path
    Draw and shape a curve in the scene.

    Figure 5.56. Draw and shape a curve in the scene.

  6. In the options, choose Edit

    Draw and shape a curve in the scene.
    The options for Attach To Motion Path

    Figure 5.57. The options for Attach To Motion Path

    The default Time Range is set to Time Slider so the bug will travel the length of the curve based on the current length of the time slider (200 frames in this scene). You can change this after the motion path is created.

    The Follow option orients the animated object so the front axis follows the bends in the curve. The Bank option adds a rotation on the Z axis around bends in the curve to simulate banking.

  7. Play the animation. The bug follows the path (see Figure 5.58).

    At this point the animation looks a little silly; the other parts of the bug need to be animated, which you can do using the techniques described in the chapter. By attaching the mechanicalBug group as opposed to the bodyCtrl group, you now have the option of adding additional animation to the bodyCtrl curve to add variation in the movement of the bug as it flies along the curve.

    The bug is attached to the motion path curve. As the animation plays the bug travels along the length of the curve.

    Figure 5.58. The bug is attached to the motion path curve. As the animation plays the bug travels along the length of the curve.

    You can change the rate at which the bug flies along the curve by editing the motionPath1 node's U Value attribute on the Graph Editor.

  8. In the Outliner, select the mechanicalBug group. In the Channel Box under Inputs, select motionPath1.

  9. Choose Window

    The bug is attached to the motion path curve. As the animation plays the bug travels along the length of the curve.
  10. In the left-hand column, select the motionPath1 U Value attribute, and press the f hot key to focus the graph on its animation curve.

  11. Use the graph-editing tools to edit the curve.

  12. Save the scene as mechBugPath_v02.ma. To see a version of the scene to this point, open the mechBug_v02.ma scene in the chapter5scenes directory on the DVD.

Animating Constraints

You can constrain an object to more than one node. The weighting of the constraint strength can be blended between the two nodes and even animated. This is a great technique for solving difficult animation problems, such as a character picking up and putting down an object.

Dynamic Parenting

Dynamic parenting refers to a technique in which the parenting of an object is keyframed. In this exercise, you'll animate the mechanical bug sitting on a moving object for a few moments before flying off along a motion path.

  1. Open the mechBugConstrain_v01.ma scene from the chapter5scenes directory on the DVD.

    This scene has the bug rigged and sitting at the origin of the grid. A cattail is bobbing up and down in the breeze. Above the cattail, a curve defines a motion path (see Figure 5.59).

    The scene contains an animated cattail and a motion path.

    Figure 5.59. The scene contains an animated cattail and a motion path.

    A locator named bugLanded is constrained to one of the joints of the cattail using a parent constraint. On the motion path is another locator named bugFly. To make the bug sit on the moving cattail, you'll create a parent constraint between the bug and the bugLanded locator.

  2. In the Outliner, select the bugLanded locator and Ctrl+click the mechanicalBug group. From the Animation menu set, choose Constrain

    The scene contains an animated cattail and a motion path.
    The options for the parent constraint

    Figure 5.60. The options for the parent constraint

    The mechanical bug now appears on the end of the cattail. You can reposition the bug on the cattail using the bodyCtrl and legCtrl curves.

  3. In the Display Layers window, turn on the CONTROLS layer. Select the blue bodyCtrl curve, and pull it upward to move the bug up above the end of the cattail.

  4. Turn on Wireframe view. Select the red legCtrl circle, and move it upward with the Move tool so the legs are positioned on the end of the cattail. (Use the Show menu in the viewport to turn off the visibility of Joints so that you can easily see the geometry.)

  5. Position each of the small purple leg control circles so the bug's legs are posed on the end of the cattail geometry (see Figure 5.61).

  6. Play the animation. You'll see the bug sticking to the cattail as it moves up and down.

  7. Set the timeline to frame 320. In the Outliner, select the bugFly locator, and Ctrl+click the mechanicalBug. Create another parent constraint; the same options should be applied automatically when you create the constraint.

    When you play the animation you'll see that the bug is floating between the two locators, thus inheriting a blend of their animation. This is because the strength of both constraints is at 1 (or full strength).

    Pose the legs using the legCtrl curves so the bug is standing on the cattail.

    Figure 5.61. Pose the legs using the legCtrl curves so the bug is standing on the cattail.

  8. Set the timeline to frame 353. This is a point where the two locators are very close and a good time for the bug to start to fly off.

  9. In the Outliner, expand the mechanicalBug group. Select the mechanicalBug_parentConstraint1 node.

  10. In the Channel Box, set Bug Fly W1 to 1 and Bug Landed W0 to 0. The bug reorients itself to match the orientation of the bugFly locator.

  11. Shift+click both the Bug Landed W0 channel and the Bug Fly W1 channel in the Channel Box (see Figure 5.62). Right-click and choose Key Selected.

    Set the weights of the parent constraint and key it at frame 353.

    Figure 5.62. Set the weights of the parent constraint and key it at frame 353.

  12. Set the timeline to 347. Reverse the values of the two weights so Bug Landed W0 is at 1 and Bug Fly W1 is at 0. Set another keyframe.

  13. Rewind and play the animation. You'll see the bug sitting on the cattail as it bobs up and down. At frame 347 the bug switches to the motion path and flies off.

  14. With the mechanicalBug parentConstraint1 node selected, open the Graph Editor. Select the Bug Landed W0 and Bug Fly W1 channels on the left column of the Graph Editor, and press the f hot key to focus on their animation curves.

  15. Use the curve-editing tools to fine-tune the animation so the transition between the cattail and the motion path is smoother. This usually takes a fair amount of experimentation (Figure 5.63).

    In some cases you can create a smoother transition by extending the length of time between the keyframed weight values. It depends on what type of motion you are trying to achieve and your own personal taste.

  16. Save the scene as mechBugConstrain_v02.ma. To see a version of the scene to this point, open the mechBugConstrain_v02.ma scene from the chapter5scenes directory on the DVD.

You can also animate the bodyCtrl curve and the leg controls to create a more believable motion to the bug as he takes flight.

Edit the weights of the constraint on the Graph Editor.

Figure 5.63. Edit the weights of the constraint on the Graph Editor.

Animation Layers

Animation layers are a new feature in Maya 2009. Animation layers separate the keyframe data applied to objects in the scene so you can create variations of animation for approval from a director, blend different versions of an animation together for a higher level of control, or organize the animated parts of an animation. This section is a tour of how animation layers work and some of the ways they can be applied in a scene. There is a great amount of flexibility in how animation layers can be used; no doubt you will create your own preferred animation layer workflow after a little bit of practice.

Create an Animation Layer

In this section, you'll create a simple dancing motion for the mechanical bug. Animation layers take some getting used to, so you'll start with a very simple animation.

  1. Open the mechBugLayers_v01.ma scene from the chapter5scenes directory on the DVD.

  2. Set the current frame on the timeline to 1. Select the blue bodyCtrl curve above the bug, and set its Translate Y channel to −0.5. Create a keyframe for this channel.

  3. Set the current frame to 20, set Translate Y to 0.5, and create another keyframe.

  4. Create three more keyframes for the bodyCtrl curve:

    • Frame 40 Translate Y: −0.5

    • Frame 60 Translate Y: 0.5

    • Frame 80 Translate Y: −0.5

      When you play the animation the bug bobs up and down.

  5. In the Layer panel in the lower-right corner of the screen below the Channel Box, set the Mode to Anim. This switches the Layer Editor to Animation layers as opposed to Display or Render layers.

  6. Choose Layers

    Create an Animation Layer

    In the perspective view nothing has changed regardless of which layer is selected.

  7. Double-click on AnimLayer1 and rename it bounce (see Figure 5.64).

    Create a new animation layer in the scene and rename it bounce.

    Figure 5.64. Create a new animation layer in the scene and rename it bounce.

  8. Select the bodyCtrl curve. In the Animation Layer panel, select the bounce layer, RMB+click on it (or select it from the Layer menu), and choose Add Selected Objects. This adds just the bodyCtrl curve. Notice that all the channels in the Channel Box are now yellow. You'll also notice that in the INPUT section under the Channel Box for the bodyCtrl curve, bounce has been added to the list of inputs.

    When creating an animation layer you have the option of creating the layer from selected objects in the scene or copying an existing layer (using the options in the Layers menu). When you copy a layer, the keyframes are also copied to the new layer. The Layers menu has a lot of options you'll explore as you go through the next few exercises.

  9. Select the bounce layer, and a green circle appears on the right. This indicates that the layer is active.

  10. Play the animation. It looks the same as before. Notice that there are no keyframe tick marks on the timeline. Select the BaseAnimation layer; the tick marks reappear. So what does this mean?

Each layer has its own set of keyframes for the objects in that particular layer. The bounce layer has no keyframes yet, so what you're seeing when you play the animation is the keyframes set on the BaseAnimation layer. The way in which the keyframes on one layer interact with the keys on another depends on the layer's Mode and Accumulation settings.

You can also use Extract

Create a new animation layer in the scene and rename it bounce.

Layer Mode

The mode of a layer can either be Additive or Override. Additive layers blend the values of the keys together so the resulting animation is a combination of the two layers. Using the Additive mode you can add changes to the animation without affecting the original keyframes on the BaseAnimation layer.

When a layer is set to Override mode, the animation on that layer overrides the animation on the layers below it. Override mode is a good way to create different "takes" or versions of an animation without affecting the original BaseAnimation layer.

Follow the next steps to see how these modes work.

  1. In the Layer Editor, select the bounce layer. Choose (from the menu in the Layer Editor) Layers

    Layer Mode
  2. If you switch to the BaseAnimation layer, you can see the keyframes on the timeline, but the bug still doesn't move. This is because even though the bounce layer is not selected, it is overriding the BaseAnimation layer.

  3. In the Layer Editor, click the red Mute Layer button (see Figure 5.65). The Mute Layer button temporarily disables the layer; when you click Play, you'll see the bug move up and down again.

    The Mute Layer button temporarily disables a layer.

    Figure 5.65. The Mute Layer button temporarily disables a layer.

  4. Turn the Mute Layer button off, and then play the animation. The bug should stop moving. Select the bounce layer, and drag the Weight slider slowly to the left as the animation plays (see Figure 5.66).

    The Weight slider determines the amount of influence the layer has over the animation.

    Figure 5.66. The Weight slider determines the amount of influence the layer has over the animation.

    As you drag the Weight slider down, the influence of the overriding layer decreases, and you can see the bug start to move up and down again. When the weight is at zero the overriding layer has no more influence. The K button to the right of the Weight slider sets a keyframe on the Weight value so you can animate the strength of the weight over time.

  5. Select the bounce layer. Set the Weight for the bounce Layer to 1, and make sure the layer is not muted. When you play the animation you should see no motion. Select the bodyCtrl curve, and set the following keyframes on the Translate Y channel.

    • Frame 1 Translate Y: −0.05

    • Frame 10 Translate Y: 0.5

  6. With the bodyCtrl curve selected, open the Graph Editor and select the Translate Y channel. Drag a selection around the keys, and choose Curves

    The Weight slider determines the amount of influence the layer has over the animation.
  7. When you play the animation, the bug bounces a little faster. As you lower the Weight for the layer, you'll see the slower bouncing motion of the BaseAnimation layer.

    If you turn off the Passthrough option in the Layers

    The Weight slider determines the amount of influence the layer has over the animation.
  8. Set Layer Mode to Additive, as shown in Figure 5.67. Set the Weight of the bounce layer to 1, and play the animation. You can see that the resulting animation is now a combination of the keyframe values on the bounce and BaseAnimation layers (the Passthrough option has no effect on additive layers).

  9. In the Options menu of the Layer Editor, turn off Auto Ghost Selected Objects. Click on the red G in the Base Animation layer. This creates a ghost of the animated objects on this layer so you can compare it with the animation on other layers. In this case, you'll see a red copy of the bodyCtrl curve moving according to the keyframes set on the BaseAnimation layer.

  10. Rewind the animation and select the bodyCtrl curve. In the Layer Editor, choose Create Layer From Selected. Name the new layer rock and set its mode to Override.

    When Layer Mode is set to Additive, the animation of the two layers is combined.

    Figure 5.67. When Layer Mode is set to Additive, the animation of the two layers is combined.

  11. Select the rock layer. In the Channel Box, highlight the Rotate X, Y, and Z channels, and set a keyframe on these channels.

  12. Turn on the Auto Keyframe feature by clicking the key icon to the right of the timeline.

  13. Set the timeline to various points in the animation, and use the Rotate tool to rotate the bug, making him do a happy little dance.

  14. Rewind and play the animation. You'll see him move around. Experiment with the weight of the rock layer; try setting its mode to Additive and observe the result.

    By varying the weight, you get a pretty good dancing action (for a mechanical bug) fairly easily.

  15. Save the scene as mechBugLayers_v02.ma. To see a version of the scene to this point, open the mechBugLayers_v02.ma scene from the chapter5scenes folder on the DVD.

Other Options in the Layer Editor

The Layer Editor includes other options as well. These are:

Lock Layer

Click the padlock icon to the left of the layer. When this is active, you cannot add keyframes to the layer. This is helpful if you use Auto Keyframe because it prevents you from accidentally changing the animation on a layer.

Solo Layer

Click the horizontal bar icon to left of the layer. This temporarily disables the animation of other layers so you can focus on just the soloed layer (more than one layer can be in solo mode).

Mute Layer

This button disables animation on the selected layer.

Ghost Layer

This button (G) creates a ghost of the animated objects on the layer. You can change the color of the ghost by right-clicking the G button and choosing a color from the pop-up window.

Zero Key Layer

The Zero Key Layer is a way to edit a small portion of an animation using an animation layer. Select an object in the layer, and click the Zero Key icon in the upper left of the Layer Editor to create a starting point on the timeline for the edit. Then move the Time slider to a later point in the animation, and click the Zero Key icon again. Any keyframes you set on the object between these two points in time will not be offset from the original animation.

You can change the order of layers by clicking the up and down arrows in the upper right of the Layer Editor window. The order of layers affects how the animation behaves. For instance, an override layer overrides animation on the layers below it but not above it. You can stack additive layers above, and Override Layer adjusts their weighting and rearranges their order to create different variations on the animation.

The Layer Accumulation settings determine how scaling and rotation are calculated when two or more layers that have animated scaling and rotation are combined.

The animated scaling on two layers can be added or multiplied depending on the Layer Accumulation setting.

Euler and quanternion are two different methods for calculating rotation. Euler is the standard method used in Maya. If the combination of rotation animation on two different layers leads to an unexpected result, try switching to quanternion in the Layer Accumulation settings.

Layer Hierarchy

You can create a hierarchical relationship between animation layers. This is useful as an organizational tool and can speed up your workflow as you animate. Creating a hierarchy means parenting one or more animation layers to another. When you mute or solo the parent layer, all the child layers are also muted or soloed. Likewise the Weight and Mode settings of the parent can affect the child layers. When animation layering becomes complex, you can use the hierarchy to quickly enable, disable, and rearrange the layers.

  1. Continue with the scene from the previous section or open the mechBugLayer_v02.ma scene from the chapter5scenes folder on the DVD.

  2. In the Animation Layer Editor, mute the rock and bounce layers. You'll notice that the bug still bounces. This is because of the keyframes set on the BaseAnimation layer.

  3. Before creating a hierarchy for the layers, you can quickly move the animation on the BaseAnimation layer to its own new layer. To do this, select the bodyCtrl curve and the BaseAnimation layer. Right-click on the BaseAnimation layer and choose Extract Selected Objects.

    Extracting the bodyCtrl object from the BaseAnimation layer creates a new animation layer that contains the bodyCtrl curve and its animation. At the same time, the keyframes from the bodyCtrl curve are removed from the BaseAnimation layer. If you mute all the layers except BaseAnimation, the bug no longer moves when you play the animation.

  4. Name the new layer bounce1, and rename bounce as bounce2.

  5. Make sure bounce1 is below bounce2. Mute all the layers (see Figure 5.68).

    Copy the BaseAnimation layer, renamed it bounce1, and move it below the other layers. Mute all layers.

    Figure 5.68. Copy the BaseAnimation layer, renamed it bounce1, and move it below the other layers. Mute all layers.

  6. In the Layer Editor choose Layers

    Copy the BaseAnimation layer, renamed it bounce1, and move it below the other layers. Mute all layers.
  7. Select the circle under the front left leg. In the Layer Editor, choose Layers

    Copy the BaseAnimation layer, renamed it bounce1, and move it below the other layers. Mute all layers.
  8. MMB drag FLeftLegAnim on top of the legAnim layer to make it a child of this layer. A small black triangle appears, and the FLeftLegAnim layer is indented above the legAnim layer (see Figure 5.69).

    The FLeftLegAnim layer is parented to the legAnim layer.

    Figure 5.69. The FLeftLegAnim layer is parented to the legAnim layer.

  9. Repeat steps 7 and 8 for the front right leg circle. Name the new layer FRightLegAnim.

  10. Select the FLeftLegAnim layer and, in the perspective view, select the circle under the front left leg. In the Channel Box, Shift+click all the channels except the Translate channels. Right-click and choose Remove From Selected Layers (see Figure 5.70).

    Remove the Rotate and Scale channels from the animation layer.

    Figure 5.70. Remove the Rotate and Scale channels from the animation layer.

  11. With the FLeftLegAnim layer selected, set a keyframe on the left leg control circle's Translate channels. Then use the Auto Keyframe feature to create an animation of the leg moving up and down as if it's tapping out a little beat.

  12. Switch to the FRightLegAnim layer, and create a similar animation for the front right leg.

  13. When you have a nice animation going for both layers, unmute the other layers and play the animation.

  14. Click the black triangle on the legAnim layer to collapse the layer. Experiment with the Weight setting of the legAnim layer. The Weight value of the parent layer applies to both child layers as well. This is also true for the Layer Mode, Mute, and Solo settings.

    You can create further nested layers within the hierarchy. Each child layer can have its own Mode setting. To keep things simple, you can use empty layers as parent layers. The empty parent layers can be used to set the Weight and Mode operation of the child layers. If the parent layer is empty, you don't have to worry about how the animation in a parent layer is blended with the child layers.

  15. Save the scene as mechBugLayers_v03.ma. To see a version of the scene to this point, open the mechBugLayers_v03.ma scene from the chapter5scenes folder on the DVD.

Merging Layers

You can merge the animation of two layers into a single animation layer.

  1. Continue with the scene from the previous section or open the mechBugLayers_v03.ma scene from the chapter5scenes folder on the DVD.

  2. In the Animation Layers Editor, select the bounce2 and bounce1 layers.

  3. Choose Layers

    Merging Layers
  4. Turn on the Smart Bake option.

    When you merge two or more layers, the animation of the objects on the layers is baked. You can choose to sample the baked keyframes based on the Sample By value. For instance, if you set Sample By to 1, then the object on the resulting baked layer will have a keyframe placed on the animated channels for every frame of the animation. A setting of 2 creates a key on every other frame. The Smart Bake option creates a curve from the combined animation layers with fewer keyframes. The Increase Fidelity setting increases the accuracy of the resulting animation curve to better represent the combined animation of the two layers. The Sample By option is more accurate but creates a lot of keyframes, which can be hard to edit. The Smart Bake option works very well when there are fewer layers or the animation is simple.

    You can bake a parent layer and all its child layers into a single layer. You can also choose to delete the original layers or keep them. Figure 5.71 shows the options for merging layers.

  5. Click Apply to merge the layers. A new layer named Merged Layer is created. Rename the new layer bounce. Select the bounce layer. In the perspective view, select the bodyCtrl and open the Graph Editor. You'll see the merged animation curve in the Graph Editor (see Figure 5.72).

  6. Save the scene as mechBugLayers_v04.ma. To see a version of the scene, open the mechBugLayers_v04.ma scene in the chapter5scenes folder on the DVD.

The options for merging layers

Figure 5.71. The options for merging layers

The merged animation curve is displayed in the Graph Editor.

Figure 5.72. The merged animation curve is displayed in the Graph Editor.

The Bottom Line

Create a simple rig with joints and constraints

Joints are a deformer commonly used in character animation. The hierarchical relationship makes them useful for rigging many types of characters. When creating robots and mechanical devices, you can build a skeleton using joints and then parent the parts of the robot to the joints.

Constraints are used to constrain the channels of one object to the world space coordinates of another object. Constraints are useful as rigging tools for snapping the pivot point of one object to another.

Master it

Create a simple joint chain for a robot's arm. Use the joint chain to animate an arm made from simple polygon surfaces.

Use Inverse Kinematics

Inverse Kinematics creates a goal object, known as an End Effector, for joints in a chain. The joints in the chain orient themselves based on the translation of the goal. The IK Handle tool is used to position the End Effector.

Master it

Create an Inverse Kinematic control for a simple arm.

Animate with keyframes

A keyframe marks the state of a particular attribute at a point in time on the timeline. When a second keyframe is added to the attribute at a different point in time, Maya interpolates the values between the two keyframes, creating animation. There are a number of ways to edit keyframes using the timeline and the Channel Box.

Master it

Create a number of keyframes for the Translate channels of a simple object. Copy the keyframes to a different point in time for the object. Try copying the keyframes to the Scale channels. Try copying the keys to the Translate channels of another object.

Use the Graph Editor

More sophisticated animation editing is available using the animation curve editing tools on the Graph Editor.

Master it

Create a looping animation for the mechanical bug model using as few keys as possible. The bug should leap up repeatedly and move forward with each leap.

Preview animations with Playblast

Playblast is a tool for viewing the animation as a flipbook without having to actually render the animation. F Check is a utility program that is included with Maya. Playblasts can be viewed in F Check.

Master it

Create a playblast of the mechBugLayers_v04.ma scene.

Use driven keys

A driven key is a keyframe that uses the attributes of one object as an input instead of time. Using driven keys you can automate many parts of an animation that might otherwise be tedious.

Master it

Create an alternate automated walk cycle for the mechanical bug so that when it walks sideways (along its Translate X), the legs automatically move in a crablike fashion.

Animate with expressions

Expressions are a powerful way to automate the movement of an object. Using conditional statements you can create an expression that causes the animation to react to changes in the scene automatically.

Master it

Create an expression to randomly rotate the bug's eyes up and down. Make the rotation faster based on the height of the bodyCtrl curve.

Animate with motion paths

Motion paths allow you to attach an object to a curve. Over the course of the animation the object slides along the curve based on the keyframes set on the motion path's U Value.

Master it

Make the bug walk along a motion path. See if you can automate a walk cycle based on the position along the path.

Use animation layers

Animation layers are a new feature in Maya 2009. Using animation layers you can add new motion that can override existing animation or be combined with it.

Master it

Create animation layers for the flying bug in the mechBug_v08.ma scene in the chapter5scenes directory on the DVD. Create two layers: one for the bodyCtrl curve and one for the legsCtrl curve. Use layers to make the animation of the wings start with small movements and then flap at full strength.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset