Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design

📄 Contents

  1. In This Chapter
  2. Reactor: Planning the Attack
  3. Summary
  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Reactor: Planning the Attack

As with so many aspects of computer animation, preplanning the attack on a challenge can help you get the job done in a cost-effective manner. With a Reactor scene, visualizing ahead of time what you would like to see as a result and getting it down in a storyboard is paramount; then be prepared to spend time tweaking the Dynamics simulation parameters to get as close as you can to your expectations.

The process is based on physics, and you have about as much true control with Reactor as you do rolling a boulder down a hillside in real life. You can hope for a certain outcome, but must be prepared for some unexpected events along the way. Even small changes in the weight of an object, the friction of a surface, or the strength of the gravitational pull can have profound effects on the Dynamics simulation's end result.

Using small scenes with efficient mesh objects is an essential start. The more faces and vertices your scene has, the more possible collisions you must account for, and the longer the process will take. Only the objects directly involved in the collisions should be included in the Reactor collections, and when you have complex mesh objects, you should use simple proxy objects that define the boundaries for collision detection with no extraneous detail.

To increase your efficiency and free more computer resources, background images are often a good means of eliminating geometry from your scene while retaining the look of a complete scene. Background images are an entry-level step into another sophisticated special-effects science called digital compositing. Background images enable you to composite your current 3D scene atop a previously rendered image or photographic plate. Many complex productions consist of multiple layers combined with masks and image-processing tools.

Reactor: Catching Barrels in a Net

To add a little more life to your street scene from Chapter 2, "Modeling: A Medieval Street Scene," you will use the new Reactor feature to set up a collision detection simulation that catches the barrel fired from the catapult in a net and drops it to the street.

Reactor collision detection can require a lot of computer resources, so optimizing the process where you can is imperative. The buildings along the street are not involved directly with the collisions, so you will learn to use a rendered image of the street scene as a background image, with only the necessary mesh objects—the net, the catapult, and the barrel—in the foreground. The street, however, is part of the collision because the barrel drops from the net and bounces on the street cobblestones. You will take advantage of a special material called Matte/Shadow that always lets the background show through objects that have this material applied to give the illusion that the objects are in the street scene. This material eliminates the need for the street mesh object yet gives the appearance of a street surface for the collisions.

The net will be a Plane primitive that Reactor treats like a cloth object; to make it look like a net, you'll apply a material with Wire attributes enabled. The wire material renders only the visible edges of the segmented plane with a thickness you define. The net will seem to be suspended from the buildings by rigid rods; the rods are not actually part of the Reactor simulation, but the net must be anchored to the ends of the rods. To do this, you'll assign the Cloth modifier to only selected vertices. The unselected vertices are not part of the simulation, so they will remain fixed in space.

Last, the barrel must have a certain velocity and mass when it hits the net. If it is moving too fast or if it is too heavy, it will pass through the net. If it's moving too slow or if it is too light, gravity will pull it to the road before it hits the net. To achieve the correct velocity and mass, you will set the barrel's initial velocity by animating it with Set Key mode for a few frames, and then set the Reactor simulation to calculate from that point onward.

Exercise 13.1: Setting the Scene

  1. From the CD-ROM, open the Reactor_net01.max file. Choose File, Save As from the menu, and save the file to a subdirectory on your hard drive with the name Reactor_net02.max. The scene contains a catapult, a barrel, a net with four supporting rods, and a box called Street. Figure 13.1 shows the rendered Camera01 viewport.

On the CD

exercises\CH13\Reactor_net01.max

Figure 13.1 The scene with a catapult, a barrel, a net, support rod, and a box rendered against a black background.

  1. You will learn to apply a background image to the rendered image as an environment map, and then use the map as a viewport background. Choose Rendering, Environment from the main menu. In the Environment dialog box, Common Parameters rollout, click the None button for the Environment map. In the Material/Map Browser, double-click Bitmap, and in the Select Bitmap Image File dialog box, double-click Reactor_background.png in exercises\CH13\ on the CD-ROM. Close the Environment dialog box.

