Chapter 32: Animating with Constraints and Controllers


When you first begin animating and working with keys, having Max figure out all the frames between the start and end keys seems amazing, especially if you've ever animated in 2D by drawing every frame. But soon you realize that animating with keys can be time-consuming for complex realistic motions, and again, Max comes to the rescue. You can use animation constraints and controllers to automate the creation of keys for certain types of motions.

Constraints and controllers store and manage the key values for all animations in Max. When you animate an object using the Auto Key button, the default controller is automatically assigned. You can change the assigned controller or alter its parameters using the Motion panel or the Track View.

This chapter explains how to work with constraints and controllers and examines all the various types that are available. For example, you can use the Noise controller to add random motion to a flag blowing in the wind, the Surface constraint to keep a bumper car moving over the surface, or the Waveform controller to produce regular repeating motions such as a sine or square wave.

Restricting Movement with Constraints

The trick of animating an object is to make it go where you want it to go. Animating objects deals not only with controlling the motion of the object, but also with controlling its lack of motion. Constraints are a type of animation controller that you can use to restrict the motion of an object.

Using these constraints, you can force objects to stay attached to another object or follow a path. For example, the Attachment constraint can be used to make a robot's feet stay connected to a ground plane as it moves. The purpose of these constraints is to make animating your objects easier.

Using constraints

You can apply constraints to selected objects using the Animation image from book Constraints menu. The constraints contained within this menu include Attachment, Surface, Path, Position, Link, LookAt, and Orientation.

image from book All constraints have the same controller icon displayed in the Motion panel or the Track View.

After you select one of the constraints from the Animation image from book Constraints menu, a dotted link line extends from the current selected object to the mouse cursor. You can select a target object in any of the viewports to apply the constraint. The cursor changes to a plus sign when it is over a target object that can be selected. Selecting a constraint from the Constraints menu also opens the Motion panel, where the settings of the constraint can be modified.

image from book You can also apply constraints using the Assign Controller button found in the Motion panel and in the Track View window.

CROSS-REF 

Find out more about the Track View window in Chapter 33, "Working with Function Curves in the Track View."

Working with the constraints

Each constraint is slightly different, but learning how to use these constraints will help you control the animated objects within a scene. You can apply several constraints to a single object. All constraints that are applied to an object are displayed in a list found in the Motion panel. From this list, you can select which constraint to make active and which to delete. You can also cut and paste constraints between objects.

Attachment constraint

The Attachment constraint determines an object's position by attaching it to the face of another object. This constraint lets you attach an object to the surface of another object. For example, you could animate the launch of a rocket ship with booster rockets that are attached with the Attachment constraint. The booster rockets would move along with the ship until the time when they are jettisoned.

The pivot point of the object that the constraint is applied to is attached to the target object. At the top of the Attachment Parameters rollout is a Pick Object button for selecting the target object to attach to. You can use this button to change the target object or to select the target object if the Animation image from book Constraints menu wasn't used. There is also an option to align the object to the surface. The Update section enables you to manually or automatically update the attachment values.

Note 

The Attachment constraint shows up in the Position track of the Assign Controller rollout as the Position List controller. To minimize the effect of other controllers, set their Weight values in the Position List rollout to 0.

The Key Info section of the Attachment Parameters rollout displays the key number and lets you move between the various keys. The Time value is the current key value. In the Face field, you can specify the exact number of the face to attach to. To set this face, click the Set Position button and drag over the target object. The A and B values represent Barycentric coordinates for defining how the object lies on the face. You can change these coordinate values by entering values or by dragging the red crosshairs in the box below the A and B values. The easiest way to position an object is to use the Set Position button to place the object and then to enhance its position with the A and B values. The Set Position button stays active until you click it again.

The TCB section sets the Tension, Continuity, and Bias values for the constraint. You can also set the Ease To and Ease From values.

Tutorial: Attaching eyes to a melting snowman

Chapter 31, "Using Animation Modifiers and Wiring Parameters," included an example of a snowman that melted using the Melt modifier. The problem with this example was that the Melt modifier was applied to the entire snowman model, including the solid objects such as the eyes of coal and the carrot nose. If the Melt modifier weren't applied to these items, they would stay floating in the air while the rest of the snowman melted about them. This problem can be fixed with the Attachment constraint, which causes the eyes to remain attached to the snowball as it melts.

