Chapter 38. Simulating Physics-Based Motion with reactor

When you speak of reactor in Max, you really are speaking of physics. Physics is one of the coolest arms of science because it deals with the science of matter and energy and includes laws that govern the motions and interactions between objects. For animators, this is great news because what you are trying to do is to animate the motions and interactions between objects.

So, should all animators study physics? The answer is absolutely. Understanding these laws through study and experience will sharpen your animating skills. But you can also take advantage of the work that other animators have done in understanding the laws of physics and turning them into a product that ships with Max. The other animators are a group called Havok, and the product is reactor.

The Havok physics engine included in Max is the same engine commonly used in games to simulate game-world physics such as the reactions in Value's Half Life 2.

Using reactor, you can simulate many physical properties and automatically capture keyframes as the objects interact. It's like getting a physics degree for free.

The reactor menu includes everything you need to access the reactor physics simulation engine. With reactor, you can define objects as rigid bodies like chairs or bowling balls or as soft bodies like stuffed animals. You can also define specialized objects, including cloth and rope.

After physical properties are defined, you can define physical forces to act on these objects and simulate the resulting animation. Not only does reactor make difficult physical motions realistic, but it also is fun to play with.

Understanding Dynamics

Dynamics is a branch of physics that deals with forces and the motions they cause, and regardless of your experience in school, physics is your friend—especially in the world of 3D. Dynamics in Max can automate the creation of animation keys by calculating the position, rotation, and collisions between objects based on physics equations.

Consider the motion of a simple yo-yo. Animating this motion with keys is fairly simple: Set rotation and position keys halfway through the animation and again at the end, and you're finished.

Now think of the forces controlling the yo-yo. Gravity causes the yo-yo to accelerate toward the ground, causing the string to unwind, which makes the yo-yo spin about its axis. When it reaches the end of the string, the rotation reverses and the yo-yo rises. Using Gravity and Motor Space Warps, you can simulate this motion, but setting the keys manually is probably easier for these few objects.

But before you write off dynamics, think of the motion of popcorn popping. With all the pieces involved, setting all the position and rotation keys would take a long time. For this system, using dynamics makes sense.

Dynamic tools let you specify objects to include in a simulation, the forces they interact with, and the objects to be involved in collisions. After the system is defined, the Dynamics utility automatically calculates the movement and collisions of these objects according to the forces involved, and then it sets the keys for you.

Note

Max includes several different dynamic tools, including dynamic objects such as a spring and damper, dynamic material properties found in the Material Editor, specialized dynamic Space Warps, and the Dynamics utility. Before investing too much time in the Dynamics utility, please realize that for dynamic simulations, the reactor features are more robust and easier to set up. The Dynamics utility still exists only for backwards compatibility.

Using reactor

The reactor plug-in was developed by a company named Havok. reactor is a complex piece of software with a huge assortment of features that enable you to define physical properties and forces and have the scene automatically generate the resulting animation keys as the objects interact while following the laws of physics.

Note

Be aware that the reactor plug-in is different from the Reaction controller, discussed in Chapter 21, "Animating with Constraints and Controllers."

The reactor plug-in interface exists in the Utilities panel and is one of the default utilities, but you can also access it from the reactor menu and the reactor toolbar, shown in Figure 38.1. The reactor menu and the reactor toolbar provide a quick and easy way to access the various reactor elements. For example, clicking the Rope Collection button opens the Helper category in the Command Panel, selects the reactor subcategory, and selects the RP Collection button.

Use the reactor toolbar to define physical object properties.

Figure 38.1. Use the reactor toolbar to define physical object properties.

The reactor process

Before getting into the details of reactor, I want to briefly explain the process involved in using reactor. reactor works with geometry that is defined with certain physical properties. After these properties are defined, the reactor engine can take over and determine how all the various objects interact with one another. In the reactor utility, you can select to use the reactor version 1 engine (Havok 1) or the reactor version 3 engine (Havok 3). Version 3 of the reactor engine is much more accurate and considerably faster than version 1, but if your simulation includes cloth, rope, or soft body objects, then you need to stick with version 1.

Within the Utilities panel are several rollouts of options for controlling the simulation. In the Preview & Animation rollout, you can set the simulation range, number of frames, and substeps per key. In the Havok 1 World rollout, you can set the global gravity values, the World Scale, and Collision Tolerance. The Add Deactivator option lets you remove objects from the simulation that are considered at rest. This keeps them from wiggling around, which happens when they are still part of the simulation. The Short and Long Frequency values help determine when an object is at rest.