On the CD

exercises\CH13\Reactor_background.png

TIP

You might have noticed the cyan and orange rectangles in the Camera01 viewport. They indicate safe frames, areas that prevent clipping of your image when rendering for video output. To toggle them on, right-click the viewport's label and select Show Safe Frame in the menu. Safe frames are linked to the render output resolution, which is 640x480 pixels by default in max.

In this exercise, however, the safe frames option has the effect of matching the viewport's aspect ratio to the render output and to the size of the background image, which is also 640x480 resolution. This keeps both the viewport and final rendering in registration (aligned).

  1. Right-click in the Camera01 viewport, and click the Quick Render button (keyboard shortcut: Shift+Q) to see the street appear behind the mesh objects in your scene. Close the Virtual Frame Buffer. Choose Views, Viewport Background from the menu. In the Viewport Background dialog box, select the Use Environment Background check box and the Display Background check box (see Figure 13.2), and click OK. The street image as well as the rendered scene now show in the Camera01 viewport.

Figure 13.2 Remember to select Display Background when you have selected the Use Environment Background option; otherwise, the image will be loaded but not displayed.

On the CD

exercises\CH13\Reactor_net.mat

NOTE

The Reactor_net.mat material library is in the \exercises\CH13 folder on the CD-ROM. You can open it in the Material Editor, if you do not see the materials listed as you work through this exercise.

  1. The large Street box object hides the lower portion of the background image. You will assign a special material, called Matte/Shadow, to the box that allow the background to show through, making the box invisible yet still able to receive shadows from the mesh objects in the scene. On the main toolbar, click the Material Editor button (hotkey: m), and click the sample window to the far right in the second row (see Figure 13.3). Drag and drop the material onto the Street box object in the Camera01 viewport. The Matte/Shadow material already has the Receive Shadows option enabled. Quick Render the Camera01 viewport (see Figure 13.4).

Figure 13.3 Enabling the Receive Shadows option in a Matte/Shadow material allows the invisible object to receive shadows cast by other objects.

Figure 13.4 The Receive Shadows option creates the illusion that the net and catapult are casting shadows onto the background image in the rendered scene. The building shadows are part of the background image.

TIP

The 2-Sided option allows the Net material to be seen from both sides of the object, not just the side with the face normals. You should do this for most transparent materials.

  1. The net in the rendered image looks like a solid object, not a net, so you'll assign a wire material that renders only the visible edges of the segmented plane. In the Material Editor, click the Net sample window (on the far right in the top row). It is a bright red color. Notice that Wire and 2-Sided are selected in the Shader Basic Parameters rollout, and the Extended Parameters rollout shows a wire size of 2 units in. Drag and drop this material onto the Net object and render the Camera01 viewport. Now you can see through the net.

  2. Close all windows and dialog boxes. Save the file. It should already be called Reactor_net02.max. The scene is now ready for the Reactor dynamics setup.

You have a busy-looking scene with only a small amount of actual geometry. This makes rendering the scene more efficient and frees computer resources for the Reactor simulation in the following exercises.

Preparing Objects for Collision Detection

Before you are able to calculate Reactor collisions, you must assign objects to collections—Rigid Bodies or Cloth, for example—based on their physical properties in the simulation. Objects can be assigned directly to Rigid Bodies collections, but cloth objects must first have a Reactor Cloth modifier assigned before they are available to the collection.

Exercise 13.2: Using Reactor Collections and Modifiers

On the CD

exercises\CH13\Reactor_net02.max

  1. Open Reactor_net02.max from Exercise 13.1 or from the CD-ROM, and save it as Reactor_net03.max. Right-click in the Top viewport to activate it. This is where you will define the Reactor collections.

  2. In the Create panel, Helpers category, click the drop-down arrow next to Standard, and choose Reactor in the list. This is where you find the collections that define objects to be included in the Reactor simulation. In the Object Type rollout, click the RBCollection button, and click in the lower-right corner of the Top viewport to create a Rigid Bodies collection (RBCollection) icon that looks like a box, torus, and sphere.

  3. In the RB Collection Properties rollout, click the Add button. Hold down the Ctrl key and select Barrel01 and Street in the Select Rigid Bodies dialog box. Click Select in the dialog box, and the names will be added to the Rigid Bodies window in the rollout (see Figure 13.5).

