Animating a Rigid Body Entity

Here, we’ll describe how you can simulate any animated geometry with Golaem Crowd, even if it hasn’t a skeleton or a complex rig. If the animation engine will not be usable in such cases, we’ll still be able to use the Asset Manager, some avoidance behaviors and, of course, the procedural rendering techniques.

 

Setting up your Asset

Here is a little nutcracker soldier. No skeleton here, it’s just a bunch of keyframed meshes to make it cyclely walk on-the-spot during 24frames. The only requirement to input this character into Golaem Crowd is to create a root joint on the floor and to parent the character geometry to it (middle click drag’n’drop). This joint will be used by the system to place and orient the characters in world space.

With this root joint, you can create an entry in the Assets Manager for the nutcracker character. Pretty straightforward: select the root joint, create a new asset (Asset_NutCracker), select the character meshes and create a new asset group (Body).

Don’t forget to export it to FBX (Tools / Export Selection as FBX), to set up the bounding box and you’re done!


 

Setting up the Simulation

The simulation part is the same piece of cake than the asset part:

- Create a new EntityType Nutcracker . As the character will not be animated with the Golaem Crowd animation engine, there is no need to specify a skeleton file.

- Create a Terrain . If no Maya geometry is selected, it’ll create a default plane terrain.

- Create a bunch of particles, either with the Population Tool or some Maya emitters.

- Connect a CrowdField  to the particles and run the simulation. As no skeleton has been loaded, the default display will be a bunch of oriented cylinders: pretty rough… Let’s change this.

- Import your animated Nutcracker in the scene and place its root joint at the scene origin.

- Golaem Crowd provides a GPU-based way to efficiently preview animated geometries on top of particles. Go in the entityTypeSurface1 Attribute Editor, switch the Display Mode to “Skinned Mesh” and map the imported nutcracker meshes in the “Skinned Geometry” field. You can even play with the "Hue Variation Factor" to randomize their preview color. It is important to notice that this display is for PREVIEW ONLY: it does not take into acount your shading graph and your asset repartitions (yet)


 

Setting up the Behaviors

OK, now you’re ready to add some behaviors to your characters, depending on what you’d like them to achieve: reaching a target, avoiding each other, playing a baked animation… Let’s say I want all my soldiers to reach a target and avoid each other.

- Create a Navigation Mesh from your Maya geometry  to compute obstacles and environment limits.

- Add a Crowd Target Locator  in your scene. You can keyframe its position if wanted.

- Open the Behavior Editor for your EntityType and add a Goto Behavior and a Navigation Behavior in a Parrallel operator. Change the Goto parameters to make your characters reach the Target Locator we just created. Change the Navigation parameters (speed, acceleration…) if needed.

- Play the simulation and enjoy the result.

- Ok! You may notice that the characters are still not animated: this is normal as we did not add any behavior to deal with animation yet. As the characters do not have a skeleton, we can’t use neither the Motion Behavior nor the Locomotion Behavior. So how do we play the baked animation stored in the FBX file then? Let’s have a look to the Geometry Behavior:

As you can see, it takes a FBX file to play, a start and a stop frame in this FBX, some speed replay parameters and some start frame parameters. Isn’t it exactly what we need?

- To assign a FBX file to this behavior, go in the Assets Manager, select the FBX file you’d like to play (in this scene, there’s only one) and click on the Assign button on the bottom right corner.

- Change the Geometry Behavior parameters to fit the animation: start frame, stop frame, randomize the start percent random. As we do not have skeleton animation to blend, uncheck the "Blend Behavior" option as well (you may need to Refresh the Entity Surface Shape node to take this new configuration into account at the GPU level).


 

Setting up the Rendering

Nothing special to do here, characters with or without skeleton are rendered the same: just export the cache and add a Render Proxy in your scene and you're done.


You can even add some shader attributes in the Assets Manager to deal with texture / shading variation (without relaunching the cache export).


It makes sense for you to use a crowd simulation software to animate moving characters but you're still wondering why you'll use it for static objects such as trees, parked cars? Why not using the Maya instancer instead? Let me try to convince you with few properties relative to my soldier scene:

- maya scene: 900kb
- cache per frame for 800 characters: 19kb
- render time with VRay (full-HD image): 52seconds
- geometry loaded on demand only
- shading variation / geometry variation for free
- thanks to the GPU based preview, the viewport keeps being interactive even when instancing a large number of objects

Here are a few more examples made in a couple of hours:


Cars controlled with an uniform field and animated with a geometry behavior for the tires.

 


Trees placed and oriented with the Population Tool. Same model but with different scales and geometry variations.

 


Birds controlled with a flock behavior, animated with a geometry behavior for the wings and with shading variation.