If the Havok 3 option is selected, then you can choose to compute the object's motion on a Continuous basis or on a Discrete basis, which only checks the object motion at the beginning and end of each step and interpolates between these two states. You also can set a Maximum Linear Velocity for objects and a Stiffness value.

The Collisions rollout lets you specify how collisions are stored. By storing collisions, you can trigger an event to make particles show sparks, but enabling the storing of collisions can slow down a simulation. A window for Defining Collisions lets you ensure that certain objects won't collide and others will.

The Display panel lets you specify a camera, clipping planes, lights, and textures to use in the Preview window for displaying the simulated objects.

The Utils panel includes an Analyze World button that you can use before starting a simulation. There are also controls for reducing the total number of keys and for testing the convexity of objects.

Defining geometry with physical properties happens in several different ways. Objects can be added to a collection. A collection is a type of reactor object that has several inherited physical properties, such as a Rigid Body collection. Objects can also be linked with reactor objects such as a Spring or Motor. These objects are affected by forces that are preset for the different reactor objects. Finally, you can set properties using the Object Property rollout, which lets you define properties such as mass, friction, and elasticity. After all the objects are defined and attached to the correct reaction collection or object, you can open a Preview window that lets you see how the object will react under the current forces. You can also interactively play with the various objects in the Preview window.

When you're comfortable with the animation, the reactor

The reactor process

Tutorial: Filling a glass bowl

Imagine trying to animate a bunch of marbles falling into a glass bowl. If you were using keyframes, determining whether an object overlaps another would be difficult, but with this quick example, you see the power of reactor.

To animate marbles falling into a glass bowl, follow these steps:

  1. Open the Glass bowl of marbles.max file from the Chap 38 directory on the DVD.

    This file includes a glass bowl and several marbles positioned above its opening.

  2. Select reactor

    Tutorial: Filling a glass bowl
  3. In the Select Objects dialog box, click the Select All button and then the Select button to select and make all objects in the scene rigid body objects. Then right-click to exit Rigid Body Collector mode.

  4. Select the Box and sphere objects that make up the floor and bowl, select reactor

    Tutorial: Filling a glass bowl
  5. Select all the marble objects in the scene, and set the Mass value to 5.0.

  6. Then select reactor

    Tutorial: Filling a glass bowl
  7. If the animation looks fine, select reactor

    Tutorial: Filling a glass bowl

Figure 38.2 shows the bowl full of marbles positioned using reactor.

reactor can compute all the collisions between all these marbles.

Figure 38.2. reactor can compute all the collisions between all these marbles.

Using reactor Collections

One of the first steps in creating with a simulation is defining the object properties. For example, a simple sphere object in Max could represent a bowling ball, an orange, or a tennis ball. Each of these objects responds very differently when being animated to drop on the floor.

In reactor, the simulation identifies the various objects by the type of collection that it is part of. reactor has five types of collections: Rigid Body, Cloth, Soft Body, Rope, and Deforming Mesh, as described in Table 38.1.

Table 38.1. reactor Collections

Toolbar Button

Name

Description

reactor Collections

Rigid Body collection

Rigid bodies resist a force.

reactor Collections

Cloth collection

Cloth objects flow and bend to all forces.

reactor Collections

Soft Body collection

Soft bodies flex when they come in contact with a force.

reactor Collections

Rope collection

Rope objects support tension but not compression.

reactor Collections

Deforming Mesh collection

Meshes can be deformed by forces.

Rigid bodies are objects that keep their shape when pushed; soft bodies deform when pushed. Cloth and rope are intuitive, and deformable meshes are any object with keyed animation, including bones and skin systems.

Note

Remember that cloth, rope, and soft body objects are only as flexible as the number of segments that make up the object. For example, a rope made from a spline with three vertices bends only in the middle.

All objects that are included in one of these collections behave with similar properties. To include a collection in the scene, select the reactor

reactor Collections
The gizmo icons for each of the collections

Figure 38.3. The gizmo icons for each of the collections

Collection gizmos in the scene are not rendered and appear red when first created. When selected, the gizmo appears white; when an object has been added to the collections, it appears blue. This makes it easy to see which collections are empty.

