With the recent release of Maya 2016
, there have been many improvements and changes to the 3D application
. It’s apparent Autodesk is slowly bringing the Bullet Physics Engine, which was first integrated into Maya 2015, at the forefront of its plans for rigid body dynamics (RBDs).
Bullet is an extremely powerful dynamics engine that also includes things like cloth and ragdoll physics, but its bread and butter are in the collision detection and rigid and soft body dynamics.
One of the draws to Bullet is its ease of use coupled with its flexibility. Although it’s relatively new to Maya, Bullet has been used for years. For example, the team at DreamWorks used Bullet for feature films like Megamind
and Shrek 4
and thanks to its smooth integration into game engines it was also used in games like Grand Theft Auto V
If you’re new to the Bullet engine then now is the time to start diving into the dynamics simulation engine, as Maya 2016’s updates indicate, Autodesk is moving full force with it. Let’s learn by doing as we go over the basics of setting up a simple RBD simulation with Bullet.
Setting up an RBD simulation in Bullet
Let’s first start by creating a couple cubes. I’ve gone ahead and stacked them up to create a small structure. You can probably already guess just from looking at it that we’ll be setting up a very simple simulation and have something smash into the cubes, knocking them over.
In Maya 2016 you should see a Bullet shelf. If you don’t, make sure bullet.mll
is loaded in Maya's Plug-in Manager.
In addition to the shelf, there’s a Bullet drop down under the FX menu set. Although you’ll find most of the same tools you have in the Bullet shelf, in the menu you can use the option box to adjust some of the options and edit the properties before setting up your simulation.
With Bullet loaded, let’s turn all of the cubes into active rigid bodies. To do this, highlight all the cubes and either use the Active Rigid Body icon (highlighted in the screenshot above) or you can go up to the Bullet drop down menu and choose Active Rigid Body.
You’ll know your cubes are active rigid bodies when they get a green highlight after running the command.
To run the simulation, press the Play button in Maya’s Time Slider. At this point, you’ll see the cubes slowly start to fall as the simulation runs. They’ll keep falling into endless 3D space until your timeline’s range is done.
Let’s create a ground floor next so they’ll have somewhere to land.
We can do this one of two ways. One method you could use is to create a poly plane and set it to be a passive rigid body by selecting the plane and going to Bullet > Passive Rigid Body.
Another method for creating a ground floor is to tell Bullet to use Maya’s grid as a floor. To do that open up the Outliner by going to Windows>Outliner.
Inside the Outliner scroll all the way down to the bottom until you see the bulletSolver1
group, open it up and select the bulletSolverShape1
With the bulletSolverShape1
node highlighted, open up the Attribute Editor (Ctrl+A). Inside the Attribute Editor, you’ll see a large list of parameters you can adjust for the bulletSolverShape1
The Bullet solver lets you change the overall properties for your scene like gravity, wind direction and things like that. Under the Solver Properties drop down menu, you’ll see a checkbox for Ground Plane (highlighted in the screenshot above). Check this option and Bullet will use the grid as your floor. Now if you run the simulation, the cubes will hit the ground plane.
Start by dropping a poly sphere into your scene and position it in front of the cubes. With the sphere selected, click on the Active Rigid Body icon on the shelf.
Select the green box around the sphere, and navigate to the bulletRigidBodyShape161
node. If you’re following along and the number at the end is different, that’s OK. It just means you have a different number of objects in the scene than I do, but the techniques are the same.
In the bulletRigidBodyShape
node, scroll down to the Collider Properties and set the Collider Shape Type to sphere as you can see in the screenshot above.
Now scroll up to the Initial Conditions section and under the Initial Velocity change the X value to around -40. This will give our sphere some initial movement in the -X direction at the start of the simulation.
If you’re following along and positioned the sphere differently than I did in the beginning, you might need to set your initial velocity in the Z axis. The key is to have the sphere start traveling toward the cubes.
If you run the simulation now, the sphere should travel toward the cubes and hit them. However, by default the sphere will hit the cubes and fall. To have the sphere make a bigger impact on the cubes, we’ll need to adjust the properties on the sphere to make sure it smashes through the blocks and doesn’t just fall and bounce off.
Scroll up to the Rigid Body Properties and bump up the Mass attribute to around 30.
Now when you run the simulation, the sphere should bust through the cubes.
And you’ve successfully setup your first collision simulation with Bullet!
Tweaking simulations in Bullet
Something you’ll learn quickly about dynamic simulations is how they require a lot of tweaking to get them to do what you want. For example, what if you wanted to adjust the properties of the cubes so they’re a little bouncier? Or maybe increase the friction so they don’t slide as much along the floor?
Well, because we initially selected all of the cubes as separate objects when we applied the active rigid body to them, each cube has its own rigid body properties. This is OK, but if you want to adjust the bounciness of the cubes overall, it’d mean you’d have to go in and individually set every single cube.
No one wants to do that.
Luckily, Bullet has a feature called a Rigid Body Set that you can use to save time.
Let’s use our original stack of cubes before we turned all of them into rigid bodies.
Start by selecting all of the cubes. Instead of clicking on the Active Rigid Body button, this time click on the icon just to the right (highlighted above). This is the Rigid Set, and it tells Bullet to create a single solver for all of the selected objects – in this case the stack of cubes.
If you run the simulation now without a ground floor, you’ll get a result similar to what we had earlier. Just like before, go to the Outliner select the bulletSolverShape1
node and check the Ground Plane checkbox.
Now select the bulletRigidSetInitialState
node in the Outliner and open up the Attribute Editor. Any adjustments to your Rigid Set’s attributes will reflect across all the cubes in the scene, so you only have to modify one single node to make sweeping changes. This can save you a tremendous amount of time.
So, for instance, you can adjust the friction to zero in the Rigid Set and all of the cubes behave more like they’re on ice.
If you don’t want the cubes to start moving as soon as the simulation starts, scroll down to the Initial Conditions and enable Initially Sleeping. The Initially Sleeping attribute means that when then simulation starts, the cubes are not going to move until they encounter another object.
This is great if you’re doing something like shattering glass, and you want the separate pieces of geometry to stay still together until an object hits the glass.
With the knowledge you have of working with Bullet, now it’s time for you to start creating your own simulations and experimenting with it. Or if you want to you want to learn some more techniques for working with Bullet, check out the Shattering a Statue Using Bullet Physics in Maya