You are here

Create a Bounding Box for a Crowd Field

When lighting a scene, sometimes you want to avoid the lighting TD to directly deal with the crowd simulation and rather use Maya objects to locate / visualize where the Crowd Entities currently are. The Golaem Crowd Constraint Behavior provide a way to place Maya objects on Crowd Entities but that'll require to create as many Maya objects as they are Crowd Entities. In the following, we provide a sample code to use and keyframe Maya cubes as Bounding Boxes of the particles representing Crowd Entities.

Example of a Maya cube acting as a bounding box of the crowd

This whole process relies on Maya MEL functions. First you need to copy the following function in your Maya scripts and make sure it's sourced correctly. It takes the name of an object to track (in our case a particle system), the name of the cube to use as bounding box and if you want the bounding box vertices to be keyframed:

Next we can use that function to edit a cube vertices position according to a particle system containing our Crowd Entities. First create a Maya cube with only 1 subdivision on each axis and run the following command:

It will create an expression attached to pCube1 which will make it deformed according to particle1 bounding box (do not forget to change the names depending on your objects :)). Set 1 as last parameter of updateCubeFromObjectBBox if you want pCube1 to be keyframed when the simulation is run. Once it is keyframed, you can run the simulation, delete the expression and export that Maya cube (which will be animated) for your lighting TDs.