After a collection is added to the scene, you can use its Pick button in the Properties rollout to select a single object to the collection. The cursor changes into crosshairs when it is over an object that can be added to the collection. Or you could click the Add button to open a Select Object dialog box where you can select objects from a list. The collection objects are then displayed in a list found in the Properties rollout. Clicking the highlight button in the Properties rollout briefly turns white all objects that are part of the collection.

Warning

A single object can be added to multiple collections, but this causes a warning to appear when you try to preview the animation.

If an object is selected before you create a collection icon, then the selected object is automatically added to the collection and the collection icon is positioned at the Pivot Point of the selected object or objects.

Collection modifiers

If you tried several times to add an object to a Cloth collection with no luck, then this section is for you. Before you can add objects to the Cloth, Rope, or Soft Bodies collections, you need to apply the Cloth, Rope, or Soft Body modifiers to the object. To apply a modifier to an object, select the object in the viewport, choose reactor

Collection modifiers

Note

The Rope modifier can be applied only to splines or shapes.

Table 38.2. reactor Modifiers

Toolbar Button

Name

Description

reactor Modifiers

Cloth Modifier

Allows objects to be simulated as cloth

reactor Modifiers

Soft Body Modifier

Allows objects to be simulated as soft bodies

reactor Modifiers

Rope Modifier

Allows objects to be simulated as rope

Each of the reactor modifiers has a Vertex subobject mode available in the Modifier Stack. Selecting a vertex allows you to give it different physical properties from the rest of the vertices. For example, you could select the vertices at one end of a rope to have a higher Mass value where it connects with a hook. This end would then fall under gravity before the other end.

Setting object properties

After collections have been added to the scene and objects have been added to the collection, you can define the physical properties using the Property Editor, shown in Figure 38.4. You can open the Property Editor by selecting reactor

Setting object properties
The Property Editor can set the physical properties for geometric objects included in the scene.

Figure 38.4. The Property Editor can set the physical properties for geometric objects included in the scene.

Mass, friction, and elasticity

The Mass property defines how heavy the object is. For example, a bowling ball has a higher mass value than a Ping-Pong ball. The Elasticity value defines how springy the object is; a tennis ball is more elastic than a marble. The Friction value defines how resistant the object is to rolling or sliding along the floor. For example, a brick has a higher friction value than an ice cube.

Tip

A rigid body with a Mass value of 0 is left out of all calculations and remains stuck in the simulation.

The Property Editor also includes several other options. The Inactive option removes the object from the simulation calculations. The Disable All Collisions option causes the object to not collide with other objects. The Unyielding option makes the object immovable and is good to use for floor and wall objects, and the Phantom option makes objects so they have no impact on other objects in the scene.

The Shell value defines an additional radius that surrounds convex shapes and is used for collision detection. If you specify a shell value, the simulation runs much more quickly and the likelihood that objects will interpenetrate each other is much less. The Penetration value is the amount of penetration that is allowed between objects. By providing a non-zero value, the simulation can be solved much more quickly. The Quality settings let you set how important the object's motion is to the animation. The options include Debris, for objects of low importance; Moving, for objects of medium importance; Critical, for objects that should never penetrate other objects; and Bullet, for objects that move rapidly. The Shell, Penetration, and Quality values work only with the version 3 reactor engine.

Defining collision boundaries

Another common property that you can set pertains to how the object deals with collision detection. You can select the volume to use to determine when two objects collide with each other. If this sounds a bit funny because any collision volume that doesn't use the actual mesh would be inaccurate, then you need to realize that a complex simulation with lots of collisions of complex objects could take a long time to compute. If reactor has only to compute collisions based on the object's bounding box instead of the actual mesh object, the simulation runs much more quickly and the inaccuracies aren't even noticeable.

Before deciding on the collision boundary to use, you need to determine whether an object is convex or concave. A concave object is one that you can penetrate with a ray and cross its mesh boundary only twice. Convex objects require more than two crossings with an imaginary ray. You can test whether an object is convex using the reactor

Defining collision boundaries

A convex object can use any of the options found in the Simulation Geometry rollout of the Object Properties dialog box, including Bounding Box, Bounding Sphere, Mesh Convex Hull, Proxy Convex Hull, Concave Mesh, Proxy Concave Mesh, or Not Shared as its collision boundary. If a Proxy option is selected, you can select the proxy object using the Proxy button found in the Simulation Geometry rollout. A proxy is a just a low-resolution version of an object used here for collision detection.