To constrain the solid objects to a melting snowman, follow these steps:

  1. Open the image from book Melting snowman.max file from the Chap 32 directory on the DVD.

    This file includes the melting snowman file from the previous chapter with the Melt modifier applied to all objects.

  2. Select the left eye object in the scene. In the Modifier Stack, select the Melt modifier and click the Remove Modifier button to throw that modifier away.

  3. With the left eye still selected, select Animation image from book Constraints image from book Attachment Constraint. A connecting line appears in the active viewport. Click the top snowball to select it as the attachment object. This moves the eye object to the top of the snowball where the snowball's first face is located.

  4. In the Attachment Parameters rollout, change the Face value until the eye is positioned where it should be. This should be around face 315. Then change the A and B values (or drag in the Position graph) to position the eye where it looks good.

  5. Repeat Step 5 for the right eye and for any other objects in the scene that you want to attach.

  6. Click the Play button (/), and notice that the snow melts, but the eye objects stay the same size.

Figure 32.1 shows the resulting melted snowman.

image from book
Figure 32.1: The Attachment constraint sticks one object to the surface of another.

Surface constraint

The Surface constraint moves an object so that it is on the surface of another object. The object with Surface constraint applied to it is positioned so that its pivot point is on the surface of the target object. You can use this constraint only on certain objects, including Spheres, Cones, Cylinders, Toruses, Quad Patches, Loft objects, and NURBS objects.

In the Surface Controller Parameters rollout is the name of the target object that was selected after the menu command. The Pick Surface button enables you to select a different surface to attach to. You can also select specific U and V Position values. Alignment options include No Alignment, Align to U, Align to V, and a Flip toggle.

Note 

Don't be confused because the rollout is named Surface Controller Parameters instead of Surface Constraint Parameters. The developers at Autodesk must have missed this one.

Tutorial: Rolling a tire down a hill with the Surface constraint

Moving a vehicle across a landscape can be a difficult procedure if you need to place every rotation and position key, but with the Surface constraint, it becomes easy. In this tutorial, we use the Surface constraint to roll a tire down a hill.

To roll a tire down a hill with the Surface constraint, follow these steps:

  1. Open the image from book Tire rolling on a hill.max file from the Chap 32 directory on the DVD.

    This file includes a patch grid hill and a wheel object made from primitives.

  2. Create a dummy object from the Helpers category, and link the tire object to it as a child. This causes the tire to move along with the dummy object. Position the dummy object's pivot point at the bottom of the tire and the top of the hill.

  3. Select the dummy object, choose Animation image from book Constraints image from book Surface Constraint, and select the hill object.

  4. In the Surface Controller Parameters rollout, select the Align to V and Flip options to position the dummy and tire objects at the top of the hill. Set the V Position value to 50 to move the tire down the hill.

  5. Click the Auto Key button (or press the N key), drag the Time Slider to frame 100, and change the U Position to 100. Click the Animate button again to deactivate it, and click the Play Animation button to see the tire move down the hill.

Figure 32.2 shows the tire as it moves down the hill. In the Top view, you can see the function curves for this motion.

image from book
Figure 32.2: The Surface constraint can animate one object moving across the surface of another.

Path constraint

The Path constraint lets you select a spline path for the object to follow. The object is locked to the path and follows it even if the spline is changed. This is one of the most useful constraints because you can control the exact motion of an object using a spline. With Max's spline features, you can control very precisely the motions of objects that are constrained with the Path constraint. A good example of this constraint is an animated train following a track. Using a spline to create the train tracks, you can easily animate the train using the Path constraint.

When you choose the Animation image from book Constraints image from book Path Constraint menu command, you can select a single path for the object to follow. This path is added to a list of paths in the Path Parameters rollout.

The Path Parameters rollout also includes Add and Delete Path buttons for adding and deleting paths to and from the list. If two paths are added to the list, then the object follows the position centered between these two paths. By adjusting the Weight value for each path, you can make the object favor a specific path.

The Path Options include a % Along Path value for defining the object's position along the path. This value ranges from 0 at one end to 100 at the other end. The Follow option causes the object to be aligned with the path as it moves, and the Bank option causes the object to rotate to simulate a banking motion.

