Creating Crowds


Crowd systems are composed of two helper objects called Crowd and Delegate, but the system can also use other scene objects that act as objects to avoid or follow.

Using Crowd and Delegate helpers

Crowd and Delegate helper objects are created using the Create image from book Helper image from book Crowd or Delegate menu commands. The Crowd object looks like a simple dummy object and the Delegates are simple pyramids. Objects can be linked to a behavior object that travels along with it.

Several of the tools that you need to define the crowd system are accessed from the Setup rollout, shown in Figure 42.14.

image from book
Figure 42-14: Use the Setup rollout to define the crowd system.

Scattering delegates

image from book If only a single delegate is created, it is not much of a crowd. Multiple delegates can be created using the various cloning methods or using the Scatter button located in the Setup rollout in the Modify panel when the Crowd object is selected.

CROSS-REF 

The various cloning methods are covered in Chapter 9, "Cloning Objects and Creating Object Arrays."

Clicking the Scatter button causes the Scatter Objects dialog box, shown in Figure 42.15, to open. This dialog box includes several panels used to randomize the Position, Rotation, and Scale of the cloned delegates. In the Clone panel, you can select the Object to Clone and How Many clones to create. After the settings are correct, click the Generate Clones button to create the duplicates.

image from book
Figure 42-15: The Scatter Objects dialog box lets you quickly create crowds of objects.

Setting delegate parameters

image from book Each selected delegate has parameters that can be set in the Modify panel including its dimensions, Speed, Acceleration and Turning values. With the Crowd object selected, you can click the Multiple Delegate

Editing button to open a dialog box, shown in Figure 42.16, that lets you change the parameters of multiple delegates simultaneously.

image from book
Figure 42-16: The Edit Multiple Delegates dialog box lets you quickly set the parameters of multiple delegates.

In the upper-left corner, you can select the delegate objects to change using the Add button. You can then specify two values for the parameters. If the Random option is specified, the parameter falls somewhere between the two values. You can also save sets of settings using the drop-down list in the lower-left corner of the interface.

Assigning behaviors

Within the Setup rollout of the Crowd object is a New button that lets you add new behaviors that can be used with the crowd system. All behaviors that are added to the crowd system appear in a drop-down list. By typing a new name in the list, you can name each behavior. The available behaviors include the following:

  • Avoid: Prevents collisions between scene objects and other delegates.

  • Orientation: Controls the direction in which the delegates face.

  • Path Follow: Forces delegates to move only along a designated path.

  • Repel: Forces delegates to move away from a target object.

  • Scripted: Makes a delegate behave using a MAXScript.

  • Seek: Moves delegates toward a target object.

  • Space Warp: Uses a Space Warp object to control behavior.

  • Speed Vary: Changes the speed of delegates as they move about the scene.

  • Surface Arrive: Moves delegates toward a surface.

  • Surface Follow: Moves delegates across a surface.

  • Wall Repel: Uses a grid object to repel delegates.

  • Wall Seek: Uses a grid object to attract delegates.

  • Wander: Makes delegates move randomly.

When a behavior is selected from the Setup rollout, a custom rollout of parameters for the selected behavior appears. Using these parameters, you can govern how the behavior acts and select which objects are targets.

image from book After the behavior's parameters are set, you can assign specific delegates or teams of delegates to use certain behaviors in the Behavior Assignments and Teams dialog box, shown in Figure 42.17. This dialog box is opened using the Behavior Assignment button found in the Setup rollout.

image from book
Figure 42-17: The Behavior Assignments and Teams dialog box lets you organize teams of delegates and assign them to behaviors.

All behavior assignments are listed in the center pane, and each assignment can be given a weight. If the delegate has two conflicting behaviors to follow, then it follows the one with the greatest weight value.

Solving the simulation

The final step in the process is to solve the simulation. This step creates keyframes for all the motion in the scene. To solve the simulation, click the Solve button in the Solve rollout or click the Step Solve button to solve for a single frame at a time. By default, the solution saves keyframes for every frame, but you can increase the Positions and Rotations values to compute the simulation faster.

Tutorial: Rabbits in the forest

This example uses the delegate primitives linked to rabbit meshes to navigate through a forest. Moving several objects through an array of objects can be time consuming when done by hand, but the Crowd system makes it easy.

To move a group of rabbit delegates through an array of trees, follow these steps:

  1. Open the image from book Bunny in the forest.max file from the Chap 42 directory on the DVD. This file includes several pine trees and a bunch of bunnies.

  2. Select the Create image from book Helpers image from book Crowd menu command, and drag in the viewport to create a Crowd object. Make the Crowd object big enough to be easily selected.

  3. Select the Create image from book Helpers image from book Delegate menu command, and drag in the Left viewport to create a Delegate object positioned outside the trees. Orient and link the bunny to the delegate object. Then, shift+drag the delegate to create six total delegate bunnies positioned about the cubes.

  4. Select the crowd object, click the New button in the Setup rollout of the Modify panel, select the Avoid behavior, and name it Avoid trees. In the Avoid Behavior rollout, click the Multiple Selection button. In the Select dialog box that appears, choose all tree objects and click the Select button. Enable the Display Hard Radius button, and then decrease the Hard Radius value to 0.2 so that bunnies can travel through the trees.

  5. Click the New button again. This time, select the Seek behavior and name it Seek hole. In the Seek Behavior rollout, click the None button and choose the red box object that represents the hole.

  6. In the Setup rollout, click the Behavior Assignment button to open the Behavior Assignment and Teams dialog box. Click the New Team button, select all delegate objects, and click the OK button. Then select the Team0 team and the Avoid cubes behavior, and click the center New Assignment button. Select the Team0 team again with the Seek goal behavior, and click the New Assignment button again. Both assignments are listed in the center pane; click the OK button.

  7. In the Solve rollout, click the Solve button.

    The crowd system solves the movement of all delegates as they move toward the goal.

  8. Click the Play Animation button to see the resulting solution.

Figure 42.18 shows the position of the delegates after the simulation has ended. Notice the random position of the various delegates.

image from book
Figure 42-18: The Crowd simulation automatically figures out how to move the delegate bunnies to reach the goal while avoiding the trees.




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