Справка Houdini на русском Crowd simulations

Setting up a crowd simulation

How to set up and edit a crowd simulation.

On this page

Overview

Crowd simulations require a few different node networks to set up. Most of these have shelf tools that set up the networks for you.

  • A render network to render out agent files from a character.

  • A geometry network to load an agent from disk.

  • A geometry network to source agent primitives.

  • A simulation network to run the crowd simulation.

Quick start

It’s possible to use the Simulate shelf tool to get a "demo" crowd simulation quickly in one scene. This is useful for getting a feel for the different networks involved in crowd simulations.

  1. Press ⌃ Ctrl + on the Simulate tool on the Crowds shelf tab. The tool will automatically build agents and a crowd source networks using the mocapbiped1 character built into Houdini.

  2. If you have terrain geometry you want the agents to walk across, select it and click Terrain on the Crowds shelf tab.

Bake out an agent

It’s possible to build a quick simulation that gets agent data directly from a character in the same scene file. But it’s much more efficient to "bake out" the agent data into files and use those for simulation.

See baking an agent for how to write out agent files for a character.

Load an agent

Once you've baked agent files, you can load them into a scene for simulation using an agent setup network.

  1. At the scene level, create a Geometry object for the agent.

  2. Inside the geometry network, create an Agent node.

    • Set Agent name to the name you used when you baked out the agent.

    • If you stored the agent files somewhere other than in an agents folder beside the scene file, set the Cache directory parameter to the path containing the agent files.

  3. If you're going to do terrain adaptation (where Houdini adjusts the agent’s animation so its feet plant properly on the terrain geometry), or look at (where Houdini edits the agent’s neck joint to point its head at something), or other features that require Houdini know which joints represent which body parts, you need to add an Agent Prep node after the Agent node.

    In the Agent Prep parameters, you can associate joints in the character with specific body parts.

  4. Add a Null at the end of the network and give it the display flag. This will serve as a convenient node to reference for the output of the network which doesn’t change even if you add other nodes before it.

    The usual convention is to name this node OUT.

  5. If you're going to do ragdoll simulation of agents, you need to set up collision geometry and joint limits on the agent. See how to set up agents for ragdoll.

Create a crowd source

The agent setup network loads the agent files from disk, representing the "definition" of an agent. To create a crowd, you need a crowd source network that creates a crowd of agent primitives.

  1. On the Crowds shelf tab, click Populate.

  2. Select the agent setup object, then press Enter.

  3. If you have terrain geometry, select it and press Enter, or just press Enter if you don’t have terrain.

    (With no terrain geometry, the node will simply scatter agents across an area defined by parameters on the node).

Create a crowd simulation

The crowd source network generates agent primitives representing the individual agents in the crowd. To make the crowd move and execute behaviors, you need a crowd simulation network.

  1. Select the crowd source object.

  2. On the Crowds shelf tab, click Simulate.

    The tool will build a dynamics network the loads the crowd source and applies a few default behaviors. You can edit the nodes in this network to set up the crowd behaviors you want.

    See dynamics network below for information on the general structure of this network.

Shelf tools

The following tools are on the Crowds tab of the shelf.

Bake Agent

Set up the networks to create an agent and bake out animation clip for the selected character.

Collision Layer

Set up simple collision geometry around an agent character’s skeleton.

Configure Joints

Set up joint rotation limits on an agent character, for use in ragdoll simulation.

Populate

Create a network to scatter agents across the selected geometry, but do not create the simulation network. This may be useful for layout artists who don’t want to create a simulation.

Paint density

Paint density attributes on terrain geometry to control the random distribution of generated agents.

Simulate

Set up geometry and simulation networks with sample animated agents and sample behaviors. This is useful for setting up the networks quickly, and you can then modify them to suit your needs.

Terrain

Set the selected geometry as terrain for the current crowd simulation.

Obstacle

Add the selected geometry as an obstacle for the current crowd simulation.

Path

Create a POP Steer Path node to make all agents follow the selected path. If you want only agents in a certain state to follow the path, you need to rewire the POP Steer Path node. See the simulation network overview and states and behaviors.

Look At

Have agents keep their head turned toward the selected object.

Target Position

Have agents chase the selected object.

Agent Cam

Create an attach cameras to the head transform of the selected agents.

Geometry networks

Crowd simulations have separate agent setup networks for each separate class of agent, and a crowd source network to generate the crowd.

Agent setup networks

This network is where you (or the shelf tools) add nodes to modify the agent primitive before simulation, such as adding layers, and adding collision and rotation information for ragdoll simulation.