Note

The Material Editor includes a Dynamics Properties rollout with values for Bounce Coefficient, Static, and Sliding Friction. These values are used with the Dynamics utility but are not used with the reactor engine.

Modifier properties

In addition to the properties found in the Property Editor, objects that have one of the reactor modifiers applied to it have additional properties that are specific to the collection types. These properties show up in the Modify panel when the object is selected.

Note

All the modifiers include an option to Avoid Self-Intersections. Because these object types are flexible, they often move and bunch up together. This option prevents an object from turning inside out and intersecting with itself.

For the Cloth modifier, these additional properties include Mass, Friction, Relative Density, and Air Resistance. You can also select to use the Simple Force Model or the Complex Force Model, which enables Stretch, Bend, Shear, and Damping values. You can also define a Fold Stiffness, which determines how stiff the fold in the cloth is.

Note

When similar properties exist for an object in the Property Editor and the Modify panel, the value in the Modify panel takes precedence. Actually, the properties in the Property Editor apply only to rigid body objects.

The Soft Body modifier adds value for Stiffness and Damping to the Mass and Friction values. You can also select to have the object deform using a Mesh-based or an (Free Form Deformer) FFD-based algorithm. The FFD-based algorithm uses control points and is a simpler method that doesn't require as much memory.

The Rope modifier includes Mass, Thickness, Friction, and Air Resistance values. You can also select the rope to be a Spring or Constraint type. Spring ropes act like bungee cords or rubber bands.

Tutorial: Throwing a shirt over a chair

In the preceding example, you looked at something that reactor made much easier, but in this example, you see some animations that would be impossible without reactor. Cloth deformation is very difficult to animate, but it is much easier if you correctly apply the laws of physics to describe this motion. In this simple example, you throw a stiff shirt over a stationary chair to see how it reacts.

To animate cloth falling over a hard object, follow these steps:

  1. Open the Shirt over chair.max file from the Chap 38 directory on the DVD.

    This file includes a chair object and a shirt that is nothing more than an extruded shape that has been sufficiently subdivided.

  2. Select reactor

    Tutorial: Throwing a shirt over a chair
  3. Select the chair and floor object, and choose reactor

    Tutorial: Throwing a shirt over a chair
  4. Select the shirt object, and choose reactor

    Tutorial: Throwing a shirt over a chair
  5. With the shirt object still selected, choose reactor

    Tutorial: Throwing a shirt over a chair
  6. Now preview the animation before computing it. Select reactor

    Tutorial: Throwing a shirt over a chair
  7. Select reactor

    Tutorial: Throwing a shirt over a chair

Figure 38.5 shows one frame of the finished animation.

reactor can be used to simulate cloth falling realistically over a chair.

Figure 38.5. reactor can be used to simulate cloth falling realistically over a chair.

Creating reactor Objects

In addition to collections, reactor also includes several default objects that react with the scene in unique defined ways. These objects can be created using the reactor

Creating reactor Objects

The default objects include Spring, Plane, Linear Dashpot, Angular Dashpot, Motor, Wind, Toy Car, Fracture, and Water, as listed in Table 38.3.

Table 38.3. reactor Objects

Toolbar Button

Name

Description

reactor Objects

Spring

Acts to bring connected child and parent objects closer together

reactor Objects

Plane

Adds a solid plane object to the scene

reactor Objects

Linear Dashpot

Acts to limit linear motion between connected child and parent objects

reactor Objects

Angular Dashpot

Acts to limit angular motion between connected child and parent objects

reactor Objects

Motor

Used to add angular force to the scene

reactor Objects

Wind

Used to add linear force to the scene

reactor Objects

Toy Car

Simulates a simple car with rotating wheels and linear motion

reactor Objects

Fracture

Identifies objects that can be broken into pieces

reactor Objects

Water

Adds water to the scene that conforms to concave surface

The gizmos for these objects, like the collection gizmos, appear red when first created for most of these objects and then turn white when selected, and blue when connected, to a geometry object. Figure 38.6 shows the gizmo icons for each of these reactor objects.