Figure 13.5 Objects must be added to the proper collection properties list to be included in a collision detection simulation.

  1. In the Object Type rollout, click the CLCollection button to create a Cloth collection. Click near the RBCollection icon in the Top viewport to create a Cloth-Col icon (looks like a blouse or dress). Right-click in a viewport to exit CLCollection mode. If you click the Add button in the CL Collection Properties rollout, nothing appears in the list because objects in a Cloth collection must have a special modifier assigned first.

  2. On the main toolbar, click the Select button and pick the Net object in the Camera01 viewport. In the Modify panel, Modifier List, select the Reactor Cloth modifier.

  1. In the Top viewport, click the Cloth-Col icon. In the Modify panel, CL Collection Properties rollout, click the Add button, and double-click Net in the Select Cloths dialog box to add it to the window in the CL Collection Properties rollout.

  2. Close any windows or dialog boxes and save the file. It should already be called Reactor_net03.max.

You have added two objects to a Rigid Bodies collection and one object to a Cloth collection to make them available to a Reactor simulation. Any mesh object can be assigned to the Rigid Bodies collections, but objects assigned to a Cloth collection must have a Reactor Cloth modifier applied first.

Assigning Object Properties

Now that the objects to be included in the Reactor simulation have been assigned to collections that define their general behavior, you need to assign more specific properties to get them to interact believably. The barrel needs some weight so that it will react with gravity, for example. The net also should react to gravity, but you don't want it dropping to the street; it should appear to be held up by the rods. You do not want the street to drop from the pull of gravity or move when the barrel hits it. To define these behavioral traits, in this next exercise you assign properties to the collection objects.

Exercise 13.3: Trying to Make a Barrel Behave

On the CD

exercises\CH13\Reactor_net03.max

  1. Open the Reactor_net03.max file, and save it as Reactor_net04.max. Click the Select button, and in the Camera01 viewport, pick the Street object in the scene.

  2. In the Utilities panel, Utilities rollout, click the Reactor button. Expand the Properties rollout, and in the Other Properties section, select the Unyielding check box. This option tells the box to be included in the simulation but not be affected by any forces it might encounter. In the Simulation Geometry section, select the Use Bounding Box radio button. This option uses the outer dimensions of the box shape to determine the extents of the simulation surface.

TIP

The Hold/Yes option stores the scene in a buffer file on disk. If dropping to sub-object level in the stack causes problems, you can choose Edit, Fetch from the main menu to retrieve the scene in its current state.

  1. Select the Net object in the Front viewport. It is a Plane primitive with a Reactor Cloth modifier. If you were to include it in a Reactor simulation, gravity would pull the net to the street, and the force of a barrel hitting it would move it down the street. You want it to seem as though the rods are attaching the Net object to the buildings. In the Modify panel, Stack display, expand Editable Mesh and choose Vertex. Click the Hold/Yes button in the Warning dialog box.

  2. In the Front viewport, select all the vertices of the Net object, except the four corner vertices (see Figure 13.6). Remain in Vertex sub-object selection mode so that the Reactor Cloth modifier will be acting only on the selected vertices. The vertex symbol (three dots) must remain visible to the right of Reactor Cloth in the Stack display. In the Stack display, return to Reactor Cloth. Notice in the Properties rollout, Vertex Selection section, that the radio button for Non-Selected Are Fixed is selected. This means the Reactor Cloth modifier will act only on the selected vertices, so the net will appear to hang from the rods.

