Wednesday, 10 June 2020

Flag waving crowd agents in Houdini

Here I present a method of adding vellum cloth to crowd agents.
This is based on the SideFX example scene 'Simple Crowd Cloth' which you can find in the Houdini Help page for Agent Vellum Unpack.
I have modified the setup to allow the cloth object to be attached to a prop which the crowd agent is holding.

First we need an agent. For this tutorial, I have chosed a mocap animation from Mixamo. They are good quality, adaptable and free.

Go to and choose a character you like. I chose 'Brian' because it is the kind of character you might find at a football match waving a flag.

I wanted to find a clip where the character was holding and waving a prop. The closest I found was the clip called 'Standing Torch Inspect Upward'

Download this clip, with skin, and save it in a new Houdini project.

In Houdini, create an agent: Create a new Geometry object, jump inside and create an Agent SOP.
In the Agent SOP, choose FBX as the Input and browse to find the FBX saved from Mixamo.

Be careful here: Scale is extremely important when it comes to dynamic simulations. Make sure you check the Convert Units box. You do not want a human agent that is 150 metres high!

Name the clip in the agent SOP and name your agent as well.

Next, make a flag and flagpole. The rig does not have a prop joint, so we will have to manually place the flag and pole manually in the right position.

The pole is just a simple Tube SOP and the flag is a simple Grid SOP transformed into place.

One detail - I made a group of the flag vertices closest to the pole. That group will be used later to attach the flag to the pole.

Now we have to define the flag geometry as a Vellum object. To do this, simply drop down a Vellum Configure Cloth node and plug the flag geometry into the first input. We need the pole geometry to act as a collision object so that the flag can attach to it. Plug the pole geometry into the third input of the Vellum node.

So, now the flag is a Vellum cloth object, we need to add it to the Agent definition.

First, it must be packed. Use the Vellum Pack node to do that.

Now we need to add the new geometry to the agent as agent layers: first the pole layer -

Then the flag layer.
Note that we add the Vellum cloth version of the flag to the Agent Layer.
Also note: the flag layer also contains the pole object.
This is needed to allow the flag to attach to the pole later on.

Now that the Agent Layers have been created, save out the with Agent Definition Cache node (or use an Agent ROP node)

We are now ready to test the agent.

Back up in the /obj world, create a new Geometry object. Jump inside and drop a new Agent SOP and this time read back the agent you cached out. Choose Disk as the input and make sure you choose the same Agent Name used in the agent setup.

When you first load the agent, the flag and pole will not be visible. That's because they are on layers.
In the Agent SOP, choose the flag layer as the Current Layer. The flag and pole should now be visible.

Now we need to unpack the Vellum flag. There is a node to do this: Agent Vellum Unpack.

Here we want to choose select by Agent Layer and pick the flag layer.
The Shapes to Simulate is just the flag. We do not want to simulate the pole, just have it present for the flag to attach to.
The Agent Vellum Unpack node retrieves the Vellum cloth from the Agent, plus any collision geometry, that includes any geometry connected to the Vellum cloth node when it was created and the Agent geometry as well.

Now we can attach the flag to the pole, since the pole was added as collision geometry earlier.

Drop down a Vellum Attach To Geometry node and connect all three inputs to the previous unpack node. If Show Guide Geometry is checked, you can see all the collision geometry (in blue). There is the pole, ready for the flag to attach to.

You can specify some vertices or edges for the flag to attach to, but usually just using the Constrain to Closest Point will be adequate.

Now the flag is ready to simulate. Drop down a Vellum solver and plug all three inputs. You should have the flag attached to the pole and the pole being waved around tby the agent.

Of course, you want more that one agent. So, make a crowd.

Drop down a Crowd Source SOP and connect it just after the Agent SOP.
Now you will see lots of flags and lots of blue agent collision object.
If want to see agent geometry, you need to merge the flags with a different Agent Layer.
The pole layer contains the agent and the pole geometry. So, drop down an Agent Edit node and use that to specify the pole layer. This can then be merged with the Vellum cloth flags.

There you have a crowd of flag waving agents - perfect for your next stadium crowd project!

1 comment:

  1. Thanks for the tutorial. I would love a hip file if possible of just how to get the agent to hold something. Cheers