Most of these objects need to be associated with an object to be included in reactor. For example, the Toy Car reactor object must be connected to a geometry object for its chassis and up to four geometry objects for its wheels. This is done by clicking on the respective buttons in the Properties rollout and selecting the geometry object in the viewport. For example, you can connect a Spring object to both a Child and a Parent object. Other reactor objects, like the Plane and Wind objects, do not need to be connected to an object to work.

The gizmo icons for each of the reactor objects

Figure 38.6. The gizmo icons for each of the reactor objects

Springs and dashpots

The Spring and Dashpot objects can be linked between a child and parent object. Simply select the Child button in the Spring Properties rollout, and click the scene object to make the Spring's child. If no parent is selected, the Spring is connected between the child object and the Spring object gizmo's location.

The Align options let you move the Spring to the Child or Parent Body and to use the Child or Parent Space. Selecting the Each Body option positions the Spring object equally spaced between the child and parent.

For the Spring object, you can set the Stiffness, Rest Length, and Damping values and whether it acts on Compression or Extension. The farther the child and parent objects are from the Spring object icon, the stronger the pull toward the icon, so changing the Rest Length value to a small value causes the two objects to be pulled quickly together.

Note

The child and parent objects still need to be added to a collection such as the Rigid Body collection to be used in the simulation.

Dashpot objects work in a similar manner to Springs. They can be linked to child and parent objects and include values for Strength and Damping. Linear dashpots force the parent and child objects to maintain their position as if they were connected by a springy bar. The Angular dashpot forces two objects to retain the same orientation; rotating one causes the other to rotate the same way.

Plane

A Plane object creates a solid wall that an object cannot penetrate if it belongs to the Rigid Body collection, but only the face with the normal extending from it is solid. This object can be scaled, and its only property is a Show Normal option. Also note that this object is not renderable and is not visible in the Preview window.

Motor and Wind

The Motor object can be used to spin objects belonging to the Rigid Body collection in the scene. For these objects, you can select a Rotation Axis value, as well as Angular Speed and Gain values.

The Wind object can be used to add a linear force to the scene. The force is directed globally in the direction that is displayed on the Wind object icon, so you need to be careful to place this icon in the correct viewport in order to get the wind blowing in the right direction. The strength of the wind is determined by the Wind Speed value. The wind's ability to move objects depends on its strength and the object's Mass value. Heavier objects are harder to blow away.

The Perturb Speed option lets you make the wind gusty. The Variance is how different its strength is from the base value, and the Time Scale determines how often these gusts take place. You can also set a Ripple option to cause a variance in wind strength Left/Right, Up/Down, or Back/Forward with a given Magnitude and Frequency. You can also perturb (or change) time and see the results.

The Use Range lets you specify a range on which the wind has an effect. All objects within the set range are influenced by the wind, but objects beyond the range are not. The Enable Sheltering option lets objects positioned behind other objects be sheltered from the wind. You can choose which objects the wind can affect, including Rigid Bodies, Cloth, Soft Bodies, and Ropes.

Toy Car

The Toy Car reactor object is a specific object type that simulates a driving car that produces linear motion by rotating wheels. For this object, you can select a Chassis object that represents the car body and pick a list of objects to act as wheels. For this system, you can specify Angular and Linear Strength values and a Suspension value.

You can also specify the car's orientation using the icon (an arrow points in the direction the car will travel) or using a Common Local Orientation. For the wheels, you can specify to Allow Wheel Penetration, which lets the system have some give as it moves over a rough surface, and whether the wheels spin. To give the car some power, you can set the Angular Speed and Gain of the wheels.

For the reactor version 3 engine, an additional set of parameters is available.

Tip

If you use the reactor version 3 engine with the Toy Car object, then a new set of parameters for controlling its strength, suspension, and breakable threshold are available.

Fracture

The Fracture reactor object offers a way to have reactor objects blown apart. The Properties rollout includes a list of Pieces that are to be involved in the fracturing. If you select a Piece from the list, you can designate it as Broken, Normal, Unbreakable, or Keystone, or to Break at Time. The Now button sets the break time to the current frame.

The Use Connectivity option enables linked objects to stay together, such as two parts connected to a spring. You can also select to Break On and set an Impulse value or a Velocity value. The Energy Loss is the amount of energy lost with every collision.

Tutorial: Smashing a gingerbread house

It doesn't matter how many times your mother asks you to not play ball in the house, you always forget. And Murphy's Law says that you'll forget at just the wrong time, like when the gingerbread house has just been finished.

