The biped crowd is a special case of crowd simulation necessitated by the complex nature of legged animal movement. Biped locomotion exhibits intricate dynamics and exacting IK foot constraints. As such, the smoothly curving trajectories computed from delegate motion parameters, while suitable for birds, fish, insects, and snakes, are not rich enough to animate the microstructure of bipedal motion. Therefore, several features in Crowd are focused on the special needs of bipeds.
In order to generate the required level of nuance, animated motion clips form the basis for the repertoire of biped movements. In other words, during a Biped/Crowd simulation, the delegates have no effect over the motion of the Biped, they only set goals to be achieved using clips available in the Motion Flow graph. With this approach, known as motion synthesis, the animator can precisely control details in the motion either by using hand animation or employing motion capture to produce a set of clips that describe how a member in the crowd behaves.
For example, if you wanted to animate a crowd of marathon runners making their way through the streets of a city, you would need motion clips for various kinds of walking, running, jogging, resting, drinking water, cheering, etc. In effect, each of the motions you might expect to see in a marathon race could be represented as a clip. But motion must be more than a fragmented collection of clips. You must also consider how motions might be sequenced. Which motion transitions are possible from a given motion clip?
To best understand this process, study this topic and follow the procedure Using bipeds in a crowd simulation.
Motion Flow Network and Possible Scripts
Biped's Motion Flow functionality provides the mechanism for defining how separate motions fit together into a fluid animation. In effect, the motion flow network describes which motions can follow from other motions. Once the motion flow network is defined, a broad set of animated actions is possible by following different paths through the network. In Biped, a path through the network is called a motion flow script.
For example, shown below is a motion flow network used in the sample file walkers.max. You can find this file in the cstudio\tutorials\biped_crowds folder in your 3ds Max path. This folder also contains the BIP files used in the motion flow network. You can access these files only if you have installed tutorials on your hard disk. For information on installing tutorials, see the Installation Guide.
This is a fairly simple network of possible motions, because the characters can only start, stop, turn at 90 degree angles left and right (walk_L90 and walk_R90), and do an about-face (walk_180). However, for more natural crowd interaction, it's advisable to expand the motion flow network to include shorter, more finely tuned variations such as turning at 45 degree increments, moving in different directions while facing the same way, loitering motions, and moving at different speeds. The Biped Motion Library has a comprehensive list of clips for you to experiment with.
Motion flow graphs that work best incorporate fine-tuned transitions. A good way to check your motion-flow transitions is by building test scripts as you build the graph: Add clips to the graph, add the necessary transitions, and optimize the transitions. Optimizing transitions works well as a starting point and, more often than not, produces the smoothest transitions. Next, make a new script that uses your transitions, and use the script to tweak the motion flow until the feet don't slide.
The Shared Motion Flow Networks feature lets many bipeds use a single motion-flow network. Therefore, it’s practical to make motion-flow networks large without taxing your computer's memory.
Delegate-Directed Behavioral Goals
You can give a biped a behavioral goal by associating it with a delegate in the Crowd system, and then assigning behaviors to the delegate.
For example, in the walkers.max sample, the behavioral goals of each of the biped's delegates are to:
During a biped crowd simulation, character studio attempts to compute the best motion flow script for each biped member of the crowd that satisfies the behavioral goals of its associated delegate. In other words:
So in the walkers.max sample, the simulation will always choose the best available walking clip in the network that directs the biped's delegate toward the sphere. Each biped's script evolves as the crowd "Solve" computes. This is somewhat like a real-time "game engine" in that the crowd solver’s choice of the next best clip for a given biped is restricted by that biped's currently active clip.
Biped Crowd Avoidance, Priority, and Backtracking
Because bipeds in crowds are always following motion flow scripts, the avoidance behavior for bipeds works differently. Unlike ordinary delegates, biped delegates can move only along motion flow-scripted paths, so if a collision takes place, character studio will backtrack to the previous clip in the current script and find another path. This may take some time to compute when complex crowd interactions are present since a single backtrack may not be enough. The computation will explore all paths from a given backtracking clip, and if that fails, it will backtrack to the previous clip, and so on, until a solution is found.
In the example, if the current script of a biped is:
walk_start walk walk_L90
and a collision is encountered during the walk_L90 clip, the biped will backtrack to the end of the walk clip and attempt to try a different clip in place of the failed left turn. If that fails, it will try the next best choice, and so on.
In order to make the backtracking computationally manageable, the biped crowd members are computed one at a time, in order of priority. Thus, the crowd interaction is accumulated with each successive biped added to the animation. In other words, each waits its turn to compute its complete animation, which entails avoiding the bipeds that have been computed before it. It follows that bipeds with the lowest priorities generally encounter the most collisions, since they must steer around all the bipeds that have higher priorities.
Preparing Characters for a Biped Crowd
To create a biped crowd simulation, you will need several bipeds. Because the crowd simulation factors in each biped's leg length when applying clips to the biped, your simulation will be more accurate if your bipeds are the correct size from the start.
One straightforward workflow would be:
This setup makes it easy to merge the characters into the crowd scene. When characters are merged, the meshes themselves will be hidden, which will improve system performance.
Preparing Motions for a Biped Crowd
The clips you use for a biped crowd simulation can be loaded from the samples included with 3ds Max, imported from motion capture files, or created from scratch.
The integrity of transitions between clips in the motion flow network is very important when creating a biped crowd simulation. When creating transitions for a single biped, it's a simple matter to correct individual transitions after the motion flow script has been created. With a crowd, having to correct transitions for each biped after the simulation is complete would be extremely time-consuming. It is much more efficient to ensure your transitions are correct before starting to solve the simulation.
One way to make this process easier is to set up all motions so each has an ideal transition of exactly the same number of frames, such as 10 or 15. Then you can optimize transitions for this length, and all or most transitions will work flawlessly.
To check transitions, create a simple script for one biped using several transitions in the graph. Check the motion and work with transitions individually until they look right. You might not catch all bad transitions with this method, but you'll catch most of them. A “bad” transition would be one where the feet skip or hop when they should be walking, or any other undesirable change that occurs during a transition. See Customizing Transitions.
After solving the biped crowd simulation the first few times, check again for bad transitions you might have missed the first time around. After a few simulations, most likely you will have found all or nearly all the bad transitions.
Some features of the crowd system are not designed to work with biped crowds. These behaviors and parameters have no effect on the crowd's movements when bipeds are used with the simulation.
Procedures: Using Bipeds in a Crowd Simulation
The following sequence of procedures gives the basic steps for creating and saving a motion flow graph, assigning several bipeds to delegates, and then sharing the motion flow graph among the bipeds so that character studio automatically creates separate motion flow scripts for each biped, based on the behaviors assigned to its delegate.
The first step is to create an appropriate motion flow graph and save it to disk.
To create the shared motion flow:
This displays an Open dialog that lets you select any number of BIP files from the same directory to add simultaneously to the motion flow graph. Use Click+Shift+click (click, and then Shift+click) to choose several contiguous files, and Ctrl+click to choose non-contiguous files.
The files are added to the graph as clips. Each clip is automatically named after the file from which it's derived.
The next step is to add transitions among the clips so character studio knows which actions can proceed to and from other actions. You can do this manually for greater control, but for initial testing, you can save time by letting character studio add and optimize transitions automatically.
The graph now shows arrows to and from each clip, as well as from each clip to itself. If you like, delete transitions that obviously don't belong, such as the ones from the stop and start clips to themselves.
Alternatively, you can use (Create Transition) to set up a custom graph.
When you solve the simulation, Crowd automatically generates a motion flow script for the biped, based on this graph. When you have a graph with multiple clips, as in this case, it chooses the starting clip for the script from one or more clips you designate as random start clips.
If you want to check the integrity of transitions before continuing, do so now. See Customizing Transitions.
This tells character studio to start the script with this clip, and uses the default probability of 100 percent that the clip will be chosen.
If you want the various bipeds to start with different clips, select multiple random start clips by pressing and holding the Ctrl key as you click. The default Random Start Probability setting of 100 for all clips means that character studio will choose randomly among them for a starting clip for each biped's script.
To change the likelihood of starting with specific clips, right-click a clip and modify its Random Start Probability setting. For example, say you want to start each biped's script with any of three clips: clips A, B, and C. You want clip A to be chosen twice as often as clip B or C. In that case, using the Random Start Clips tool, you'd first click clip A, and then Ctrl+click clips B and C. Then you'd right-click each in turn, assigning a Random Start Probability of 60 to clip A, and 30 to both clips B and C.
The next step in using bipeds in a crowd simulation is to create the simulation.
To set up the crowd simulation:
You must select the biped's center of mass (COM) object (typically named Bip0#), as indicated by the mouse cursor turning into a crosshairs icon when it's over the COM in the active viewport.
To apply the shared motion flow:
Next, you use the Shared Motion Flow function to apply the saved motion flow graph to the bipeds.
This creates a new shared motion flow and assigns it a default name. You can change the name if you like.
For your convenience, the Select dialog shows only center of mass objects for the bipeds in the scene.
After you click the Select button, the bipeds appear in the dialog, in the list under "Bipeds Sharing this Motion Flow."
One more step in the Shared Motion Flow dialog is necessary: You must activate Motion Flow mode for all the bipeds sharing the motion flow. A special button in the dialog lets you perform that action in one step.
This activates Motion Flow mode for all the bipeds sharing the motion flow.
To offset the delegates and test the simulation:
Delegate-controlled bipeds can begin their animation with their motion flow scripts' first clip, if it exists, or with a random motion clip. But when you load a motion flow file into the Shared Motion Flow dialog, any scripts in the file are ignored. Thus, delegate-associated bipeds using motion flow in an unsolved crowd simulation have no existing scripts, and you must specify that they use the random start clip that you set in the motion flow. You do this via the delegates.
Chances are good that adjustments will be required. You can resolve problems in a number of different ways: Change the behavior and/or motion flow setups, change delegate parameters, and so on.
If you find that bipeds are colliding and interpenetrating, you can take advantage of Crowd's special Priorities and Backtracking features. In fact, it is strongly recommended that you use both options for most Crowd/Biped simulations.
Now, when it solves the simulation, Crowd solves for one biped/delegate at a time, starting with the lowest-priority biped/delegate. As it solves for each subsequent biped/delegate, it looks for collisions, and when the occur, it backs up the solution to the end of the previous clip, and if necessary, previous clips, and then tries different paths through the motion flow graph. This method can take longer, which is why Backtracking is off by default, but it's often the best way to resolve problems with colliding bipeds.