KaBOOM!

KaBOOM! is a handy, and very easy to use MEL script I created for quickly making breakable objects.  This could be anything from a crate that the hero smashes over the villain's head, to the destruction of an entire building.  KaBOOM! uses Maya’s built in rigid body dynamics to create physically correct motion paths for flying debris, and allows the user to quickly and easily bake that animation to keyframes, for use in any game engine.
Below is a brief tutorial on how to use KaBOOM!

Note: If you’re looking for the download link, you won’t find one.  I wrote KaBOOM! while working for Amaze Entertainment, so I am unable to share the actual script.  I am using it for skill demonstration purposes only.

Tuesday
Sep282010

Part 1: Setting up you objects

KaBOOM! consists of two scripts; mwKaBOOMUI and mwKaBOOM.  Make sure both scripts are located in your scripts directory.  You may need to type in “source mwKaBOOMUI” and “source mwKaBOOM” in the command line to force them to load.

Step 1)  Create two versions of the object you wish to smash - an intact version, and a broken version.

Figure 1-1Step 2) Now that you have two versions of your object, do the following:

  • Turn off visibility for the intact version of your object.  You will keyframe the visibility for both objects later.

  • Place the broken version at the origin.

  • Freeze transforms on the broken version.

  • Center the pivot points for all of the debris pieces (those you want to move)

  • Make sure none of the debris pieces are intersecting.  This will cause errors in Maya’s rigid body calculations.

  • Set the timeline to start at Frame 0, and end at Frame 500.  This should give you enough time to see the entire simulation.  Adjust the end frame if necessary.

 

 

Step 3) Open KaBOOM by typing mwKaBOOMUI in the command line.    
The KaBOOM! window should open to the Setup tab (below).  You may want to create a shelf button if you plan to use KaBOOM often.

 

Figure 1-2Step 4) Set up the simulation.
The Setup tab is divided into four sections:
In the first section, you will choose explosion type.  The three options are; Ground, Wall, and Air.

  • A Ground burst will send the debris upward and out in random directions.  A ground plane is automatically created so the debris will have something to interact with.  You do have the choice of deleting this plane and adding any geometry you want.

  • Wall burst may send some of the debris in the downward direction.  This is randomly generated, so some explosions will look more like a ground burst.

  • An Air burst is omnidirectional.  This is ideal for simulating hits on aircraft.

In the next section, you have the option of using temporary geometry.  This is great for trying out KaBOOM!, but if you use it for you simulations, you will need to take into account the varying object topologies.

In the third section, you add rigid body dynamics to your object.  If you have been testing with the Temp Geo, you can now delete that geometry, insert your own and press Add Dynamics.  You do not need to restart KaBOOM!.

The last section contains controls that allow you to adjust three parameters that determine the size and appearance of your explosion.

  • Range to First Bounce determines approximately when the debris will first contact the ground plane.  However, since the velocities are randomly generated, not all fragments will reach this distance.  Think of it as the maximum range your debris can fly.
  • Sweep determines how round the explosion is.  It has a minimum of a 10 degree arc, and a maximum of 360 degrees.
  • As the name implies, Ground Plane Scale simply adjusts the size of the ground plane.  Make sure the ground plane is slightly larger than Range to First Bounce, otherwise your fragments may appear to fall off the edge of the world.
Wednesday
Sep292010

Part 2: Simulation and Baking

Now that you have you’ve chosen your explosion type, added dynamics, and adjusted the parameters, it’s time to start the simulation.  Press the Easy Bake tab shown in Figure 2-1.

Step 1)  Play the simulation as is. Figure 2-1
This will show you what the default simulation looks like.  From there, you have a few options.

  • If you are happy with the results, go to Step 2.  
  • If you are happy with range and sweep, but unhappy with the distribution pattern, Do the following in order:
    • Press REWIND - This takes you back to frame 0.
    • Press RANDOMIZE - This will recalculate the velocities and angles, creating a new distribution pattern.  You can do this as often as you like, until you get the results you want.
    • Press PLAY to re-run the simulation.
  • If the Range and Sweep are not to your liking, return to the Setup tab, adjust those values, and return to Easy Bake to run the simulation again.

 

 

Step 2)  Bake the keyframes.
Take note of  when the debris fragments stop moving in the simulation.  This will be your Stop Frame.  The Start Frame should be either 0 or 1.  Enter those values in the fields, and then press BAKE ANIMATION.

That’s it!  You now have a realistic explosion.  Just add a particle system or two, and you have a really convincing effect.

 

Thursday
Sep302010

Part 3: Cleanup and Customization

Now that you have you’ve chosen your explosion type, added dynamics, and adjusted the parameters, it’s time to start the simulation.  Press the Clean up Scene tab (Figure 3-1).

Step 1)  Press the Clean Up Scene tab.Figure 3-1
This will remove all rigid bodies, and other dynamics components that are no longer needed.

 

 

 

 

 

Step 4) Customize your simulation.
There may be situations in which a simple ground plane isn’t going to effectively model your simulation.  One example from my own work, was creating an explosion inside a mine tunnel.  I didn’t want geometry passing through the walls and reappearing elsewhere in the scene, so I needed to use the geometry created by the environment artist.
Doing this requires only a few relatively simple steps.

  • Delete the ground plane.
  • Import your geometry.
  • Place your environment geometry around the origin.  All of KaBOOM!s dynamics assume the origin as the center of the explosion.  Once baked, you can move the effect to another world position.
  • Make sure your environment geometry is selected.
  • From the Soft/Rigid Bodies menu in Maya, choose Passive Rigid Body.
  • Run the simulation as outlined in Part 2.


That should do it.  You will need to note the rotation and position of the environment geometry, so the effect can be placed properly when that environment geometry is moved back to its original position.