To smash a gingerbread house, follow these steps:

  1. Open the Smashed gingerbread house.max file from the Chap 38 directory on the DVD.

    This file includes a gingerbread house model created by Viewpoint Datalabs.

  2. Select reactor

    Tutorial: Smashing a gingerbread house
  3. Select reactor

    Tutorial: Smashing a gingerbread house
  4. Select the "ground" object in the scene, choose reactor

    Tutorial: Smashing a gingerbread house
  5. Select reactor

    Tutorial: Smashing a gingerbread house

    The ball falls, and the house explodes into pieces.

  6. Select reactor

    Tutorial: Smashing a gingerbread house

Figure 38.7 shows the gingerbread house as it fractures into pieces.

The fracture object in reactor can be used to compute realistic explosions.

Figure 38.7. The fracture object in reactor can be used to compute realistic explosions.

Water

The Water reactor object creates a realistic surface that acts and behaves like a liquid. For water, you can specify its size in X- and Y-coordinate values and its Subdivisions. Be aware that with inadequate subdivisions, the water does not work realistically. The Landscape option lets you select a surround object that acts like an object with which the water interacts.

You can also set the Wave Speed, Minimum and Maximum Ripple sizes, Density, Viscosity, and Depth. If the Depth option is disabled, then the water has only surface effects.

reactor water is applied as a Space Warp. Space Warps aren't rendered, so to see the water surface, you need to create a Plane object and bind it to the Space Warp using the Bind to Space Warp icon on the main toolbar.

Tutorial: Working with water

One of the coolest features of reactor is its ability to create and simulate the effects of water. Before you can use water, you must have a model that can hold water.

To use reactor to create a body of water, follow these steps:

  1. Open the Pool of water.max file from the Chap 38 directory on the DVD.

    This file includes a pool to hold water created from primitives, along with three spheres of different mass.

  2. Select reactor

    Tutorial: Working with water
  3. Select reactor

    Tutorial: Working with water
  4. Select the left sphere in the Front viewport, and open the Property Editor with the reactor

    Tutorial: Working with water
  5. Check the animation in the Preview window by selecting reactor

    Tutorial: Working with water
  6. Record the animation keys with the reactor

    Tutorial: Working with water
  7. Select Create

    Tutorial: Working with water

Figure 38.8 shows the simulation in the Preview window. Notice how the mass values determine whether the sphere floats or sinks.

Depending on the mass property, objects sink or float.

Figure 38.8. Depending on the mass property, objects sink or float.

Calculating and Previewing a Simulation

Although you've already had some experience with the Preview window in the examples, more controls are available than just playing the animation. To preview the simulation, select reactor

Calculating and Previewing a Simulation

Warning

The Preview window runs only if the OpenGL or the Direct3D display drivers are used. The window uses OpenGL by default, or you can set it to use DirectX with the DirectX option in the Display rollout. The display driver being used is displayed in the title bar of the Preview window.

Using the Preview window

The fun part of the preview window is that you can interact with the objects. Right-clicking (when the simulation is playing) and dragging on the object moves it. If you find a position that you want to capture for Max, you can use the MAX

Using the Preview window

Tip

If the reactor version 3 engine is selected, then you can interact with the objects in the Preview window by holding down the Spacebar and dragging the mouse.

The Preview window is a fun place to play with a simulation.

Figure 38.9. The Preview window is a fun place to play with a simulation.

If you want to reset the animation to its starting positions, you can use the Simulation

The Preview window is a fun place to play with a simulation.

The Performance menu includes options for setting the frames per second and the number of substeps used to compute the simulation. For most animations, the default of ten substeps is sufficient, but if you want Max to spend more time computing an accurate solution, you can try a higher substep value.

Warning

Don't use a high substep value with water.

Creating animation keys

To compute the animation keys for the simulation, select the reactor

Creating animation keys

Note

After you've clicked the Create Animation menu command, a warning appears stating that the operation cannot be undone.

Analyzing the scene

After the Preview window is opened, a warning dialog box appears if the scene has any errors or warnings that could cause trouble with the simulation. It also warns of unrealistic data, such as property settings that are too high or too low.

Tip

The one warning that isn't included in the warning dialog box is if objects have no Mass value. If objects in your simulation are just sitting there, then make sure that they have a Mass value.

