Working With Maya Rigid Body Collision

 
  Introduction

What is a Rigid Body
    A rigid body is a rigid surface whose animation is governed by Newtonian physics, not keyframes. The surface can be either polygonal or NURBS, and it does not change shape during the course of a simulation. The behavior of rigid bodies is determined by their reaction to fields, collisions, springs, and constraints.

What Governs its Behavior
    Physics governs the behavior of rigid bodies. Fields, collisions, springs, and constraints are used to simulate the physics that would be acting on the objects in the real world.

Where have we seen it before
    For those of you who attended SIGGRAPH 99, the opening piece in the electronic theatre titles Fiat Lux used Maya's rigid body collision. Fiat Lux showed large objects colliding inside St. Peter's Cathedral. Star Wars Episode I used Maya's dynamics to create the Pod Race. The motion of the racers was determined by spring simulations, and the crashes were created using a modified version of Maya's rigid body dynamics.
 
Rigid Bodies in Maya

Rigid Body Basics
    There are two types of rigid bodies in Maya.
Active rigid bodies react to dynamics
Passive rigid bodies are reacted against by active rigid bodies
For example with a pool table the balls would be active rigid bodies and the table would be a passive rigid body.
Passive rigid bodies can be keyframed. Active rigid bodies cannot.
A few rules to note:
  • Maya calculates collisions based on the polygonal representation. This means that when using NURBS the tessellation of the NURBS object to a polygonal object is the collision object. To avoid making overly detailed rigid bodies, be sure to specify the tessellation criteria to be used for collisions
  • Collisions can only occur on the side of each polygon with normals.
  • Rigid bodies cannot intersect each other in simulation, so be sure that they do not already intersect each other on the initial frame.
  • Edit->Duplicate does not work with rigid bodies
  • Curves are not considered rigid bodies
  • If a NURBS surface is trimmed, invisible geometry still exists in the whole, so convert the NURBS to polygons is you want anything to pass through the trimmed hole.
  • Latices and deformers can change the look of a rigid body but they do not change the shape used for the collision calculation.
 
Creating Rigid Bodies
    To create a rigid body, simply select the object or objects
Select Bodies -> Create Active Rigid Body   OR
Select Bodies -> Create Passive Rigid Body
The object will now react to collisions, fields, springs, and constraints, but by default there are none.


  • Active button changes rigid body from active to passive
  • Particle Collision when on allows an active rigid body to react to the force exerted by colliding particles.
  • Mass specifies the mass of the object.
  • Center of mass can be specified.
  • Static Friction controls the objects tendency to resist movement when at rest and in contact with another object.
  • Dynamic Friction or kinetic friction controls the objects tendency to resist movement once moving and in contact with another object.
  • Bounciness controls the amount of bounce. When 0.0 the object does not bounce off of surfaces. When 1.0 the object bounces off with the same velocity it struck the surface.
  • Damping controls the drag. It affects the object before, during, and after collisions
  • Impulse is used to create an instantaneous force and is generally keyframed.

  • Initial settings allow you to set initial velocity, orientation, spin, and position.
  • Apply Force At determines whether forces are applied to the
    Center of Mass
    Bounding Box
    or Vertices/CVs
    This option (not seen here) is available only in the attribute editor
  • Tessellation Factor roughly sets the number of polygons the NURBS object will be tessellated into.
  • Collision Layer - rigid bodies will collide only with other rigid bodies having the same layer number. If the layer number is "-1" however, the rigid body will collide with all other rigid bodies regardless of their layer number.

 
Rigid Body Solver
    Changing the Rigid Body Solver attributes, adjusts the dynamic simulation.  

  • Step Size - this determines the number of times per second the rigid body calculations are performed. If your animation runs at 30fps, then each frame is roughly 0.03 seconds long. If the step size is 0.03 then rigid body calculations are performed once every frame.
  • Collision Tolerance controls the accuracy of collisions. The smaller the tolerance the more accurate and slower the calculations.
  • Solver Method allows you to choose between three methods.
    Midpoint - fastest but least accurate
    Runge-Kutta - slower speed better accuracy
    Runge-Kutta Adaptive - slowest but most accurate (is also the default)
  • Rigid Solver States - toggle on/off aspects of solving. If you are not using some of these states, it is best to turn them off in order to gain speed. State refers to the effect of fields, collisions, and constraints. It effectively turns off the solver all together.

  • Display options allow you to select what shows up in your window.
    When display label is on, the window labels al constraints and labels objects as active or passive.

Changing Between Active and Passive
    If you want to key an objects motion and then at a certain point allow dynamics to take over, then you can use
Bodies->Set Passive Key   OR
Bodies->Set Active Key
This will keyframe a change to passive or active at the current frame.
When changing from passive to active, the current motion is applied to the initial settings of the rigid body (maintaining motion).
When changing from active to passive, the motion does not carry over.