Figure 13.6 Selecting all vertices except the four corners of the net enables the Reactor Cloth modifier to act on most of the object, while the four corners are stationary.

  1. To make the Net object slightly heavy, enter 5 in the Mass field in the Properties rollout. In the Force Model section, enter 0.5 in the Stiffness field to give it more body.

TIP

You can also define mass and friction properties for materials in the Material Editor and then use the Get From Material and Set To Material buttons in the Properties rollout to make changes.

  1. In the Camera01 viewport, select the Barrel01 object. In the Utilities panel, Properties rollout, Physical Properties section, enter 3.0 in the Mass field to make the barrel weigh less than the net (see Figure 13.7). Enter 1.0 in the Friction field to make the barrel cling slightly to the net when it strikes. In the Simulation Geometry section, leave Use Mesh Convex Hull selected. This option tells Reactor to use the barrel's actual shape in collision detection.

Figure 13.7 Properties for Cloth objects are set in the Modify panel, but Rigid Bodies properties are set in the Utilities panel, Reactor utility.

  1. Save the file. It should already be called Reactor_net04.max.

You have assigned properties to the objects in the Reactor collections to give them behavioral parameters based on physical traits such as mass, friction, and stiffness. You also have defined the bounding box shape for the collision detection to use. The simpler the bounding box shape, the faster the calculations. However, a sphere with a box bounding shape, for example, might cause bouncing on the corner of the bounding box for an unrealistic effect in the collision detection.

For Every Action, There Is a Reaction

Without any animation in the scene, a collision detection simulation is simple. In this next exercise, you set things in motion so that Reactor has colliding objects to simulate the action. You use Set Key mode to animate the barrel moving toward the net over a period of five frames. Hand-animating ensures that the barrel's initial velocity is set in the right direction. You then tell Reactor to pick up that velocity at frame 4 and use it for the duration of the collision detection simulation. The result should be a convincing animation.

Exercise 13.4: Setting Things in Motion

On the CD

exercises\CH13\Reactor_net04.max

  1. Open the Reactor_net04.max file, and save it as Reactor_net05.max. Right-click in the Top viewport to activate it, and zoom in to fill the viewport with the catapult and the net.

  2. Select Barrel01 in the Top viewport. In the Status Bar, click the Set Key button to toggle Set Key animation mode on. The Time slider and viewport border turn pink. Click the Key Filters button, and make sure only the Position check box is selected and the other check boxes are cleared. Close the Set Key Filters dialog box. With the Time slider at frame 0, click the key icon button to set an initial position key for Barrel01.

  3. Drag the Time slider to frame 5. Click the Select and Move button, and in the Top viewport, move Barrel01 about one quarter of the distance from the catapult to the net (see Figure 13.8). In the Camera01 viewport, move the barrel up to align its top with the top of the catapult dish. Click the key icon button to set a position key. Toggle Set Key mode off.

Figure 13.8 Animating the barrel toward the net sets an initial velocity for the Reactor simulation.

NOTE

It is important to follow all the steps in this exercise for the process to work. If it fails, start from step 1 by loading the scene and trying again. After you have it functioning and are comfortable with the process, you can experiment with variations.

  1. In the Reactor Utility panel, Animation & Export rollout, enter 4 in the Start Frame field to pass the barrel's velocity and trajectory at frame 4 to the Reactor simulator. From frame 4 onward, Reactor will use that initial velocity to calculate the rest of the simulation. Select the Update Viewports check box so that you can see the calculation's progress in the viewports. Click the Perform Simulation button. The first thing you will notice is the net sagging from the effects of gravity. As the barrel hits the net (see Figure 13.9), the net collapses and then rebounds, tossing the barrel back into the street. The action of the barrel and net depends on the velocity and angle that you set at frame 5. It would be different each time you tried the exercise because even slight changes in the position of the barrel at frame 5 will affect the results.

Figure 13.9 The net deforms from the effects of gravitational pull and from the barrel hitting it.

  1. Save the file. It should already be called Reactor_net05.max.

