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.
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.
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.
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.
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.
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).
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.
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
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.
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.
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.
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.
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 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.
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.
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.
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).
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:
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.
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.
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.
Save your work VERY REGULARLY
Organize your life
Scheduling is vital, including 20-25% contingency time
Organize your files well, and back them up to CD / DVD regularly/
Keep an eye on your quota
Keep physical notes while watching playblasts, etc, so that you aren't playblasting every time you correct one little thing, but only when you've corrected all previous errors
Before you set important renders going, check over the render settings
Wherever possible, render (or playblast) at half resolution (360×288)
Every time you find yourself thinking "I wish I had a shortcut key for that", set one up
Consider your safe area (90% of screen is action safe, 80% is text safe) and gamma, especially when transferring to video or watching on television
Work out time to render one frame, and predict total render time (assume only one computer) to make sure you can finish it in time
Keep render times to a minimum
Save your scene just before each render
Maya is much less likely to crash when rendering from the command prompt, so do that whenever possible
Keep number of lights as low as possible, especially area lights
Keep geometry simple: if a prop only appears small on screen, don't model it with 500k polygons
Likewise, if a texture appears small on screen, don't map a 2000×1500 image onto it: generally go for 1.5 times the size it will appear on screen.
Consider using bump maps instead of adding more geometry
Take your antialiasing into account
Don't be afraid to "cheat":
Don't model / texture / render surfaces that will never be seen, e.g. behind the camera
Bake global illum / caustics wherever possible
Rather than re-render an entire scene, consider painting out errors in Photoshop
Be kind to the computer
Save regularly, as the software WILL crash
Save, close Maya and restart occasionally, especially if strange things start happening
If strange things carry on happening, log off and back on again: maybe even restart the computer
If the computer suddenly slows down, think about what you've just done and what might have caused it
Be kind to your classmates
You cannot expect computers to remain logged in without anyone sat at them, even if a render is going
If a computer is locked by someone not present in the lab, anyone may restart it without warning
The /transfer drives of each computer can be used to store data, but it should not be left there indefinitely: if the support team are told that a /transfer drive is full, they will empty it remotely without looking at the content. /tmp is emptied when the computer reboots
Save your work twice as often as you think is sensible
*Be sure to turn off the character set
© Henry Bush, 2013
These notes were last updated on Friday 10 May, 2013 and are designed for the use of students at the NCCA, but remain the property and responsibility of Henry Bush. They are available for free for personal or academic use, but with no guarantees of the quality or reliability of the material involved. Please give appropriate credit where used.