Agent node

Creates an agent primitive, and sets basic information such as its name, the current layer, and the current animation clip.

Agent Prep node

Sets up additional information on the agent, such as specifying transforms to use for different limbs, so the solver knows how to do foot placement and other procedural changes.

OUT node

This node exists as a reference target for the simulation network to grab the agents using a POP Source node.

Crowd source network

Object merge

These nodes "import" the agent primitive from a setup networks.

Crowd Source node

This node copies agent primitives onto points. It has options for automatically scattering agents across a surface or within a defined area, as well as for randomizing their initial states.

Agent Constraint Network

This node sets up the constraint networks between agent parts, for ragdoll simulation.

merge_crowdsources

This node merges the separate import → crowd source → constraints branches for each agent class in the simulation.

Below this is a null node to act as a target for importing the agents into the crowd simulation DOP network. You can wire nodes you want to apply to all agents between these two nodes.

crowd_sim_import

This DOP IO node node imports the results of the DOP crowd simulation back into this object so it can be rendered.

You can wire geometry into the crowd source nodes to control the scattering of agents.

  • If you wire in point geometry, it will create agents at those points.

    If the input points have agent related attributes on them, the attributes will be copied onto the new agent primitives. This is a very effective way of manually or randomly specifying different starting conditions, looks, etc. across agents.

  • If you wire in surface geometry, it will use the dimensions of the of the surface as the area across which to randomly scatter a number of agents controlled by a parameter.

    If the surface has a density attribute, the node will only create agents where the attribute is non-zero.

  • If you don’t wire in any geometry, it will parameters to decide the area and number of agents to randomly scatter.

DOP network

The Simulate shelf tool creates the geometry network above as well as a simulation network with some sample nodes for simulating the crowd.

States and behaviors

Each branch leading into the merge_states node starts with a Crowd State node, which specifies the state name.

The state node is followed by behavior nodes specific to that state, between the state node and the merge_states node. These behaviors do not execute in sequence, they are normalized and applied simultaneously to the agents in that state.

You can wire behavior nodes after the merge_states node. Those behaviors will apply to all states. This is useful for things like avoiding obstacles.

The state name should correspond to an animation clip of the same name that agents will play while in that state.

Triggers and transitions

Each branch leading into the merge_transitions starts with a Crowd Trigger node specifying a condition that will cause an agent to change state. You can combine multiple conditions using the Crowd Trigger Logic node, which lets you specify "And", "Or", and "Not" relations between two triggers.

The trigger node(s) is/are followed by a Crowd Transition node which specifies that agents in one state should switch to another state when the trigger condition is met.

(You can wire multiple Transition nodes between a trigger and the merge_transitions if you want a trigger to cause multiple state changes.)

Crowd source

This is a POP Source DOP that references agent primitives created in the crowd source network.

Crowd solver node

Implements the crowd system. The solver has controls for several optional default behaviors that can apply to all agents, such as agent-to-agent collision avoidance, and terrain following.

Crowd Object and POP solver

These nodes are used by the particle (POP) foundation on which the crowd system is built. You will not usually need to modify these nodes.

Tip

Houdini automatically color codes certain nodes to make it easier to keep them straight in the network editor (Crowd State pink, Crowd Trigger orange, Crowd Trigger Logic green). If you want to, you can change a node’s color after it is created.

Crowd simulations

Getting started

The moving parts

  • Agents

    About agents, the moving "actors" that make up a crowd simulation.

  • States

    About agent states, the virtual "mood" of each agent which controls the agent’s animation and which behaviors it runs.

  • Clips

    How to associate animation with agents in certain states.

  • Triggers

    How to specify conditions that cause agents to change from one state to another.

Next steps

  • Foot planting

    How to set up agents to adapt their animation to terrain and prevent skating.

  • Transition graphs

  • Attributes

    Useful attributes for reading in triggers, or that you can set to affect behavior.

  • Sensors

    How to make agents behave differently based on their virtual senses.

  • Diversity

    How to create a more realistic crowd by making agents look and act differently.

  • Weights

    How the Houdini crowd solver decides which behaviors to apply to an agent at each time step.

  • Terrain

    How to specify terrain geometry for agents to walk across.

  • Obstacles

    How to set up obstacles for agents to avoid.

  • Dynamics interaction

    Tips on setting up interaction between agents and other types of dynamics.

  • Ragdoll simulation

  • Adding direction

    How to assert manual control over different aspects of the crowd simulation.

  • Fuzzy Logic

  • Caches

    Tips for efficiently caching and loading crowd sims.