The Bank Amount value sets the depth of the bank, and the Smoothness value determines how smooth the bank is. The Allow Upside Down option lets the object spin completely about the axis, and the Constant Velocity option keeps the speed regular. The Loop option returns the object to its original position for the last frame of the animation setting up a looping animation sequence. The Relative option lets the object maintain its current position and does not move the object to the start of the path. From its original position, it follows the path from its relative position. At the bottom of the Path Parameters rollout, you can select the axis to use.

Tutorial: Creating a spaceship flight path

Another way to use splines is to create animation paths. As an example, we use a Line spline to create an animation path. You can use splines for animation paths in two ways. One way is to create a spline and have an object follow it using either the Path constraint or the Path Follow Space Warp. The other way is to animate an object and then edit the Trajectory path.

In this tutorial, we use a simple path and attach it to a spaceship model. Viewpoint Datalabs provided the spaceship model.

To attach an object to a spline path, follow these steps:

  1. Open the image from book Spaceship and asteroids.max file from the Chap 32 directory on the DVD.

    This file contains the spaceship model and several asteroid objects.

  2. Select Create image from book Shapes image from book Line, and click and drag in the Top viewport to create an animation path that moves the spaceship through the asteroids. Right-click when the path is complete. Then select the Modify panel, click the Vertex button in the Selection rollout to enable Vertex subobject mode, and edit several vertices in the Front viewport.

  3. With the spaceship selected, choose Animation image from book Constraints image from book Path Constraint. Then click the animation path to select it as the path to follow. Select the Follow option in the Path Parameters rollout, and choose the Y-Axis option.

  4. Click the Play Animation button in the Time Controls to see the spaceship follow the path.

Figure 32.3 shows the spaceship as it moves between the asteroids.

image from book
Figure 32.3: The spaceship object has been attached to a spline path that it follows.

Position constraint

You can use the Position constraint to tie the position of an object to the weighted position of several target objects. For example, you could animate a formation of fighter jets by animating one of the jets and using Position constraints on all adjacent jets.

The Position constraint menu option lets you select a single target object, enabling you to place the pivot points of the two objects on top of one another. To add another target object, click the Add Position Target button in the Position Constraint rollout in the Motion panel. This button enables you to select another target object in the viewports; the target name appears within the target list in the rollout.

If you select a target name in the target list, you can assign a weight to the target. The constrained object is positioned close to the object with the higher weighted value. The Weight value provides a way to center objects between several other objects. The Keep Initial Offset option lets the object stay in its current location, but centers it relative to this position.

Figure 32.4 shows a sled positioned between four tree objects using the Position constraint. Notice how the weight of the downhill tree object is weighted higher than the other targets, and the sled is close to it.

image from book
Figure 32.4: You can use the Position constraint to control the position of an object in relation to its targets.

Link constraint

The Link constraint can transfer hierarchical links between objects. This constraint can cause a child's link to be switched during an animation. Anytime you animate a complex model with a dummy object, the Link constraint makes it possible to switch control from one dummy object to another during the animation sequence. This keeps the motions of the dummy objects simple.

The Link Params rollout includes Add Link and Delete Link buttons, a list of linked objects, and the Start Time field. To switch the link of an object, enter for the Start Time the frame where you want the link to switch, or drag the Time Slider and click the Add Link button. Then select the new parent object. The Delete key becomes active when you select a link in the list.

Note 

If you create a link using the Link constraint, the object is not recognized as a child in any hierarchies.

All links are kept in a list in the Link Params rollout. You can add links to this list with the Add Link button, create a link to the world with the Link to World button or delete links with the Delete Link button. The Start Time field specifies when the selected object takes control of the link. The object listed in the list is the parent object, so the Start Time setting determines when each parent object takes control.

The Key Mode section lets you choose a No Key option. This option does not write any keyframes for the object. If you want to set keys, you can choose the Key Nodes options and set keys for the object itself (Child option) or for the entire hierarchy (Parent option). The Key Entire Hierarchy sets keys for the object and its parents (Child option) or for the object and its targets and their hierarchies (Parent option).

This constraint also includes the PRS Parameters and Key Info rollouts.

Caution 

You cannot use Link constraints with Inverse Kinematics systems.

Tutorial: Skating a figure eight