Hand-animating objects to make it seem as though they are colliding with other objects and deforming under the weight of impact and gravity would be a daunting task. Reactor collision detection simulations can save you a long trial-and-error process after you have mastered the fundamentals of body dynamics. That is not to say the process doesn't have its element of trial and error when trying to set up properties for objects; it is just a different approach.

When adjusting Reactor parameters and properties, avoid the temptation to change several settings at once when fine-tuning your collisions. Set a property and perform the simulation to see the results, and then go on to the next property until you learn to predict what effect a change will probably have.

Working with Rope Collections

Another interesting option with Reactor that you will investigate is simulating the action of a rope. In this next exercise, you produce a ropelike effect for a beaded curtain in the doorway of a palm reader's shop. She has apparently seen the future in your personal transporter and has thrown it out the door, disturbing the beads and tipping over the transporter.

The scene is simple, but take the time to look at some of the materials to get ideas you can use. In the doorway is a single rope hanging from a rod across the opening to near the floor. The rope was created from a line with 17 vertices to make it flexible. It has the Renderable and Display Render Mesh options enabled in the Modify panel and a material has been assigned.

You will use a process similar to the one you used in Exercise 13.4 for the net to turn the rope into a Reactor Rope. In this next exercise, you set the floor and door trim to use the Unyielding option, and hand-animate the transporter to set an initial velocity. You then attach the rope to the rod in the doorway with a Reactor modifier to keep it from slumping to the floor under the pull of gravity. You copy the rope several times and add all the copies to a Reactor Rope collection.

Exercise 13.5: Creating Reactor Collections

On the CD

exercises\CH13\Reactor_rope01.max

  1. Open the Reactor_rope01.max file, and save it as Reactor_rope02.max to a directory on your hard drive. Right-click in the Top viewport to activate it.

  2. In the Create panel, Helpers category, click the drop-down arrow next to Standard, and choose Reactor in the list. This is where you find the collections that define objects to be included in the Reactor simulation. In the Object Type rollout, click the RBCollection button, and click in the lower-right corner of the Top viewport to create a Rigid Bodies collection icon.

  3. In the Modify panel, RB Collection Properties rollout, click the Add button. Highlight transporter, Cylinder01 (the rod over the door), DoorFrame01, and Floor in the Select Rigid Bodies list and click the Select button. The four objects are then displayed in the Rigid Bodies window in the RB Collection rollout.

  4. Select the DoorFrame01 object, and in the Utilities panel, Reactor utility, Properties rollout, select the Use Mesh radio button in the Concave section. Using the Bounding Box option for this object would keep the transporter from going through the door opening. Select the Unyielding check box in the Other Properties section.

  5. Select Floor and then Cylinder01, and set each to Use Bounding Box and Unyielding.

  6. Select the transporter, and in the Utilities panel, set the Mass field to 5.0 and the Friction field to 0.05.

  7. In the Helpers panel, Object Type rollout, click the RPCollection button and click in the Top viewport to place a Rope-Col icon (looks like a coil of rope). Click the Select button on the main toolbar, and in the Front viewport, select the Rope01 object on the left side of the doorway.

NOTE

In step 7 you are adding an RPCollection (for rope), not an RBCollection (for rigid body).

  1. In the Modify panel, Modifier List, select the Reactor Rope modifier. In the Properties rollout, enter 0.5 in the Mass field.

  2. Next, you need to select the rope's top vertex and attach it to the cylinder in the doorway. To select the vertex for the modifier to operate on, go to Modifier List, SplineSelect. Expand SplineSelect in the Stack display and choose Vertex. In the Front viewport, pick the top vertex on the rope where it meets the cylinder.

  3. In the Modifier List, select Reactor AttachToRB, and in the Properties rollout, click the None button and pick the Cylinder01 object in the Front viewport. SplineSelect must be above Reactor Rope in the stack, or Reactor Rope would set the properties for just the vertex, not the entire rope. SplineSelect ensures that only the top vertex is attached to the cylinder.

  4. In the Front viewport, make sure Rope01 is selected. Click Select and Move, hold down the Shift key, and move Rope01 a few inches to the right to about the center of the left tire on the transporter. In the Clone Options dialog box, select the Copy radio button, and enter 9 in the Number of Copies field. Click OK to create an array of ropes across the doorway.

  5. In the Top viewport, select the Rope-Col icon. In the Modify panel, Properties rollout, click the Add button. In the Select Ropes dialog box, click the All button and click Select. The ropes are then listed in the Properties rollout window. Only objects with the Reactor Rope modifier can be added to the collection.

  6. Save the file. It should already be called Reactor_rope02.max.

