MART Term 3, Lecture 2
Rigid Bodies & Soft Bodies

Dynamics

We have already been introduced to the dynamics system in Maya when we looked at particles last week. As well as manipulating particles, we can also manipulate both rigid bodies and soft bodies. Rigid bodies, as you might expect, would be things like planks of wood, bricks, etc., that stay the same shape when affected by external forces. Soft bodies might be something like a water balloon, whose shape changes depending upon the forces applied to it.

Rigid Bodies

We'll start with rigid bodies, because they are the easiest. Rigid bodies are great for simulating situations that would take a long time to animate, and if we aren't too bothered what the results look like. For an action that is intrinsic to your scene it is best to keyframe it, as then you have complete control over where the objects move. For background or incidental actions, using rigid bodies can save time.

[screenshot: MART_T3L02_html_m756db34c]To begin, we'll do a simple example of how rigid body dynamics can be useful. Get a new scene, and add a nurbs plane. Make it bigger. Now create lots of primitive shapes (8-10) a little way above the surface, making sure that none of them intersect. Select all of the objects, and go to Soft/Rigid Bodies → Create Active Rigid Body. Then select the plane, and go to Soft/Rigid Bodies → Create Passive Rigid Body (this will not move, but must affect the movement of the other objects).

Now press play. Nothing happens. This is because all we have done so far is tell Maya that when the objects collide, they should bounce off each other. What we need to do is add an external force so that they fall and do collide: we do this using the same fields that we used last week for our particles. Select all of the objects, and click on Fields → Gravity. We shouldn't need the options box this time. Press play now, and we have a chaotic mess of precipitating primitives. To animate this by hand would have taken a really long time, but we would have been able to control the action much more thoroughly.

See-saw

Now we're going to simulate the classic roadrunner trick of dropping a large weight onto a see-saw with a person on the other end. First of all delete all the primitives that we made above, but keep the surface. We'll use the same one.

For this, we are going to utilize the principle of the pre-roll. This means we are going to have a few frames (about 100 or so) where the objects settle into position, before the animation that we are interested in capturing actually starts.

[screenshot: MART_T3L02_html_71ba1f73]First, we'll create our pivot and our plank. I shall use two scaled cubes. I have made sure that they are very much separate, as I am going to drop them down. Now add our "roadrunner": I'm going to use a cube. Make all of these objects into active rigid bodies, then apply the gravity field to them (if you didn't delete it: otherwise, just create a new one).

Now press play. You'll see that the general idea is there, but the box slides off the end of the see-saw. This is because the default value for friction is set quite low. Select the cube, and turn both static and dynamicFriction up to 0.9 in the channel box. Do the same for the pivot and the plank.

This is better, but the pivot still jumps around all over the place. One way to sort this out is to keyframe whether or not it is active. If we set it not to be active at about frame 70, it will stop jumping about. This does also mean that it won't be affected by anything any more, but that doesn't matter.

[screenshot: MART_T3L02_html_66ebd2ab]Now if we play it, we see that after the cube has settled on the plank, it still shuffles around. In fact, it never completely settles. In order to get around this we can set it to "dampen". In the channel box, change the damping value to 0.2. Now when we play the animation, it should completely settle in our starting position.

Now we need our 10 ton weight. For this I'm going to use... yet another cube. Feel free to use something else if you prefer. Place the cube directly above the opposite end of the see-saw to our roadrunner. Now make it into an active rigid body, and apply the gravity force to it. Since we don't want it to start moving until everything else has settled, keyframe Active to be off until about frame 100. Play the animation, and you should find that it works pretty well, apart from one thing: the "weight" is no heavier than the roadrunner. Find the mass attribute of the weight, and change it to 20.

That works better. Now the roadrunner is fired into the air (which never happened in the cartoon, he always ran away too quickly).

Constraints

Get a new scene. Now we'll look at some of the constraints available for use with rigid body dynamics. Get a sphere, and make it an active rigid body. Select it, and add a gravity field to it. Press play to make sure it falls.

1. Nail Constraint

With the sphere selected, go to Soft/Rigid Bodies → Create Nail Constraint (don't bother with the options this time). Translate the new object up above the sphere and along to one side: there is a line between the sphere and the constraint. Press play and you'll see what happens. The sphere is attached to the point, as if by a solid bar: in this case, this makes it act like a pendulum. The constraint itself doesn't have many settings: just a constrain on or off. At this point we have perpetual motion; if we want to make the sphere slow down, we can change the damping attribute in the rigidBody1 node of the sphere itself.

2. Pin Constraint

[screenshot: MART_T3L02_html_3506bafc]Sounds very much like a nail constraint, but works quite differently. For this we'll need another object: create a cube, move it to somewhere other than the origin, and make it into another active rigid body. Now select both, and go to Soft/Rigid Bodies → Create Pin Constraint. To best demonstrate this constraint, delete the gravity field and apply a newton field to the objects. Now press play: the effect is similar to having a nail constraint on each object to the same point, but they can drag that point around. One of those "sure it must be useful for something, but not quite sure what at the moment" things.

3. Hinge Constraint

The hinge constraint does pretty much exactly what it say: it gives you a hinge that fixes the object in place, which you can use to create doors, pendulums, etc. Similar to the nail, but only allows rotation in one axis.

4. Spring constraint

For this one we need different objects. Get a new scene, and create one passive and one active rigid body. Then apply gravity (or anything) to the active rigid body. Select both objects and click on Soft/Rigid Bodies → Create Spring Constraint. Press play to see the marvellous springiness. This is a really useful constraint.

5. Barrier Constraint

This stops a rigid body going past a certain point. Can be useful, but (unlike in a collision) the object stops dead (no bouncing, slowing down, etc.) so tends to look very fake.

Soft Bodies

Soft bodies have many uses: they are a way of making the geometry of an object react to fields (not just the whole object, like with rigid bodies). Let's look at an example.

A Rubber Ball

[screenshot: MART_T3L02_html_m323acea3]Create a nurbs plane with a sphere above it. Now we'll make the sphere into a soft body: select it, and go to Soft/Rigid Bodies → Create Soft Body.

Soft bodies work in a slightly peculiar way: Maya creates a particle system, one particle for each CV / vertex in the original object. These particles have some special options, but also have all the attributes of a normal set of particles.

Once you've done this, apply a gravity force to our new soft body. Press play, and the sphere will pass straight through the plane. We need to make it collide: select the sphere, then the plane, and go to Particles → Make Collide. This works with all particle systems. Now press play, and see what happens.

The particles carry on bouncing forever. We need to turn down the Conserve attribute in the particleShape node: change it to 0.95. The conserve attribute affects the way that particles react to dynamics.

[screenshot: MART_T3L02_html_m4bc8f2e4]Now press play, and you'll see the effect. Our object ends up completely flat. This is not good, it's not what we want. The reason for this is that our object has no memory of what the object used to be like. Once we make it a soft body, the particles control the shape completely. There is a solution though.

[screenshot: MART_T3L02_html_m1a5c7d4e]Start again from before we form the soft body (so we just have a normal sphere above the plane). Go to Soft/Rigid Bodies → Create Soft Body ❐, and this time change to Duplicate, Make Copy Soft. Also turn on Hide Non-Soft Object and Make Non-Soft a Goal. Click create, and then apply gravity to the hidden, non-soft object (nurbsSphere1) and make it collide with the surface. What you will find is that the sphere deforms as it hits the ground, giving it a sort of wobbly look. Because it now has a goal, the object is constantly trying to be the same shape as the original sphere: if we had set its weight to be 1, the object would always be the same as the original; if it were 0, the particles wouldn't be affected by the goal at all (like the example we saw before).

Try adjusting, maybe even animating, the goal weight: you find the weights for each goal object in the attribute editor of the particleShape under Goal Weights and Objects (the name of the goal weight will be the name of the goal object).

Walking in Snow

When making soft bodies we will generally want a goal weight, but sometimes not: the example we are going to look at now is to simulate someone leaving footprints as they walk along in snow. For this we do not want a goal, because we want the footprints to stay there forever, not for the surface to creep back to its original state.

Open the scene:

tarquin-walk.ma

[screenshot: MART_T3L02_html_47eb437b]The first thing to do is make Tarquin walk for longer. Select his character set, and go to Animate → Create Clip ❐, reset the settings, and click Create Clip. Now load up the trax editor, and duplicate the clip a couple of times so that he walks for 72 frames.

Now lets create a snow surface. We'll use a polygon plane, and enough subdivisions so that his feet can press down individual vertices. I've made a runway that's 50 polygons wide by 200 polygons long. Move it down so that his feet just go through to the other side.

Now we have to make it into a soft body. This time, we do not need any of the duplicate options set: reset the settings, and click Create Soft Body. Now make it collide with the four objects that make up the two feet.

[screenshot: MART_T3L02_html_515975eb]So easy! Except that it doesn't work properly. The main problem is that some of our particles start off inside the foot geometry, thus they get dragged along inside it, making a huge mess. What we need to do is add some pre-roll: a few frames before the start of our animation, in which the scene is prepared. We will use this to move the snow surface up to the character's feet. Change the playback range so that it goes from -10 to 72. Now keyframe* the translation of the snow at frame 0, then go to frame -10 and keyframe it a little lower. Press play, and it has changed nothing; the reason being that the simulation still starts at frame 1. We can change this in the Time Attributes section of the particleShape's attribute editor: change it to -10.

OK, now the particles don't get kicked forward, but they also never stop moving once they have started. To change this, simply turn the Conserve value down: we can turn it all the way down to 0.0 in this situation. When you playback our beautiful animation, be sure to have Maya set to play every frame.

The Rules

Finally, here are a list of recommended working practices. Producing a computer animation is a complicated business, and these suggestions aim to simplify it as far as possible.

  1. Save your work VERY REGULARLY

  1. Organize your life

  1. Keep render times to a minimum

  1. Be kind to the computer

  1. Be kind to your classmates

  1. Save your work twice as often as you think is sensible



*Be sure to turn off the character set