For an animated object to switch its link from one parent to another halfway through an animation, you need to use the Link constraint. Rotating an object about a static point is easy enough: Simply link the object to a dummy object, and rotate the dummy object. The figure-eight motion is more complex, but you can do it with the Link constraint.

To move an object in a figure eight, follow these steps:

  1. Open the image from book Figure skater skating a figure eight.max file from the Chap 32 directory on the DVD.

    This file includes a figure skater model imported from Poser and two dummy objects. The figure skater is linked to the first dummy object.

  2. Click the Auto Key button (or press the N key), drag the Time Slider to frame 100, and rotate the first dummy object two full revolutions in the Top viewport.

  3. Select the second dummy object, and rotate it two full revolutions in the opposite direction. Click the Auto Key button again to deactivate it.

  4. With the figure skater selected, choose Animation image from book Constraints image from book Link Constraint. Then click the first dummy object (the top one in the Top viewport).

    The Link constraint is assigned to the figure skater.

  5. In the Link Params rollout, click the Add Link button. With the first dummy object selected in the viewport, set the Start Time value to 0. Then click the second dummy object, and set the Start Time to 25. Finally, click the first dummy object again, and set the Start Time to 75.

  6. Click the Play Animation button (or press the / key) to see the animation play.

Tip 

Another way to accomplish this same motion is to create a spline of a figure eight and use the Path constraint

Figure 32.5 shows the skater as she makes her path around the two dummy objects.

image from book
Figure 32.5: With the Link constraint, the figure skater can move in a figure eight by rotating about two dummy objects.

LookAt constraint

The LookAt constraint won't move an object, but it rotates the object so it is always orientated toward the target object. For example, you could use the LookAt constraint to animate a character's head that is watching a flying bumblebee. It is also very useful to apply to camera objects that follow a specific object throughout the animation.

After you select a target object, a single line extends from the object and points at the target object. This line, called the Viewline, is visible only within the viewports.

The LookAt Constraint rollout, like many of the other constraints, includes a list of targets. With the Add and Delete LookAt Target buttons, you can add and remove targets from the list. If several targets are on the list, the object is centered on a location between them. Using the Weight value, you can cause the various targets to have more of an influence over the orientation of the object. The Keep Initial Offset option prevents the object from reorienting itself when the constraint is applied. Any movement is relative to its original position.

You can set the Viewline length, which is the distance that the Viewline extends from the object. The Viewline Length Absolute option draws the Viewline from the object to its target, ignoring the length value.

The Set Orientation button lets you change the offset orientation of the object using the Select and Rotation button on the main toolbar. If you get lost, the Reset Orientation button returns the orientation to its original position. You can select which local axis points at the target object.

The Upnode is an object that defines the up direction. If the LookAt axis ever lines up with the Upnode axis, then the object flips upside-down. To prevent this, you can select which local axis is used as the LookAt axis and which axis points at the Upnode. The World is the default Upnode object, but you can select any object as the Upnode object by deselecting the World object and clicking the button to its right.

To control the Upnode, you can select the LookAt option or the Axis Alignment option, which enables the Align to Upnode Axis option. Using this option, you can specify which axis points toward the Upnode.

Caution 

The object using the LookAt constraint flips when the target point is positioned directly above or below the object's pivot point.

When you assign the LookAt constraint, the Create Key button for rotation changes to Roll. This is because the camera is locked to point at the assigned object and cannot rotate; rather, it can only roll about the axis.

You can use the LookAt constraint to let cameras follow objects as they move around a scene. It is the default transform controller for Target camera objects.

Orientation constraint

You can use the Orientation constraint to lock the rotation of an object to another object. You can move and scale the objects independently, but the constrained object rotates along with the target object. A good example of an animation that uses this type of constraint is a satellite that orbits the Earth. You can offset the satellite and still constrain it to the Earth's surface. Then, as the Earth moves, the satellite follows.

In the Orientation Constraint rollout, you can select several orientation targets and weight them in the same manner as with the Position constraint. The target with the greatest weight value has the most influence over the object's orientation. You can also constrain an object to the World object. The Keep Initial Offset option maintains the object's original orientation and rotates it relative to this original orientation. The Transform Rule setting determines whether the object rotates using the Local or World Coordinate Systems.




3ds Max 9 Bible
3ds Max 9 Bible
ISBN: 0470100893
EAN: 2147483647
Year: 2007
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net