Rigid and Soft Dynamic Bodies

The two types of dynamic bodies are rigid and soft. Rigid bodies are solid objects, such as a pair of dice or a baseball, that move and rotate according to the dynamics applied. Fields and collisions affect the entire object and move it accordingly. Soft bodies are malleable surfaces that deform dynamically, such as drapes in the wind or a bouncing rubber ball. In brief, this is accomplished by making the surface points (NURBS, CVs, or polygon vertices) of the soft body object dynamic instead of the whole object. The forces and collisions of the scene affect these surface points, making them move to deform their surface.

In this section, you’ll learn about rigid body dynamics.

Creating Active and Passive Rigid Body Objects

Any surface geometry in Maya can be converted to a rigid body. After it’s converted, that surface can respond to the effects of fields and take part in collisions. When one Maya object hits another in a dynamic simulation, Maya calculates the animation of the colliding objects according to their velocity and other dynamic properties such as mass. Sounds like fun, eh?

The two types of rigid bodies are active and passive. An active rigid body is affected by collisions and fields. A passive rigid body isn’t affected by fields and remains still when it collides with another object. A passive rigid body is solely used as a surface against which active rigid bodies collide.

The best way to see how the two types of rigid bodies behave is to create some and animate them. In this section, you’ll do that in the classic animation exercise of a bouncing ball.

To create a bouncing ball using Maya rigid bodies, switch to the Dynamics menu and follow these steps:

Figure 12-1: Place a poly sphere a few units above a poly plane ground surface.

f1201.tif

1. Create a polygonal plane, and scale it to be a ground surface.

2. Create a poly sphere, and position it a number of units above the ground, as shown in Figure 12-1.

3. Make sure you’re in the Dynamics menu set (choose Dynamics from the Status Line drop-down bar). Select the poly sphere, and choose Soft/Rigid Bodies ⇒ Create Active Rigid Body. The sphere’s Translate and Rotate attributes turn yellow. There will be a dynamic input for those attributes, and, as such, you can’t set keyframes on any of them. The dynamics engine drives the movement and rotation of the active rigid body sphere.

4. Select the ground plane, and choose Soft/Rigid Bodies ⇒ Create Passive Rigid Body. This sets the poly plane as a passive rigid body to serve as the floor on which to bounce your active rigid ball. For this exercise, stick with the default settings and ignore the various creation options and Rigid Body attributes; you’ll explore the most important of those later in this chapter.

5. To put the ball into motion, you need to create a field to affect it. Select the sphere, and choose Fields ⇒ Gravity. By selecting the active rigid object(s) while you create the field, you connect that field to the objects automatically. Fields affect only the active rigid bodies to which they’re connected. If you hadn’t established this connection initially, you could still do so later, through the Dynamic Relationships Editor. You’ll find out more about this process later in this chapter.

If you try to scrub the timeline, you’ll notice that the animation doesn’t run properly. Because dynamics simulates physics, no keyframes are set. You must play the scene from start to finish for the calculations to execute properly. You must also play the scene using the Play Every Frame option. Click the Animation Options button to the right of the Range slider, or choose Window ⇒ Settings/Preferences ⇒ Preferences. In the Preferences window, choose Time Slider under the Settings header. Choose Play Every Frame from the Playback Speed menu. You can also set the maximum frames per second that your scene will play back by setting the Max Playback Speed attribute.

To play back the simulation, set your frame range from 1 to at least 500. Go to frame 1, and click Play. Make sure you have the proper Playback Speed settings in your Preferences window; otherwise, the simulation won’t play properly.

When the simulation plays, you’ll notice that the sphere begins to fall after a few frames and collides with the ground plane, bouncing back up.

As an experiment, try turning the passive body plane into an active body using the following steps:

1. Select the plane, and open the Attribute Editor.

2. In the rigidBody2 tab, select the Active check box. This switches the plane from a passive body to an active body.

3. Play the simulation. The ball falls to hit the plane and knock it away. Because the plane is now an active body, it’s moved by collisions. But because it isn’t connected to the gravity field, it doesn’t fall with the ball.

To connect the now-active body plane to the gravity field, open the Dynamic Relationships Editor window, shown in Figure 12-2 (choose Window ⇒ Relationship Editors ⇒ Dynamic Relationships).

Figure 12-2: The Dynamic Relationships Editor window

f1202.tif

You can also connect a dynamic object to a field by selecting the dynamic object or objects and then the desired field and choosing Fields ⇒ Affect Selected Object(s). This method is more useful for connecting multiple dynamic objects to a field.

On the left is an Outliner list of the objects in your scene. On the right is a list from which you can choose a category of objects to list: Fields (default), Collisions, Emitters, or All. Select the geometry (pPlane1) on the left side, and then connect it to the gravity field by selecting the gravityField1 node on the right.

When you connect the gravity field to the plane and run the simulation, you’ll see the plane fall away with the ball. Because the two fall at the same rate (the rate set by the single gravity field), they don’t collide. To disconnect the plane from the gravity field, deselect the gravity field in the right panel.

Relationship Editors

The Relationship Editors, such as the Dynamic Relationships window, are a means to connect two nodes to create a special relationship. The Dynamic Relationships Editor window specializes in connecting dynamic attributes so that fields, particles, and rigid bodies can interact in a simulation. Another example of a Relationship Editor is the Light Linking window, which allows you to connect lights to geometry so that they light only that specific object or objects. These are fairly advanced topics; however, as you learn more about Maya, their use will become integral in your workflow.

Turning the active body plane back to a passive floor is as simple as returning to frame 1, the beginning of the simulation, and clearing the Active attribute in the Attribute Editor. By turning the active body back to a passive body, you regain an immovable floor upon which the ball can collide and bounce.

Moving a Rigid Body

Because Maya’s dynamics engine controls the movement of any active rigid bodies, you can’t set keyframes on their translation or rotation. With a passive object, however, you can set keyframes on translation and rotation as you can with any other Maya object. The object isn’t active, so the dynamics engine doesn’t regulate its movement with fields or collisions. But you can easily keyframe an object to be either active or passive for the widest of options.

Now, any movement that the passive body has through regular keyframe animation is translated into momentum, which is passed on to any active rigid bodies with which the passive body collides. Think of a baseball bat that strikes a baseball. The baseball bat is a passive rigid body that you have keyframed to swing. The baseball is an active rigid body that is hit by (collides with) the bat as it swings. The momentum of the bat is transferred to the ball, and the ball is sent flying into the stadium stands.

You’ll see an example of this in action in the next tutorial.

Rigid Body Attributes

To make an object a rigid body, you add several attributes that help govern how it behaves in a dynamic simulation. Here is a rundown of the more important attributes for both passive and active rigid bodies as they pertain to collisions:

Mass Sets the relative mass of the rigid body. Set on active or passive rigid bodies, mass is a factor in how much momentum is transferred from one object to another. A more massive object pushes a less massive one with less effort and is itself less prone to movement when hit. Mass is relative, so if all rigid bodies have the same mass value, there is no difference in the simulation.

Static and Dynamic Friction Sliders Set how much friction the rigid body has while at rest (static) and while in motion (dynamic). Friction specifies how much the object resists moving or being moved. A friction of 0 makes the rigid body move freely, as if on ice.

Bounciness Specifies how resilient the body is upon collision. The higher the bounciness value, the more bounce the object has upon collision.

Damping Creates a drag on the object in dynamic motion so that it slows down over time. The higher the damping, the more the body’s motion diminishes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset