Using Crowd with Animated Non-Biped Objects
 
 
 

The 3ds Max Crowd animation system has a number of special features designed for applying behaviors to non-biped objects. In this lesson, you'll learn how to create a flock of birds that automatically flap their wings when they fly upward, and glide without flapping when they fly horizontally or downward. You'll use the Crowd system's non-bipedal motion synthesis methods to achieve this.

You'll animate several delegates and link them with clones of an animated global object. Next, you'll use clip controllers to define clips from the global object's animation. You'll define states to specify which animation clip the clones should use, depending on their parent delegates' speed, acceleration, pitch, and so on. Crowd will blend the clips and synthesize an animation based on the clip and state information.

This scene uses a vector field, which is a special type of 3ds Max space warp that enables crowd members to move around complex objects.

Set up the lesson:

Examine the vector field:

The vector field is already set up, so you needn't make any changes to it, but it's useful to take a quick look at it to see how it works.

  1. Select the vector field object.

    The vector field object is the gizmo shaped like two double-headed arrows in an X formation, near the C-shaped object. It's probably easiest to use the Top viewport to select this.

  2. Go to the Modify panel. In the Obstacle Parameters rollout > Display group, turn on Show Lattice.

    The lattice is a yellow, box-shaped, three-dimensional grid surrounding the obstacle object. Its settings determine the location, resolution, and maximum volume of the vector field. This field uses a high-resolution grid, so the display in the Perspective viewport is almost solid yellow, but you can see the grid clearly in the orthogonal viewports.

  3. Turn off Show Lattice, and turn on Show Range.

    The range is typically an expanded version of the obstacle object, and is used by the vector field to calculate vectors within the lattice.

  4. Turn off Show Range, and turn on Show Vector Field.

    The blue lines represent forces used by the Vector Field space warp to guide delegates through this volume. As you can see, their spacing is determined by the lattice resolution, and the overall shape of the field is determined by the range volume.

  5. Turn off Show Vector Field.

Assign behaviors:

  1. Select the Crowd object. On the Modify panel > Setup rollout, add a Space Warp behavior.
  2. On the Space Warp Behavior rollout, click the None button and select the vector field object.

    Now, any delegates using the Space Warp behavior will use the vector field to guide their motion.

  3. Add an Avoid behavior.
  4. On the Avoid Behavior rollout, click the Multiple Selection button.
  5. In the Select dialog, select all of the delegates and click Select.

    This instructs the delegates to avoid each other.

  6. Open the Behavior Assignments dialog.

    The delegates have already been grouped into a team (Team0).

  7. Assign both behaviors to the team and close the dialog.
  8. On the Solve rollout, click the Solve button.

    You can stop the simulation at any time by pressing ESC. As Crowd solves the simulation, the delegates move around the obstacle object, roughly following its contours while remaining at their starting height. Some might fly away, which you'll remedy in the next procedure.

    To allow the delegates to fly up and down, you turn off the switch that constrains the delegates to the XY plane.

Modify the delegates:

  1. On the Setup rollout, click Multiple Delegate Editing.

    The delegates have already been added to the Delegates To Edit list. You don't need to highlight them.

  2. In the General group, turn off Constrain To XY Plane.
  3. Turn on SET for Constrain To XY Plane.

    You can also vary the delegates' speeds.

  4. In the Speed group, to the right of Average Speed, turn on both Random and SET.

    Turning on Random gives you access to both Average Speed settings.

  5. Change the first Average Speed setting to 3.0.

    Crowd will use random values between 3 and 5 units per frame for the delegates' speeds.

  6. Click the Apply Edit button to close the dialog and apply your changes to all specified delegates.
  7. Solve the simulation again. This time, be sure to let it finish.

    The delegates move in three dimensions, soaring and then descending.

    If any of the delegates still fly away, try changing its starting position, or if you want to keep the V formation, move all of them together.

Reveal the eagle:

You'll assign an animated bird object to each delegate.

  1. Right-click in the active viewport, and from the Display quadrant of the right-click menu, choose Unhide All.

    Only the Eagle object was hidden. If you haven't changed the Perspective view, you'll see it in that viewport. If you have, and the Eagle object is not visible, use SHIFT+Z to undo viewport changes.

  2. Select the Eagle object and drag the time slider to see its animation.

    The bird flaps its wings from frames 0 to 186 and then remains still. The last key frame is 288.

    The bird is animated in place, so you can combine the delegates' motion with the bird's animation to create a convincing animation.

    There are quite a few interim keyframes, even while the bird doesn't move, because Motion Clips uses interim frames to blend animation clips when it synthesizes an object's animation.