Using Multiple Solvers
    Multiple Solvers can be used to lessen the calculations Maya has to do. Suppose you have a bowling alley, there is no need to have one solver calculating all bowling lanes together, because they don't interact together. So one solver could be created per bowling lane, thus simplifying the work Maya has to do.
You can simple create more solvers by selecting
Solvers->Create Rigid Body Solver
When rigid bodies are created, they are assigned to the currently selected solver. Each rigid body can belong to only one solver at a time.
To change what solver an already created rigid body belongs to, type
rigidbody -edit -solver solvername
 
Rigid Bodies React to Fields

Fields are forces that can be used to animate the motion of particles, soft bodies, and rigid bodies.
There are two types of fields. Stand-Alone fields are independent fields that influence geometry and do not belong to a particular object. Object fields belong to an object and as that object moves so does the field. Object fields are typically applied to every vertex/CV
There are a number of fields that can be created to affect the rigid body simulation. Almost every field has standard parameters such as magnitude, attenuation, maximum affecting distance, and direction. Here are the fields available in Maya
  • Gravity Field - Simulates the earth's gravitational pull. It exerts force in one direction. This is a stand alone field
  • Newtonian Field - Pulls an object toward it. These are good for creating planetary motion. They can be either stand-alone or object fields.
  • Drag Field - exerts a friction on an object animated by dynamics. This is an object field.
  • Air Field - simulates the affects of moving air. Parameters include :
    wind - adjusts the wind applied to the entire field.
    wake - adjusts the affects of objects moving through the air field, thus causing them to create a wake.
    fan - can be placed to affect the air field. This works like wind only it emanates from a point, in a direction, at a specified angle.
  • Radial Field - pushes an object away or pulls an object towards it. These are good for creating effects like magnetic fields.
  • Uniform Field - is essentially a force in a direction.
  • Turbulance Field - this field causes irregularities in motion. They can be used to simulate the behavior of liquid or gaseous mediums.
  • Vortex Field - is a spiraling fields that can either pull things in or push things out in a spiraling motion. When used with particles you could create a tornado look.
The manipulator tools can be used to graphically adjust some of the fields attributes such as location and orientation, provided they are set to be visible.
 
Rigid Body Constraints

Rigid body constraints are used to restrict the motion of rigid bodies during a simulation. Constraints affect only rigid bodies and most affect only active rigid bodies. To create a constraint, select the rigid body that is to b constrained and select Bodies->Create Constraint (box). You can then specify the type of constraint to be used. There are a number of different constraints that can be used.
  • Nail - A nail constraint is created between an object and a point in space. It acts as though there is a metal rod connecting the object and the point.
  • Pin - constrains two rigid bodies to each other, creating a pivot joint in-between them.
  • Hinge - constrains rigid bodies like a pin, only the rotation of the joint is only along one axis, like the hinge on a door. Hinges can be created between one active/passive rigid body and a point, two active rigid bodies, or an active and passive rigid body.
  • Spring - a spring constraint acts as though it is a spring connected between two points. Springs can be created between one active/passive rigid body and a point, two active rigid bodies, or an active and passive rigid body. The spring has parameters such as:
    Stiffness - how rigid the spring is. The higher the number the more force for the same displacement.
    Damping - controls how fast the spring comes to rest. Rest length - allows you to specify the springs preferred length. The spring will exert force based on how far away it is from its preferred length.
  • Barrier - acts as an invisible plane with which rigid bodies can collide. Its location and orientation can be adjusted. It works with only one active rigid body, and does not work with passive rigid bodies.

The position and orientation of constraints can be adjusted using the manipulation tools. Multiple constraints can be used per object, but you must be careful not to create simulations where constraints fight each other. Page 187 of the Using Maya: Dynamics book briefly addresses this, and some potential fixes.
 
My advice on dynamics

  • Be aware of the units you are using when building a scene. If you are creating a scene where a gravity field is going to be used, it is good to create objects with realistic size. For example if you are working in inches and you create an apple that is 100 units tall, when gravity is applied, The apple will fall as though it were a giant 100 inch apple. Gravity can be adjusted but to remove some of the guesswork it is good to build with realistic units.
  • When using dynamics you can use low tessellation geometry for the dynamics solving and high tessellation geometry for the rendering. However if you parent the geometry together, you cannot turn off the primary visibility of the low without in turn, turning off the visibility of the high. So when rendering you simply need to make an invisible material and turn off the shadow casting and catching of the invisible low tessellation objects.
  • By varying slightly the mass of collision objects and moving then so they are not perfectly ordered at the beginning of the simulation, you can increase the realism of the simulation.
    Simulation with same mass and orientation
    Simulation with different mass and orientation
    The difference in mass and orientation makes the motion just a little more complex.
  • It is possible to use soft bodies, rigid bodies, and particles together to create some impressive effects.
 
Tutorials on the Web


Chain Link Tutorial from the Maya Assistant
Pendulum Tutorial from the Maya Assistant
Colliding SoftBodies with RigidBodies from the HIGHEND3D site