MayaMotion GraphicsSimulation

Soft / Rigid Body Simulation Including Keyframe Animated Objects in Maya

By 16. September 2016 April 10th, 2018 No Comments

In this tutorial you can learn how to simulate interactions between soft and rigid objects and how to include keyframe animated elements in the simulation.

We will use the Bullet engine which is in most cases faster than Maya’s nDynamics engine. It ships with the Maya 2017 installation. To activate Bullet, go to > Windows > Settings / Preferences > Plug-in Manager and at “bullet.mll” make both ticks.

If you like to work in a visually pleasing environment it is recommended to set up your lighting and Viewport 2.0 as described in this tutorial.

Start with a groundplane > Create > Polygon Primitives > Plane and scale it. Bring in the first collision object with > Create > Polygon Primitives > Cube and RMB >Assign New Material. Move it up. Switch the UI mode to “FX” and you should now have Bullet in Maya’s menu.

2017_fx

To start with the Bullet simulation select the cube and > Bullet > Active Rigid Body.

2017_activerigidbody

Press Play and the Cube falls through the ground. To include the groundplane in the simulation select it and > Bullet > Passive Rigid Body. Now the cube should stop on the ground. You can rotate the cube at it’s initial position to make the collision more interesting. Before you make changes in your scene always go back to Frame 1 with the |<< button at the playbar. If your simulations runs too fast go to > Windows > Settings / Preferences > Preferences > Time Slider or click on the gear icon below the playbar. Change the Max Playback Speed to Real-time.

2017_playbackspeed

Now let’s add a sphere and make it soft. Soft body simulations calculate bending and stretching between polygons and the default sphere’s different polygon sizes delivers not the best topology here. Instead > Create > Polygon Primitives > Cube, hit “3” key and then > Modify > Convert > Smooth Mesh Preview to Polygons. Alternatively the Soccer Ball and the Platonic Polygon Primitives have also a good polygon layout.

2017_smoothmeshpoly

Increase the subdivision by repeating the last steps: hit “3” key again and > Modify > Convert > Smooth Mesh Preview to Polygons. Now add the rounded cube to the simulation with > Bullet > Soft Body.

2017_softbody

When you now hit play the objects interact with each other. In the Attribute Editor at the bulletSoftBodyShape you can tweak the softness and interaction details. It is recommended to switch on Generate Bend Constraints and Enable Shape and Volume Matching. By increasing the Pressure the shape becomes more stable.

2017_softbodyshape

If your soft body slips through the ground, select the bulletSolver object in the Outliner and in the Attribute Editor under Solver Properties activate Ground Plane. If that doesn’t help increase the Internal Fixed Frame Rate to 120 Hz.

2017_bulletgroundplane

Now > Create > Polygon Primitives > Pyramid to bring in the third object. To move objects in other directions than downwards following gravity, you can give rigid bodies an initial velocity. In the Attribute Editor > BulletRigidBodyShape > Initial Conditions you could add Initial Velocity in x direction and let it rotate around z axis for instance by changing the values there.

2017_initialvelocity

If you want to have more control over the animation it is also possible to mix keyframed objects with the simulation. The important thing is, that you turn the pyramid into a rigid body before adding keframes. Select the pyramid and > Bullet > Active Rigid Body. Then you can animate it. Go to Frame 1, place the pyramid at the desired position, hit “S” key, go to the next position in the timeline, move the object, hit “S” key and so on. With the pyramid selected then go to the > Attribute Editor > bulletRigidBodyShape tab and switch Body Type to Kinematic RigidBody. This tells the Bullet engine that the pyramid comes with it’s own animation. The Collider Shape Type needs to be set to “hull”, otherwise the Bullet engine would internally work with the default simplified box shape representation. With “Collider Shape Margin” you can adjust the padding around the shape.

2017_kineticrbd

When you go back |<< and press play all objects should now interact with each other.

2017_bulletresult2

If you want to have more granular control over the simulation especially with soft bodies or if you like to apply different force fields you can alternatively simulate with Maya’s nDynamics engine. It is slower than the Bullet engine but can be more precise. The handling is similar like with Bullet, you find the tools in the FX interface under the nCloth and Field/Solvers menu.