Assign animated objects to delegates:

  1. Select the Crowd object and click Scatter to open the Scatter Object dialog.
  2. Specify Eagle as the object to clone

    How Many is already set to 5.

  3. Turn off Clone Controllers so the eagle's animation won't be replicated in the clones.

    If you don't do this, the existing animation mixes with the synthesized new keyframes, which can create confusing and erroneous results.

  4. Click Generate Clones, and then click OK to exit the dialog.
  5. Drag the time slider to see the non-animated clones superimposed over the original, animated eagle.

    Next, you'll link the delegates with the eagle clones, repositioning the clones at the same time.

  6. Click Objects/Delegate Associations to open its dialog.

  7. Click the Add button under the Objects list and select the five eagle clones: Eagle01 through Eagle05.
  8. Click the Add button under the Delegates list and select the five delegates.

    The two lists appear in alphabetical order, indicating the order in which each delegate and eagle mesh are to be paired. You can change the order by highlighting list items and clicking the up and down arrows in between the two lists. In this case, it's not necessary.

  9. Click Align Objects With Delegates.

    This moves each object to its respective delegate's position, and reorients the object as necessary to align its local axis with that of the delegate. In the viewports, the eagle clones line up with the delegates. But they're not linked yet.

  10. Click the Link Objects To Delegates button, and then click OK to close the dialog.

    This creates a parent-child hierarchy for each pair, with the delegate as the parent in each pair.

  11. Drag the time slider to observe the eagle clones moving with the delegates.

    The eagle clones remain in their initial, wings-raised animation position as they move.

Use Clip Controllers:

You'll use Clip Controllers to apply the correct animation clips from the original eagle object to the clones. Three clip controller types are available:

  1. With the Crowd object selected, scroll down to the Global Clip Controllers rollout at the bottom of the Modify panel.
  2. Click New and select the Eagle object.

    This specifies the Eagle as the Global Object, from which the eagle clones' animation will be derived.

  3. In the Global Clip Controllers list, click the Eagle entry, then click the Edit button to open the Eagle dialog.

    The dialog's three tabbed panels let you set up the clip controllers in a logical workflow.

  4. Look at the five check boxes In the Motion Clips panel > From Global Object group. Make sure they are all turned off.

    These controls are useful only when you've animated the global object's position and rotation and want to incorporate this animation in the resulting states.

  5. In the same group, click New to add a new clip.

    The MotionClip Parameters dialog opens with the default clip name Motion Clip.

    The MotionClip Parameters dialog defines animation clips from the global object. The current end frame is automatically set to the last key in the global object's animation.

  6. Change the name to Flap, and set End to 186, the last frame of the flapping motion. Click OK.
  7. Create a second clip called Glide, and set it to use frames 187 through 288. Click OK.

    The clips use different colors so you can distinguish them in Track View.

Define states:

You'll define two states to specify how a delegate moves at any point in time. You can specify values or value ranges for one or more of these motion categories: speed, acceleration, pitch, pitch velocity, and heading velocity. You can also use MAXScript to define a state. As you define states, you assign clips to them. For example, if your animated object uses different motions for turning sideways or slowing down, you create a state for each one and assign it the appropriate motion clip.