If you want to check your scene without opening the Preview window, you can use the reactor

Analyzing the scene

Tutorial: Dropping a plate of donuts

All the great books have an element of tragedy, so consider a policeman carrying a dozen donuts on a plate when he stumbles and drops the plate. Donuts everywhere, how tragic! This animation sequence would be difficult or at least time-consuming if it were not for reactor.

To use reactor to animate a falling plate of donuts, follow these steps:

  1. Open the Falling plate of donuts.max file from the Chap 38 directory on the DVD.

    This file includes a simple plate of donuts created from primitives.

  2. Select the reactor

    Tutorial: Dropping a plate of donuts
  3. Select the Torus objects, and choose reactor

    Tutorial: Dropping a plate of donuts
  4. Then select reactor

    Tutorial: Dropping a plate of donuts
  5. Select reactor

    Tutorial: Dropping a plate of donuts
  6. The last step is to execute the simulation: Select the reactor

    Tutorial: Dropping a plate of donuts

Figure 38.10 shows the upturned plate of donuts.

Animating these falling donuts, simulated as soft body objects, was easy with reactor.

Figure 38.10. Animating these falling donuts, simulated as soft body objects, was easy with reactor.

Constraining Objects

Constraints are ways to limit the amount of motion that an object can do. Using constraints can help control objects in the scene as they interact with other objects. Perhaps the simplest constraint isn't a constraint at all. If you enable the Unyielding option in the Property Editor, the rigid body is set so that won't move and is a good option for the ground plane. It also allows hand-keyed animated objects to interact with rigid body objects instead of relying on the dynamics engine.

Other constraints are found in the reactor

Constraining Objects

Table 38.4. reactor Constraints

Toolbar Button

Name

Description

reactor Constraints

Constraint Solver

Contains all active constraints used in the scene

reactor Constraints

Rag Doll Constraint

Causes a model to act as a human figure

reactor Constraints

Hinge Constraint

Allows angular rotation like a hinge

reactor Constraints

Point-Point Constraint

Links two points together; good for rope ends

reactor Constraints

Prismatic Constraint

Used to constrain the motion of two rigid bodies to a single axis with no rotation

reactor Constraints

Car-Wheel Constraint

Causes a car to move linearly as a wheel object is rotated

reactor Constraints

Point-Path Constraint

Limits a point to move only along a path

After a Constraint object is added to the scene, you can select the objects that will be included as child and parent objects using the buttons in the Properties rollout. The Properties rollout also includes buttons to align the constraint to the Child Body, Parent Body, Child Space, or Parent Space. For each constraint, you can set the Strength and Tau of the connection. This determines how strong the link is and how easily broken. In addition to the Strength and Tau values, you can set Limits and allow the hinge to be Breakable under a defined Linear or Angular force value. The Threshold value defines the breakability of the constraint. Higher Threshold values make it less likely to break. The Threshold value works only with reactor, version 3.

When a constraint's Child is first selected, the Constraint's icon is positioned at the pivot point of the child object. If you look in the Modifier Stack for the Constraint object, you'll find subobject modes for Child Space and Parent Space. If you select these subobject modes, you can change the position of the constraint's child and parent objects.

Using a Constraint Solver

In order to use most constraints, you need to add a Constraint Solver to the scene. Then you can use the Modify panel to add Constraints to the list to be solved. The Constraint Solver needs to know about any Rigid Body Collections that are attached to any Constraints in the scene. To identify all the Constraints that are part of the Constraint Solver, click the Highlight button.

Tip

If the simulation includes any constraints that the Constraint Solver doesn't know about, the Constraint Solver icon appears red in the viewports.

Rag Doll constraint

The Rag Doll constraint defines all the joint limits common in a human figure. It can be used to animate a lifeless body colliding with various rigid body objects. Using the Rag Doll constraint, you can manually define how the body joints can twist, rotate, and move.

These joints are fairly common for human bodies. Autodesk has created a script to create a human body proxy that creates a rag doll with the correct constraints already defined. The script is named rctRagdollScript.ms. It can be found in the scripts directory where 3ds Max is installed.

You can execute this script by opening the Utilities panel, clicking the MAXScript button, and clicking the Run Script button. This opens a file dialog box. Locate the script and click Open, and the script runs. Running this script opens the Rag Doll dialog box, shown in Figure 38.11. Using this dialog box, you can provide a Name for the rag doll and set its Height and the number of Vertebra. The Create Humanoid button makes the rag doll appear in the viewports.