You have assigned objects to a Rigid Bodies collection and to a Rope collection. Then you set properties for the rope and used the SplineSelect modifier to attach just the top vertex to the cylinder across the top of the doorway. Finally, you created an array of ropes and added them to the Rope collection so that they will be included in the collision simulation.

Madame Maxine Throws a Fit and a Transporter

In this next exercise, you set objects in motion and then perform a Reactor simulation to take over the transporter's initial velocity and send it crashing into the bead ropes. The animation is a review of the process in Exercise 13.4; you will animate the transporter using Set Key mode in 10 frames and let the calculations take over at frame 9.

Exercise 13.6: Setting Initial Velocity and Performing a Reactor Simulation

On the CD

exercises\CH13\Reactor_rope02.max

  1. Open the Reactor_rope02.max file, and save it as Reactor_rope03.max. Right-click in the Top viewport to activate it, and select the transporter.

  2. In the Status Bar, click the Set Key button. Click the Key Filters button and select only the Position check box in the Set Key Filters dialog box. Close the dialog box. Make sure the Time slider is at frame 0, and click the key icon button to set a key.

  3. Set the Time slider to frame 10, and in the Top viewport, move the transporter almost to DoorFrame01 (see Figure 13.10). Click the key icon button to set a position key. Toggle Set Key off.

Figure 13.10 Animating the transporter from its current location to the DoorFrame01 object in 10 frames will set an initial velocity for the Reactor simulation.

NOTE

Depending on your computer, the calculations could take a while because the transporter and DoorFrame01 objects are concave and the entire mesh object is used instead of a simple bounding shape.

  1. In the Utilities panel, Reactor utility, Animation & Export rollout, enter 9 in the Start Frame field. Select the Update Viewports check box and click the Perform Simulation button.

  2. Next, you'll render the completed animation to an AVI file that can be viewed from any computer. On the main toolbar, click the Render Scene button (keyboard shortcut: F10). In the Common Parameters rollout, Time Output section, click the Active Time Segment radio button. In the Output Size section, click the 320x240 button to make the output resolution small enough to play back on almost any computer. In the Render Output section, select the Save File check box and click the Files button. In the Render Output File dialog box, choose a folder on your hard drive, name the file transporter.avi, and click OK. At the bottom center of the Render Scene dialog box, make sure Camera01 is in the Viewport field (see Figure 13.11). Click the Render button.

Figure 13.11 Set the Render Scene dialog box to the active time segment and write to an animation file type to save the full animation to disk for others to view.

  1. Save the file. It should already be called Reactor_rope01.max. The exact behavior of your simulation could range from the transporter becoming entangled in the bead ropes and falling back into the room to shooting out and skidding across the floor. Figure 13.12 shows my final rendered frame.

Figure 13.12 The initial velocity that you set for the transporter will affect each simulation differently.

Again, slight changes in the Reactor properties and the initial velocity of animated objects when the calculations begin can make large differences in the final reactions.

Go back to Exercises 13.5 and 13.6 and make changes to the transporter's mass, and then try the exercises again with different initial velocities to see what variations you can create. With a little practice, you can gain a level of comfort in how objects with certain properties might interact, but work through the process deliberately and with a little preplanning so that you have a better idea of what to adjust to fine-tune the results.

  • + Share This
  • 🔖 Save To Your Account