In this procedure, you'll create one state for upward motion that uses the Flap clip, and a second state for downward motion that uses the Glide clip.

  1. Click the State tab, then click New State. Change the name from ClipState to Flap.
  2. Click Add Clip and choose the Flap clip.
  3. Click Edit Properties.

    You'll use this dialog, which has the same name as the state (in this case, “Flap”) to apply the Flap state when the delegate moves upward.

  4. Click the Pitch tab and turn on Use Pitch.

    The Range settings become available. Use these to specify the range of pitches to activate this state.

  5. Set Min to 1.

    The bird will flap its wings whenever its pitch is between 1 through 180 degrees (when it's flying upward).

  6. Click Exit to close the Flap dialog.
  7. Add a second state and call it Glide.
  8. Assign it the Glide motion clip and use Edit Properties to specify that the Glide state is to use a pitch range of -180 to 0. Again, close the dialog by clicking Exit.

    The bird will stop flapping its wings whenever it's flying downward or level. You can also set different flapping rates for different pitches by creating more clips when you set up the global object.

Specify master motion clips:

This is the final part of the motion clip setup procedure. Here you specify the master motion clips, that is, the objects to which the synthesis is to be applied. You also blend the clips and synthesize the animation.

  1. Click the Synthesis tab.
  2. Click the New Master Motion Clip button and select the five eagle clones.

    The Global Object doesn't appear in the Select Object To Copy dialog because you designated it as the object from which the clips are derived.

  3. In the Synthesis Blend Parameters group, click Auto Blend All.

    Auto Blend creates natural-looking transitions between the clips. To see an example of the results of Auto Blend, set From Clip to Glide and To Clip to Flap. The blend from gliding to flapping begins on the 80th frame of the Glide clip.

  4. Click Synthesize All then click OK to close the Eagle dialog.

    This generates the animations for the clones. You don't have to solve the crowd simulation unless you change delegate or behavior settings.

  5. Click Time Configuration and in the Playback group, turn off Real Time. This turns off real-time animation playback. Maximize the Perspective viewport and zoom in.

    Although the birds should flap their wings only when they fly upward, and then stop flapping to glide downward, it isn't quite working that way. The problem is that the clips are too long for their matched states. For instance, a bird might fly upward for only 50 frames, but the animation clip for the Flap state is 187 frames long. You'll need to modify the clips.

    You might wonder why we didn't start with a Global Object whose animation was set up expressly for use with motion synthesis. In a production environment, you might be working with models containing animation originally created for other purposes; in this lesson, we're attempting to simulate such a situation. The Synthesis dialog lets you specify exactly which frame ranges to use when synthesizing motion from a Global Object's animation.

Examine the Block and Slave controllers:

Before you modify the clips, take a look at the "behind the scenes" results of the synthesis process; that is, the creation of block and slave controllers.

  1. From the Graph Editors menu, choose Track View - Dope Sheet.
  2. In the hierarchy pane on the left side, expand Global Tracks, expand Block Control, and then expand Global Motion Clip::Eagle.
  3. Scroll down or expand the Track View window vertically so you can see a few of the Master Motion Clip items.

    In the track hierarchy, the global motion clip from the Eagle object's animation is the parent to the master motion clips for the eagle clones. Each master motion clip is a different sequence of blocks, created during the synthesis process. The Flap and Glide blocks are each a different color.

  4. Expand a Master Motion Clip to see the Flap and Glide slave tracks. Expand a slave track to see its keys.
  5. Close Track View.

Modify the clips:

Examine the Global Object's animation to see how to improve the synthesis.

  1. Click the Eagle object and drag the time slider slowly.

    The wing-flapping animation repeats four times. The clip needs only part of one cycle, though, because the clip controller can blend between the last frame of one cycle and the first of the next. The flap cycle should start with the wings all the way up and end with the wings slightly up.

  2. Move the time slider back to frame 0 and turn on Key Mode Toggle.
  3. Click Next Key repeatedly while watching the eagle object. Stop at frame 48.

    The wing-flapping animation returns to the initial wings-up position at frame 48.

  4. Click Previous Key once.

    The last key before the end of the flap cycle is 42. The Flap clip should go from frame 0 to frame 42.

    The glide cycle is different. Because there's no actual animation, you must make the clip long enough to avoid generating too many keyframes (as the result of repeating a short clip many times to fill the state), while keeping it short enough to fit within the state length.

    For this lesson, you'll set a glide-cycle length of 10 frames. In your own animations, experiment to find a good length for different clips. Even with animation clips, such as the wing-flap cycle, you may need to scale or adjust the animation so the cycle doesn't exceed the shortest length of a state.

    Clip controllers perform spline interpolation over the intersection of each pair of blocks using keys within the blocks. To avoid this interpolation altering the motion within the clip, insert additional keyframes near the ends of the motion. This makes the interpolation occur at the extremes of the clip, rather than over its entire length.

    So, for the glide clip, you'll move some keys immediately inside each endpoint. These keys are of Bend modifiers applied to the wings, and have already been set to use linear interpolation.

  5. With the master eagle still selected, find the key at frame 205 of the track bar (the mini Track View below the viewports).
  6. Drag the key from frame 205 to frame 211.

    It helps to watch the status bar text while you do this.

  7. Drag the next key from frame 228 to frame 212.

    The key icon will overlap the icon of the key at frame 211.

  8. Drag the next key from frame 253 to frame 219.
  9. Drag the next key from frame 270 to frame 220.

    Enlarged view of track bar, showing keys at frames 211, 212, 219, and 220.

    In the above illustration, the track bar has been "zoomed in" for illustrative purposes by shortening the active time segment. You'll see more overlap on your screen.

    Now you have keys at frames 211 and 220 that define the clip ends, and keys immediately inside the ends that can be used for interpolation.

    To change the clip lengths used for synthesis, edit the global clip controller.

  10. In the Crowd Global Clip Controllers rollout, click the Eagle list item, and then click the Edit button.
  11. In the Global Motion Clips group, choose the Flap list item, and then, in the From Global Object group, click Modify.
  12. Set the End parameter to 42, then click OK.
  13. Modify the Glide clip to extend from frame 211 to frame 220.

Redo the synthesis:

  1. On the Synthesis tab, in the Synthesis Blend Parameters group, click Auto Blend All.

    From Clip and To Clip now reflect the changed clip lengths. Also, after the Auto Blend, the Blend Start items change.

  2. Click Synthesize All to apply the new clip lengths to the states.
  3. Close the dialog and play the animation.

Hide the Global Object and the delegates:

At this point you can hide the Eagle object and the delegates. This makes it easier to see the synthesized motion of the eagle clones.

  1. Use Select By Name to select all the delegates and the Eagle object.
  2. Right-click in the active viewport and choose Hide Selection from the right-click menu to hide the delegates and global object.

Summary

In this lesson, you worked with a global object that was animated in place. All transformational animation was supplied by the Crowd system. You can also derive delegate motion from the global object's transformational animation, if it exists.

The Global Object's animation wasn't ideal for the crowd simulation. You learned how to adapt an animation so it works better in a simulation.