Once positioned, you can press the Constrain Humanoid button in the Constrain Humanoid rollout. This adds all the necessary constrains to the rag doll.

Tip

You can use the rag doll script to place reactor constraints on a Biped object.

Fully constrained humanoid figures can be created using the rctRagdollScript.ms script.

Figure 38.11. Fully constrained humanoid figures can be created using the rctRagdollScript.ms script.

The Point-to-Point constraint lets you attach two objects together by a common point. The attach point is the pivot point of the child and parent objects. It can be used to animate a lifeless body colliding with various rigid body objects. Using the Rag Doll constraint, you can manually define how the body joints can twist, rotate, and move.

Tutorial: Swinging into a wall

Playing with the rag doll object is just plain fun. Remember that in the Preview window you can use the right-click button to throw the doll around. For this example, you use a couple of Point-to-Point Constraints along with a Rag Doll constraint to create a simple scene where the rag doll swings from a rope into a brick wall.

To animate a rag doll swinging on a rope, follow these steps:

  1. Open the Swinging into a wall.max file from the Chap 38 directory on the DVD.

    This file includes a simple scene consisting of several Boxes, a Cylinder for the rope, and a brick wall.

  2. Open the Utilities panel, and click the MAXScript button. Click the Run Script button in the MAXScript rollout. In the file dialog box, locate the Scripts directory where Max is installed. Select the rctRagdollScript.ms file, and click the Open button. The script file opens in a MAXScript window. In the MAXScript window, select the File

    Tutorial: Swinging into a wall
  3. In the Rag Doll panel that appears, open the Create Humanoid rollout and click the Create Humanoid button. Then move the Rag Doll panel to the side, but don't close it. Select the rag doll that appears at the origin, and move it so that one of its hands is positioned close to the end of the Cylinder object.

  4. In the Rag Doll panel, open the Constrain Humanoid rollout and click the Constrain Humanoid button. This automatically adds all the needed constraints for the rag doll. Then close the Rag Doll panel.

  5. Select the long Cylinder object, choose reactor

    Tutorial: Swinging into a wall

    This defines where the two objects will be attached.

  6. Repeat Step 5 to create a Point-to-Point Constraint where the Cylinder touches the roof object with the Cylinder as the Child object and the roof as the Parent object. With the second Point-to-Point Constraint selected, click on the Align Spaces to Parent Body button in the Modify panel.

  7. Press the H key to open the Select Objects dialog box, and select the RagdollRBCollection object. Then click the Add button in the RB Collection Properties rollout. Click the All button in the Select Rigid Bodies dialog box, and click Select. Repeat this step for the RagdollCSolver icon to add the two new Point-to-Point Constraints.

  8. Select all three Box objects in the scene, and choose reactor

    Tutorial: Swinging into a wall
  9. Select reactor

    Tutorial: Swinging into a wall

Figure 38.12 shows the swinging rag doll.

Using constraints gives you control over the animation motion.

Figure 38.12. Using constraints gives you control over the animation motion.

reactor Troubleshooting

reactor identifies problems before you try to preview or compute the simulation. These problems are displayed in an error window. The following are some common errors that you can avoid. Use the Analyze World button to look for warnings.

  • Don't use the default Plane primitive: reactor complains if the plane object is coplanar. The problem is that without any depth, reactor can't accurately compute collisions. Instead, use a Box primitive or use reactor's Plane Primitive object (found in its toolbar). However, you can use a plane object if you make it a Concave Mesh.

  • Watch for low Mass values: reactor complains if the Mass value for any objects is too low. To fix this problem, increase the Mass value for the identified object.

  • Don't have interpenetrating objects: Objects that intersect cause an error in reactor. Make sure that none of the objects intersect with each other.

  • Build all reactor objects to scale: reactor tends to work well when all objects are within one meter of each other. Objects that are too small or too big tend to have issues with collisions.

Summary

This chapter covered the basics of animating a dynamic simulation using the reactor. In this chapter, you accomplished the following:

  • Experimented with the reactor plug-in

  • Worked with collections

  • Applied reactor modifiers

  • Used reactor objects

  • Previewed reactor animations

  • Used constraints

The next chapter covers the dynamic abilities of Max's hair and cloth systems.

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

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