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:
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.
You create joints using the Joint tool (from the Animation menu set choose Skeleton
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.
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
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.
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).
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.
In the Layer Editor, turn off the BODY display layer so only the legs are visible.
Switch to the Animation menu set, and turn on Grid Snapping. Choose Skeleton
In the Outliner, expand the legs group. Select the frontleftLegBase object. Ctrl+click joint1 and choose Constrain
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.
In the Outliner, expand joint1. Select joint1_pointConstraint1, and press the Delete key to remove the constraint.
Repeat steps 4 and 5 (or use the shelf button created in the "MEL In Action" section) to reposition joint2 to the frontLeftFoot object.
Turn on Point Snapping (turn off Grid Snapping), and position joint3 at the very tip of the frontLeftFoot.
Rename joint1 frontLeftLegJoint. Rename joint2 frontLeftFootJoint, and rename joint3 frontLeftEndJoint.
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).
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.
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).
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.
An aim constraint constrains the orientation of an object relative to the position of one or more other objects.
Continue with the scene from the previous section or open the mechBugRig_v02.ma
scene from the chapter5scenes
directory on the DVD.
Turn on the display layer for BODY; turn off the LEGS layer so the legs are hidden and the body is displayed.
Create a locator and name it eyeAimLoc. Set the eyeAimLoc's Translate X, Y, and Z channels to 0, 0, and 2, respectively.
In the Outliner, expand the bugBodyGroup. MMB-drag eyeAimLoc into the bugBody group.
Select the eyeAimLoc and choose Modify
Expand the frontBody group, the head group, and the face group.
Select the eyeAimLoc and Ctrl+click the eyeBase group (see Figure 5.8). From the Animation menu set choose Constrain
In the options choose Edit
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.
Create two new locators named leftAntennaAimLoc and rightAntennaAimLoc.
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.
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.
In the Outliner, MMB-drag antennaAim into the bugBody group.
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).
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.
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.
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).
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.
In this section you'll add Inverse Kinematics to each of the legs on the mechanical bug.
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.
From the Animation menu set choose Skeleton
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).
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.
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 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).
Try moving the IK Handle; you'll see the rest of the joint rotate based on the position of the handle.
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.
Create a NURBS circle (Create
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.
Select the nurbsCircle1 and rename it frontLeftFootCtrl. Choose Modify
Select the frontLeftFootCtrl, and Ctrl+click the ikHandle. Create a point constraint so the handle is constrained to the frontLeftFoot circle (Constrain
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.
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).
When you have finished making the controls for the other legs, select the control circles and group them. Name the group legsControlGroup.
Select the legsControlGroup group, and choose Modify
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.
Select the legsCtrl circle, and Ctrl+click the legsControlGroup. Choose Constrain
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.
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.
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.
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.
Continue with the scene from the previous section or open the mechBugRig_v04.ma
scene from the chapter5scenes
directory on the DVD.
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.
Turn off the Visibility of the CONTROLS layer so the scene is blank.
Turn on the Visibility of the grid. Turn on Grid Snapping. Choose Create
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.
Center the pivot of the curve and name it bodyCtrl.
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.
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.
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).
Select the bodyCtrl curve in the Outliner, and Ctrl+click the bug group. Choose Constrain
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.
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.
Finally, select everything in the Outliner except the ground plane, and group them together. Name the group mechanicalBug.
Add the bodyCtrl curve and the three locators for the eyes and antenna controls to the CONTROLS layer.
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).
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.
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.
In this exercise you'll see the various ways you can set and manipulate keyframes in the Maya interface.
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:
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).
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.
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).
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).
Rewind and play the animation; you'll see the bug start moving upward on frame 20 and stop on frame 48.
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.
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.
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.
Shift+click all six of the small purple leg control circles below the bug's feet (see Figure 5.22).
With the control circles selected, press the W hot key to place a keyframe on the Translate channels for all the selected curves.
Click the Key icon to the far right of the timeline to turn on Auto Keyframe.
Set the timeline to frame 40. Select each of the circles and move them in toward the center (see Figure 5.23).
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.
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.
You can reposition keys on the timeline interactively by selecting the key markers and sliding them back and forth.
Continue with the scene from the previous section or open the mechBug_v02.ma
scene from the chapter5scenes
directory on the DVD.
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).
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.
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.
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.
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.
There are a number of ways you can quickly copy, paste, and cut keyframes on the timeline and in the Channel Box.
Continue with the scene from the previous section or open the mechBug_v03.ma
scene from the chapter5scenes
directory on the DVD.
Select the bodyCtrl curve in the perspective view. On the timeline, Shift-drag a selection over both of the keyframes.
Right-click on the selection and choose Copy (see Figure 5.25).
Deselect the keys by clicking on the timeline, move to frame 70, right-click on the timeline, and choose Paste
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.
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).
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 also cut and delete keyframes in the Channel Box. The Duplicate keyframe operation allows you to copy keyframes from one object to another.
Create a NURBS sphere and set its Translate X to 5.
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 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
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.
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).
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.
Open the mechBug_v01.ma
scene from the chapter5scenes
directory on the DVD.
Open the Preferences window by choosing Window
Make sure Auto Keyframe is enabled. Press Save to save the preferences (see Figure 5.29).
Set the length of the timeline to 120. Set the current frame to 20.
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.
Set the timeline to frame 25, and move the bodyCtrl curve down so the Translate Y channel is about −0.78.
Set the timeline to frame 35. Drag up on the bodyCtrl curve until the Translate Y channel is around 7 units.
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.
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
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
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
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
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.
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.
In the Perspective View menu, choose Panels
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).
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.
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.
Continue with the scene from the previous section or open the mechBug_v04.ma
scene from the chapter5scenes
directory on the DVD.
In the Display Layers menu, turn off the visibility of the LEGS layer so you can just focus on the animation of the body.
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.
On the menu bar of the Graph Editor, click the first tangent icon or choose Tangents
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.
Try switching to the clamped-type tangent (second tangent icon, or choose Tangents
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).
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.
With all of the keys selected in the Graph Editor, click on the last tangent icon, or choose Tangents
A good place to start editing the animation is the initial leap that occurs at frame 20.
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.
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.
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.
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.
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
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).
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).
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.
Drag a selection around both handles of the second key on the Translate Y channel. Choose Key
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
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.
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.
Continue with the scene from the previous section or open the mechBug_v05.ma
scene from the chapter5scenes
directory on the DVD.
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.
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).
With the key selected choose Curves
Select the handles and choose Keys
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).
Break the tangents on the selected handles (Keys
Pull the outcoming tangent of the fourth keyframe down and to the right (lower-right image of Figure 5.37).
Play the animation, and see how changing the length of the handles affects the way the bug jumps.
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.
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.
Continue with the scene from the previous section or open the mechBug_v06.ma
scene from the chapter5scenes
directory on the DVD.
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.
Drag a selection marquee over all the keys to the right of the third key.
From the Graph Editor menu bar, choose Edit
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.
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).
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.
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.
With the keys still selected, choose Edit
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.
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).
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.
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.
Open the mechBug_v07.ma
scene from the chapter5scenes
directory on the DVD.
Turn off the visibility of the LEGS layer so you can focus on just the bug body.
Select the blue bodyCtrl curve and open the Graph Editor. Select the Translate Y channel so it is isolated on the graph.
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.
Drag a selection around the second key on the graph. From the menu in the Graph Editor, choose Keys
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.
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.
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.
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.
Open the mechBug_v07.ma
scene from the chapter5scenes
directory on the DVD.
Set the timeline to 10.
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).
Right-click on the Rotate X channel in the Channel Box, and choose Key Selected.
Set the frame in the timeline to frame 12. Set Rotate X to 60, and create another keyframe.
Set the timeline to frame 14, set Rotate X to 0, and create another keyframe.
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.
Select all the keys, and choose Tangents
Zoom out a little in the Graph Editor (drag using Alt+RMB on the editor).
With the curve selected choose Curves
Choose View
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.
Figure 5.44. You can view how the keyframes will cycle by choosing View
To make the wing flap faster, simply scale the keyframes.
Repeat steps 7 through 11 for the rightWingMotor.
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).
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.
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.
This exercise will show you how to preview an animation using Playblast and F Check.
Open the mechBug_v08.ma
scene from the chapter5scenes
directory on the DVD.
Switch to the shotCam camera in the perspective view.
Choose Window
Set Display Size to From Window and Scale to 0.75 (see Figure 5.46).
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.
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 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.
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.
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.
Open the mechBugWalk_v01.ma
scene from the chapter5scenes
directory on the DVD.
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.
From the Animation menu set, choose Animate
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.
Select the bodyCtrl curve and click the Load Driver button.
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.
Select the frontLeftFootCtrl curve, and set its Translate Z channel to −1.
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).
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.
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.
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.
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.
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.
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.
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.
To make the foot cycle you can simply use the Pre- and Post-Infinity settings in the Graph Editor.
Continue with the scene from the previous section or open the mechBugWalk_v02.ma
scene from the chapter5scenes
directory on the DVD.
Select the frontLeftFootCtrl and open the Graph Editor (Window
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.
In the Graph Editor menu, choose View
Select the green Translate Y curve. Choose Curves
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.
Select the blue Translate Z curve and choose Curves
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.
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 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.
Continue with the scene from the previous section or open the mechBug_v03.ma
scene from the chapter5scenes
directory on the DVD.
From the Animation menu set, choose Animate
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.
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.
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.
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).
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.
Shift+click the five other leg control curves. Highlight the Translate Y and Translate Z channels, right-click, and choose Paste Selected.
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.
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
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
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.
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.
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.
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.
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.
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.
Open the mechBugExpressions_v01.ma
scene from the chapter5scenes
directory on the DVD. This scene has an animation of the mechanical bug walking.
Select the yellow circle in front of the bug. This is the antennaCtrl, which controls the rotation of the antenna control group.
In the menu above the Channel Box, select the Rotate Y channel so that it is highlighted. Choose Edit
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.
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.
In the Expression Editor, change the expression to read antennaCtrl.rotateY=30*(sin(time));
. Click the Edit button to change the expression.
Rewind and play the animation. The antennae swing back and forth.
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.
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.
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).
Select one of the yellow locators in the perspective view. In the Channel Box, highlight the Translate Y channel, and choose Edit
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.
Add a similar expression to the Translate Y of the other yellow locator. To make the motion slightly different, try translate=noise(time*5);
.
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.
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.
Continue with the scene from the previous section or open the mechBugExpressions_v02.ma
scene from the chapter5scenes
directory on the DVD.
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.
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.
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.
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.
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.
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.
Open the mechBugPath_v01.ma
scene from the chapter5scenes
directory on the DVD.
Turn on the grid display and choose Create
Draw a curve on the grid using any number of points; make sure the curve has some nice twisty bends in it.
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).
In the Outliner, select the mechanicalBug group and Ctrl+click the curve. From the Animation menu set, choose Animate
In the options, choose Edit
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.
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.
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.
In the Outliner, select the mechanicalBug group. In the Channel Box under Inputs, select motionPath1.
Choose Window
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.
Use the graph-editing tools to edit the curve.
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.
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 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.
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).
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.
In the Outliner, select the bugLanded locator and Ctrl+click the mechanicalBug group. From the Animation menu set, choose Constrain
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.
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.
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.)
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).
Play the animation. You'll see the bug sticking to the cattail as it moves up and down.
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).
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.
In the Outliner, expand the mechanicalBug group. Select the mechanicalBug_parentConstraint1 node.
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.
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 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.
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.
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.
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.
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.
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.
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.
Open the mechBugLayers_v01.ma
scene from the chapter5scenes
directory on the DVD.
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.
Set the current frame to 20, set Translate Y to 0.5, and create another keyframe.
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.
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.
Choose Layers
In the perspective view nothing has changed regardless of which layer is selected.
Double-click on AnimLayer1 and rename it bounce (see Figure 5.64).
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.
Select the bounce layer, and a green circle appears on the right. This indicates that the layer is active.
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
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.
In the Layer Editor, select the bounce layer. Choose (from the menu in the Layer Editor) Layers
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.
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.
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).
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.
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
With the bodyCtrl curve selected, open the Graph Editor and select the Translate Y channel. Drag a selection around the keys, and choose Curves
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
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).
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.
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.
Select the rock layer. In the Channel Box, highlight the Rotate X, Y, and Z channels, and set a keyframe on these channels.
Turn on the Auto Keyframe feature by clicking the key icon to the right of the timeline.
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.
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.
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.
The Layer Editor includes other options as well. These are:
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.
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).
This button disables animation on the selected 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.
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.
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.
Continue with the scene from the previous section or open the mechBugLayer_v02.ma
scene from the chapter5scenes
folder on the DVD.
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.
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.
Name the new layer bounce1, and rename bounce as bounce2.
Make sure bounce1 is below bounce2. Mute all the layers (see Figure 5.68).
In the Layer Editor choose Layers
Select the circle under the front left leg. In the Layer Editor, choose Layers
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).
Repeat steps 7 and 8 for the front right leg circle. Name the new layer FRightLegAnim.
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).
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.
Switch to the FRightLegAnim layer, and create a similar animation for the front right leg.
When you have a nice animation going for both layers, unmute the other layers and play the animation.
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.
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.
You can merge the animation of two layers into a single animation layer.
Continue with the scene from the previous section or open the mechBugLayers_v03.ma
scene from the chapter5scenes
folder on the DVD.
In the Animation Layers Editor, select the bounce2 and bounce1 layers.
Choose Layers
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.
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).
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.
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.
Create a simple joint chain for a robot's arm. Use the joint chain to animate an arm made from simple polygon surfaces.
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.
Create an Inverse Kinematic control for a simple arm.
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.
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.
More sophisticated animation editing is available using the animation curve editing tools on the Graph Editor.
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.
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.
Create a playblast of the mechBugLayers_v04.ma
scene.
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.
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.
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.
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.
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.
Make the bug walk along a motion path. See if you can automate a walk cycle based on the position along the path.
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.
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.