Chapter 14. Advanced nDynamic Effects

In this chapter, you'll delve deeper into Maya dynamics to understand how the various dynamic systems, such as nCloth, nParticles, and Rigid Bodies, can be used together to create spectacular effects. You'll also use more advanced particle expressions to control the motion of particle instances.

In this chapter you will learn to:

  • Use nCloth

  • Combine nCloth and nParticles

  • Use nCloth for rigid body simulations

  • Use traditional Maya rigid body dynamics

  • Instance geometry to nParticles

  • Create nParticle expressions

  • Create smoke effects

nCloth

nCloth uses the Nucleus solver to create soft body dynamics. Typically nCloth is used to make polygon geometry behave like clothing, but nCloth can actually be used to simulate the behavior of a wide variety of materials. Everything from concrete to water balloons can be achieved by adjusting the attributes of the nCloth object. nCloth uses the same dynamic system as nParticles and applies it to the vertices of a piece of geometry. An nCloth object is simply a polygon object that has had its vertices converted to nParticles. A system of virtual springs connects the nParticles and helps maintain the shape of nCloth objects. nCloth objects automatically collide with other nDynamic systems (such as nParticles and nRigids) that are connected to the same Nucleus solver, and an nCloth object collides with itself.

In this section you'll see how to get up and running fast with nCloth using the presets that ship with Maya as well as get some background on how the Nucleus solver works. The examples in this chapter illustrate a few of the ways nCloth and nParticles can be used together to create interesting effects. These examples are only the beginning; there are so many possible applications and uses for nCloth that a single chapter barely scratches the surface. The goal of this chapter is to give you a starting place so you feel comfortable designing your own unique effects. Chapter 15 demonstrates techniques for using nCloth to make clothing for an animated character.

Creating nCloth Objects

Any polygon mesh you model in Maya can be converted into an nCloth object; there's nothing special about the way the polygon object needs to be prepared. The only restriction is that only polygon objects can be used. NURBS and subdivision surfaces can't be converted to nCloth.

There are essentially two types of nCloth objects: active and passive. Active nCloth objects are the ones that behave like cloth. They are the soft, squishy, or bouncy objects. Passive objects are solid pieces of geometry that react with active objects but do not have their own dynamic properties. For example, to simulate a tablecloth sliding off a table, the tablecloth would be the active nCloth object and the table would be the passive nCloth object. The table prevents the tablecloth from falling in space. You can animate a passive object, and the active object will react to the animation. So you can keyframe the table tilting, and the tablecloth will slide off the table based on its dynamic settings.

The first lesson in this chapter shows how to create the effect of a dividing cell using two nCloth objects.

  1. Create a new scene in Maya.

  2. Create a polygon cube at the center of the grid. The cube should have one subdivision in width, height, and depth. Scale the cube up eight units in each axis.

  3. Select the cube, switch to the Polygon menu set, and choose Mesh

    Creating nCloth Objects
  4. Switch to a side view. Right-click on the cube and choose Vertices to switch to component mode.

    Create a sphere by smoothing a polygon cube.

    Figure 14.1. Create a sphere by smoothing a polygon cube.

  5. Switch to wireframe view (hot key = 4). Select all the vertices on the right-side center line of the grid but not the vertices on the center line.

  6. Select the Scale tool (hot key = r), and scale the vertices along the Z axis so they are flat. Turn on Grid Snapping, and use the Move tool (hot key = w) to snap these vertices on the center line. You should end up with a rounded cube with one flattened side (Figure 14.2).

    Select, scale, and snap the vertices of the right half of the cube along the center line in the side view.

    Figure 14.2. Select, scale, and snap the vertices of the right half of the cube along the center line in the side view.

  7. Name the cube cellLeft.

  8. Turn off Grid Snapping. Select cellLeft and move it just to the left of the center line; set the Translate Z channel to 0.08.

  9. Turn Grid Snapping on; hold the d key and use the Move tool to position the pivot point at the center of the grid. Be careful not to move the geometry, only the pivot point.

  10. Select cellLeft and choose Modify

    Moving the pivot point
  11. Select cellLeft and duplicate it (hot key = Ctrl+d). Set the Scale Z channel of the duplicate to −1. Choose Modify

    Moving the pivot point
  12. Name the duplicate cellRight (see Figure 14.3). Select both sides and delete history (Edit

    Moving the pivot point
  13. Switch to the nDynamics menu set. Select both objects and choose nMesh

    Moving the pivot point
    Create the second half of the cell by duplicating and scaling the first.

    Figure 14.3. Create the second half of the cell by duplicating and scaling the first.

  14. Switch to the wireframe node and select nCloth1. One of the cell halves turns purple, indicating the nCloth node is an input connection to that particular piece of geometry. Rename the nCloth1 and nCloth2 nodes cellLeftCloth and cellRightCloth according to which piece of geometry they are connected to (Figure 14.4).

  15. Set the timeline to 400 frames and play the scene. You'll see both pieces of geometry fall in space. This is because Gravity is turned on by default in the Nucleus solver.

  16. Save the scene as cellDivide_v01.ma. To see a version of the scene to this point, open cellDivide_v01.ma from the chapter14scenes directory on the DVD.

    Add two nCloth nodes to the Outliner, one for each side of the cell, and rename them cellLeftCloth and cellRightCloth.

    Figure 14.4. Add two nCloth nodes to the Outliner, one for each side of the cell, and rename them cellLeftCloth and cellRightCloth.

nCloth Nodes

When you create an nCloth object or any nCloth dynamic system (nParticles, nRigids), several additional nodes are created and connected. You can see this when you graph the cellLeft shape on the Hypergraph, as shown in Figure 14.5.

The input and output connections for the cellLeft shape are graphed on the Hypergraph.

Figure 14.5. The input and output connections for the cellLeft shape are graphed on the Hypergraph.

Each nCloth object consists of the original geometry, the nCloth node, and the Nucleus solver. By default, any additional nDynamic objects you create are attached to the same Nucleus solver. Additional nodes include the original cellLeftShape node, which is connected as the inputMesh to the cellLeftClothShape node. This determines the original starting shape of the nCloth object.

  1. Continue with the scene from the previous section or open cellDivide_v01.ma from the chapter14scenes folder on the DVD. Select the cellLeftCloth node and open the Attribute Editor. Switch to the cellLeftClothShape tab, as shown in Figure 14.6. This node was originally named nCloth1. The tabs found here include the following:

    cellLeftCloth

    This tab contains the settings for the nCloth1 transform node. Most of the time you won't have a reason to change these settings.

    cellLeftClothShape

    This tab contains the settings that control the dynamics of the nCloth object. There are a lot of settings in this tab, and this is where you will spend most of your time adjusting the settings for this particular nCloth object.

    nucleus1

    This tab contains all the global settings for the Nucleus solver. These include the overall solver quality settings but also the Gravity and Air Density settings. If you select the cellRightCloth node in the Outliner, you'll notice it also has a nucleus1 tab. In fact, this is the same node as attached to the cellLeftCloth object.

    It's possible to create different Nucleus solvers for different nDynamic objects, but unless the nDynamic objects are connected to the same Nucleus solver, they will not directly interact.

  2. Select the nucleus1 tab and set Gravity to 0. When you rewind and play the scene, nothing happens because there are no forces acting on the cells.

    The Attribute Editor for the cellLeftCloth Shape node has tabs for the transform and shape nodes as well as the nucleus1 solver.

    Figure 14.6. The Attribute Editor for the cellLeftCloth Shape node has tabs for the transform and shape nodes as well as the nucleus1 solver.

nCloth Presets

The concept behind this particular example is that both halves of the cell together form a single circular spherical shape. To make the cells separate, we'll adjust the nDynamic settings so that each half of the cell inflates and pushes against the other half, moving them in opposite directions. Creating the right settings to achieve this action can be daunting simply because there is a bewildering array of available settings on each nCloth shape node. To help you get started, Maya includes a number of presets that can act as a template. You can apply a preset to the nCloth objects and then adjust a few settings until you get the effect you want.

  1. Continue with the scene from the previous section.

  2. Select the cellLeftCloth node, and open the Attribute Editor to the cellLeftClothShape1 node. At the top of the editor, click and hold the Presets button in the upper right. The asterisk by the button label means that there are saved presets available for use.

  3. From the list of presets, scroll down and find the waterBalloon preset. A small pop-up appears; from this pop-up choose Replace (see Figure 14.7). You'll see the settings in the Attribute Editor change, indicating the preset has been loaded.

  4. Repeat step 2 for the cellRightCloth node.

  5. Rewind and play the animation. Immediately you have a decent cell division going.

    Using a preset selected from the Presets list is a quick way to start a custom nCloth material.

    Figure 14.7. Using a preset selected from the Presets list is a quick way to start a custom nCloth material.

    The next task is to create a more realistic behavior by adjusting the setting on the nCloth objects.

  6. Switch to the nucleus1 tab and set Air Density to 35. This makes the cells look like they are in a thick medium, such as water (see Figure 14.8).

    Increasing the Air Density setting on the nucleus1 tab makes it appear as though the cells are in a thick medium.

    Figure 14.8. Increasing the Air Density setting on the nucleus1 tab makes it appear as though the cells are in a thick medium.

  7. You can blend settings from other presets together to create your own unique look. Select cellLeftCloth, and in its shape node tab click and hold the Presets button in the upper right. Choose Honey

    Increasing the Air Density setting on the nucleus1 tab makes it appear as though the cells are in a thick medium.
  8. Play the animation. The two cells separate more slowly.

  9. You can save these settings as your own preset so it will be available in other Maya sessions. From the Presets menu, choose Save Maya Preset. In the dialog box, name the preset Cell (see Figure 14.9).

  10. Save the scene as cellDivide_v02.ma.

    You can save your own custom presets to the Presets list so they will be available in other Maya sessions.

    Figure 14.9. You can save your own custom presets to the Presets list so they will be available in other Maya sessions.

Stickiness

At this point, you can start to adjust some of the settings on the nCloth tabs to create a more interesting effect. To make the cells stick together as they divide, you can increase the Stickiness attribute.

  1. Continue with the scene from the previous section or open the cellDivide_v02.ma scene from the chapter14scenes directory on the DVD.

  2. Select the cellLeftCloth node, and open the Attribute Editor to its shape node tab. Expand the Collisions rollout, and set Stickiness to 1 (see Figure 14.10). Do the same for the cellRight object.

    Increase the Stickiness attribute in the cellLeftClothShape tab of the Attribute Editor.

    Figure 14.10. Increase the Stickiness attribute in the cellLeftClothShape tab of the Attribute Editor.

    Notice that many of the settings in the Collision rollout are the same as the nParticle Collision settings. For a more detailed discussion of how nucleus collisions work, consult Chapter 13.

  3. Play the animation; the cells remain stuck as they inflate. By adjusting the strength of the Stickiness attribute, you can tune the effect so the cells do eventually come apart. Try a setting of 0.8 for both cells.

  4. Save the nCloth settings as stickyCell. Save the scene as cellDivide_v03.ma.

nConstraints

nConstraints can be used to attach nCloth objects together. The constraints themselves can be broken depending on how much force is applied. In this example nConstraints will be used as an alternative technique to the Stickiness attribute. There are some unique properties of nConstraints that can allow for more creativity in this effect.

  1. Continue with the scene from the previous section or open the cellDivide_v03.ma scene from the chapter14scenes directory on the DVD.

  2. Shift+click both the cellLeftCloth and cellRightCloth nodes in the Outliner. Open the Channel Box and, with both nodes selected, set Stickiness to 0 to turn off this attribute.

  3. Switch to the side view. In the Outliner, Shift+click the cellLeft and cellRight polygon nodes. Set the selection mode to Component. By default the vertices on both objects should appear.

  4. Drag a selection down the middle of the two objects so the vertices along the center line are selected (see Figure 14.11).

    Create nConstraints between the vertices along the flattened side of each cell.

    Figure 14.11. Create nConstraints between the vertices along the flattened side of each cell.

  5. In the nDynamics menu set, choose nConstraint

    Create nConstraints between the vertices along the flattened side of each cell.
  6. Rewind and play the scene. The two sides of the cell are stuck together.

  7. In the Outliner, a new node named dynamicConstraint1 has been created. Select this node and open the Attribute Editor.

    A wide variety of settings are available in the Attribute Editor for the dynamicConstraint node; each one is described in detail in the Maya documentation. For the moment your main concern is adjusting the constraint strength.

  8. Strength determines the overall strength of the constraint. Tangent Strength creates a resistance to the tangential motion of the constraint. In this example you can leave Strength at 20 and set Tangent Strength to 0.

  9. Glue Strength is the setting that determines whether the constraint will break when force is applied. It is calculated in world space based on the size of the objects. A value of 1 means the constraint can't be broken; a value of 0 turns the constraint off altogether. Set this attribute to 0.25.

  10. Glue Strength Scale modifies the Glue Strength based on the world space distance between the constraints. Set this value to 0.6.

  11. Rewind and play the animation. The two sides of the cell start to separate but fail to part completely. There are a few techniques you can use to separate the cells.

    Keyframe the Glue Strength Scale to diminish over time.

    Create a radial field with a negative magnitude for each cell. A field can be applied independently of the Nucleus solver. You can apply a radial field to one cell and not the other. When you apply a radial field to each cell, the radial fields pull the two cells apart.

    Create a passive rigid object in the shape of a wedge that divides the two cells along the center line.

    Use the Force attribute on the dynamic constraint.

    For this exercise, you'll use the Force attribute that is built into the dynamic constraint node. The Force attribute determines the level of attraction between the constraints. Positive values cause the constraints to repel each other after they break; negative values cause the constraints to attract each other. In this scene, very small values can create a big difference.

  12. Set the Force attribute on the dynamic constraint node to 0.01. Rewind and play the scene.

  13. The cells now push each other apart and keep going. To halt their motion after separation, adjust the Dropoff Distance value. Set this to 3. Adjust the Strength Dropoff curve so that there is a sharp decline to 0 on the left side of the curve. The strength of the force drops to 0 as the distance between the constraints approaches 3 units (Figure 14.12).

  14. You can fine-tune the effect by adding a small amount of motion drag. Set Motion Drag to 0.01. If the cells can't quite separate, try raising Force to 0.012.

    Add a small value to the Force attribute, and lower the Dropoff Distance to a value of 3. By adjusting the Strength Dropoff ramp you can finetune the field.

    Figure 14.12. Add a small value to the Force attribute, and lower the Dropoff Distance to a value of 3. By adjusting the Strength Dropoff ramp you can finetune the field.

    Working with the Nucleus solver quickly becomes a very experimental process much like cooking; you adjust the sliders and season to taste until the effect looks like what you want. Since many of the attributes are interconnected, it's best to adjust one at a time and test as you go. You can move an nCloth object after it has been constrained. However, the results of the simulation may not behave they way you expect. It's usually best to make sure your nCloth objects and their constraints are positioned where you want them. Avoid setting keyframes on the translation or rotation of the nCloth object itself.

    Rest Length attributes significantly affect how the simulation behaves. Rest length refers to the length of each constraint when no tension is applied (imagine an unattached spring sitting on a table; its length at rest is its rest length). If Rest Length Method is set to Start Frame, then the rest length of each constraint is equal to its length at the first frame of the animation. If this is set to Constant, then the rest length is determined using the Rest Length numeric input.

    Rest Length Scale applies a scaling factor to the constraints. If this is set to 1 and Rest Length Method is set to From Start Distance, then the constraints have no initial tension. In other words, at frame 1 the scale is equal to the rest length. Lowering this value increases the tension on the constraint and makes it harder to break.

  15. Rewind the animation and set Rest Length Scale to 0.5.

  16. Play the animation to frame 40 and set a keyframe on Rest Length Scale.

  17. Play the animation to 50 and set Rest Length Scale to 1. Set another keyframe. Rewind and play the animation. This is one way in which you can control the timing of the cell division. You can also control this attribute using an expression or Set Driven Key.

  18. Save the scene as cellDivide_v04.ma. To see a version of the scene to this point, open the cellDivide_v04.ma scene from the chapter14scenes folder on the DVD.

Pressure

One of the more significant attributes that creates the motion of the nCloth objects used in this example is pressure. Using pressure you can inflate a piece of geometry like a balloon, or in the case of this example, make it appear as though the geometry is filled with fluid.

There are two ways to calculate pressure: Manual Pressure Setting and Volume Tracking Model.

Manual Pressure Setting is very simple—the Pressure slider and Pressure Damping slider are the only two controls (see Figure 14.13). These can be keyframed to make it appear as though the nCloth object is being filled with air. If you set Pressure at 0 and create a keyframe, then play the animation to frame 100, set Pressure to 1, and set another keyframe, the nCloth object will grow in size over those frames.

Volume Tracking Model, which is used by the waterBalloon preset originally applied to the cell geometry, is a more accurate method for calculating volume and has more controls (see Figure 14.14).

Manual Pressure Setting has very simple controls for adding internal pressure to nCloth objects.

Figure 14.13. Manual Pressure Setting has very simple controls for adding internal pressure to nCloth objects.

Volume Tracking Model has more controls and produces a more accurate internal pressure simulation for nCloth objects.

Figure 14.14. Volume Tracking Model has more controls and produces a more accurate internal pressure simulation for nCloth objects.

When Volume Tracking Model is selected as the Pressure Method, you have access to additional controls, such as Pump Rate, Air Tightness, and Incompressibility. The Pump Rate value determines the rate at which air is added within the volume. Positive values continue to pump air into the volume; negative values suck the air out. The Start Pressure value sets the initial pressure of the air inside the volume at the start of the animation.

The Air Tightness value determines the permeability of the nCloth object. Lower settings allow the air to escape the volume. The Incompressibility setting refers to the air within the volume. A lower value means the air is more compressible, which slows down the inflation effect of the cell. Activating Seal Holes causes the solver to ignore openings in the geometry.

As you may have noticed, after the cells divide they don't quite return to the size of the original dividing cell. You can use the Pump Rate attribute to inflate the cells.

  1. Continue with the scene from the previous section or open the cellDivide_v04.ma scene from the chapter14scenes directory on the DVD.

  2. Select the cellLeftCloth shape and open its Attribute Editor. Expand the Pressure settings. Note that Pressure Method is already set to Volume Tracking Model. These settings were determined by the waterBalloon preset originally used to create the effect.

  3. Set Pump Rate to 50 for each cell and play the animation (Figure 14.15). Each cell starts to grow immediately and continues to grow after the cell divides.

  4. Try setting keyframes on the start Pump Rate of both cells so that at frame 15 Pump Rate is 0, at frame 50 it's 50, and at frame 100 it's 0.

  5. To give an additional kick at the start of the animation, set Start Pressure to 0.25.

    Setting Pump Rate to 50 on the cellLeftCloth object causes it to grow as it separates from the right side.

    Figure 14.15. Setting Pump Rate to 50 on the cellLeftCloth object causes it to grow as it separates from the right side.

Additional Techniques

To finish the animation, here are some additional techniques you can use to add some style to the behavior of the cells.

  1. Increase the Stickiness of each cell to a value between 0.8 and 1. You can also try painting a Stickiness texture map. To do this select the cells and choose nMesh

    Additional Techniques
  2. If you want the objects to start out solid and become soft at a certain point in time, set keyframes on each cell's Input Mesh Attract attribute. The input mesh is the original geometry that was converted into the nCloth object. Setting the Input Mesh Attract attribute to 1 or higher causes the nCloth objects to assume the shape of the original geometry. As this value is lowered, the influence of the nucleus dynamics increases, causing the objects to become soft.

  3. Try adding a turbulence field to both nCloth objects to add a little more interesting motion.

  4. To see a finished version of the scene, open the cellDivide_v05.ma scene from the chapter14scenes folder on the DVD.

Create an nCache

At this point you'll want to cache the dynamics so that playback speed is improved and the motion of the cells is the same every time you play the animation. This also ensures that when you render the scene the dynamics are consistent when using multiple processors.

  1. Shift+click the cellLeft and cellRight objects in the Outliner.

  2. Choose nCache

    Create an nCache
  3. In the options, you can specify if you want to create a separate cache file for each frame or a single cache file. You can also create a separate cache for each geometry object; this is not always necessary when you have more than one nCloth object in a scene (Figure 14.16).

    The options for creating an nCache

    Figure 14.16. The options for creating an nCache

  4. The default settings should work well for this scene. Click the Create button to create the cache. Maya will play through the scene.

    When the cache is complete, the scene will play much faster. If you make changes to the nCloth settings, you won't see the changes reflected in the animation until you delete or disable the nCache (nCache

    The options for creating an nCache
  5. You can select the cellLeft and cellRight objects and move them so they overlap at the center. This removes the seam in the middle and makes it look as though there is a single object dividing into two copies.

  6. You can also select the cellLeft and cellRight objects and smooth them using the Smooth operation in the Polygon

    The options for creating an nCache

Using nCloth with nParticles

Creating dynamic interaction between nParticles and nCloth objects is quite easy because both systems can share the same Nucleus solver. The collision properties of nDynamics make effects that were extremely difficult to create in previous versions of Maya very simple to create. Before continuing this section, review Chapter 13 so you understand the basics of working with nParticles.

nParticles and Goals

Goal objects attract nParticles like a magnet. A goal can be a locator, a piece of geometry, or even another nParticle. In Chapter 13 you worked with force fields, which are similar to goals in some respects in that they attract nParticles dynamically. Deciding whether you need to use a goal or a force field generated by an nDynamic object (or a combination of the two) depends on the effect you want to create. This section will demonstrate some uses of goal objects with some simple examples.

  1. Create a new, empty scene in Maya.

  2. Create a locator (Create

    nParticles and Goals
  3. Switch to the nDynamics menu set, and choose nParticles

    nParticles and Goals
  4. Choose nParticles

    nParticles and Goals
  5. Set the length of the timeline to 300. Play the animation. Balls are emitted and fall through space because of the Gravity settings on the nucleus node.

  6. Select the nParticle object and Ctrl+click locator1. Choose nParticles

    nParticles and Goals
    Convert the locator into a goal for the nParticles.

    Figure 14.17. Convert the locator into a goal for the nParticles.

  7. Rewind and play the scene. The nParticles appear on the locator and bunch up over time. Since Goal Weight is set to 1, the goal is at maximum strength and the nParticles move so quickly between the emitter and the goal object that they cannot be seen until they land on the goal. Since the Balls-style nParticles have Collision on by default, they stack up as they land on the goal.

  8. Select the nParticle object. In the Channel Box, set Goal Weight to 0.25. Play the animation. You can see the nParticles drawn toward the locator. They move past the goal and then move back toward it, where they bunch up and start to collide, creating a swarm (see Figure 14.18).

    Lower the Goal Weight for the nParticle in the Channel Box, causing the nParticles to swarm around the locator.

    Figure 14.18. Lower the Goal Weight for the nParticle in the Channel Box, causing the nParticles to swarm around the locator.

  9. Create a second locator. Select the nParticle and Ctrl+click locator2. Make it a goal with a weight of 0.25 as well.

  10. Position locator2 ten units above locator1.

  11. Play the scene. The nParticles swarm between the two goals (Figure 14.19)

    By adding two goals with equal weights the nParticles swarm in between them.

    Figure 14.19. By adding two goals with equal weights the nParticles swarm in between them.

  12. Select one of the locators and choose nSolver

    By adding two goals with equal weights the nParticles swarm in between them.
  13. Open the Attribute Editor for the nParticle, and switch to the nParticleShape1 tab. Try lowering the Conserve value on the nParticles. This causes the nParticles to lose energy as they fly through the scene.

  14. Try these settings: Conserve = 0.98, Drag = 0.05. Set Wind Speed on the nucleus tab to 8 and Wind Noise to 25. You can edit these settings in the Attribute Editor or in the Channel Box for the nParticleShape1 node. Suddenly a swarm of particles buzzes between the goal. By animating the position of the goals, you control where the swarm goes.

    Using Interactive Playback, you can move the goals around and watch the nParticles follow.

    Figure 14.20. Using Interactive Playback, you can move the goals around and watch the nParticles follow.

  15. Set Point Force Field on the nParticle node to World Space. Set Point Field Magnitude to 8, Self Attract to −10, and Point Field Distance to 10. Now the motion of the nParticles is controlled by the goals, gravity, wind, wind noise, and a force field generated by the nParticles themselves. You can quickly create complex behavior without the need for a single expression (see Figure 14.21).

  16. To see an example version of this scene, open the swarm.ma file from the chapter14scenes folder on the DVD.

    Combining goals, forces, dynamic attributes, and wind noise creates some very complex nParticle behaviors.

    Figure 14.21. Combining goals, forces, dynamic attributes, and wind noise creates some very complex nParticle behaviors.

Using nCloth as a Goal

In this example an nCloth object will be used as a goal. The nParticles will be attracted to the nCloth surface and collide with it at the same time to create a very interesting effect.

  1. Create a new, empty Maya scene.

  2. Create a polygon cube at the center of the grid. The cube should have one subdivision in width, height, and depth. Scale the cube up eight units in each axis.

  3. Select the cube, switch to the Polygon menu set, and choose Mesh

    Using nCloth as a Goal
  4. Select the cube and switch to the nDynamics menu set. Choose nMesh

    Using nCloth as a Goal
  5. Open the Attribute Editor for the nCloth object, and use the Presets menu to apply the solidRubber preset to the nCloth object (see Figure 14.22).

  6. Set the length of the timeline to 500 frames. Switch to the nucleus tab, and activate the Use Plane option to create an invisible ground plane. Set the Plane Origin's Y axis to −4. Play the animation. The nCloth object falls and then bounces on the invisible floor.

  7. Choose nParticles

    Using nCloth as a Goal
    Apply the solidRubber preset to the nCloth object.

    Figure 14.22. Apply the solidRubber preset to the nCloth object.

  8. Select the nParticle and Ctrl+click the nCloth object. Choose nParticles

    Apply the solidRubber preset to the nCloth object.
  9. Select the nParticle object and, in the Channel Box, set Goal Weight to 0.5 (see Figure 14.23).

  10. Position the emitter away from the nCloth object. Rewind and play the scene. The nParticles fly toward the nCloth object and attack it. Each nParticle is attracted to a vertex on the nCloth object. The nParticles will stack up when they can't reach a vertex.

  11. Set Mass of the nParticles to 10. The attack is much more violent.

  12. To see an example of the scene described, open the nClothGoal.ma scene from the chapter14scenes directory.

    Set Goal Weight of the nParticle object to 0.5 in the Channel Box.

    Figure 14.23. Set Goal Weight of the nParticle object to 0.5 in the Channel Box.

    When an nCloth object is used as a goal, the nParticles are attracted to the nCloth object and collide with it at the same time, making it appear as though the nParticles are attacking the nCloth object.

    Figure 14.24. When an nCloth object is used as a goal, the nParticles are attracted to the nCloth object and collide with it at the same time, making it appear as though the nParticles are attacking the nCloth object.

Collision Events

Using the Collision Event Editor you can specify what happens when a collision between an nParticle and a goal object occurs.

  1. Continue with the scene from the previous section or open the nClothGoal.ma scene from the chapter14scenes directory.

  2. Select the nParticle and choose nParticles

    Collision Events
  3. In the Editor window, select the nParticle. Leave the All Collisions check box enabled. You can use the slider to specify the collision number. Each collision event is tracked with a specific number. Using the slider you can specify that the event occurs only on the collision with the specific number.

  4. Set Event Type to Emit. The difference between Emit and Split is fairly subtle, but when Emit is selected new particles are emitted from the point of collision, and you can specify that the original colliding nParticle dies. When you choose Split, the option for killing the original nParticle is unavailable.

  5. Set Num Particles to 5 and Spread to 0.5. Set Inherit Velocity to 0.5. Check the Original Particle Dies option. Click Create Event to make the event (Figure 14.25).

    Note that the collision event will create a new nParticle object.

  6. Rewind and play the scene. You'll see small particle explosions occur wherever the nParticles collide with the goal object.

    The Collision Event Editor allows you to create an event wherever the nParticle collides with a surface.

    Figure 14.25. The Collision Event Editor allows you to create an event wherever the nParticle collides with a surface.

Tearable nConstraints

This short example demonstrates how to create a bursting surface using nParticles and an nCloth surface.

  1. In a new Maya scene, create a polygon cube at the center of the grid. The cube should have one subdivision in width, height, and depth. Scale the cube up eight units in each axis.

  2. Select the cube, switch to the Polygon menu set, and choose Mesh

    Tearable nConstraints
  3. Select the cube and switch to the nDynamics menu set. Choose nMesh

    Tearable nConstraints
  4. Open the Attribute Editor for the nCloth object, and use the Presets menu to apply the rubberSheet preset to the nCloth object.

  5. Switch to the nucleus1 tab and set Gravity to 0.

  6. Choose nParticles

    Tearable nConstraints
  7. Choose nParticles

    Tearable nConstraints
  8. Select the nParticles; in the Attribute Editor for the nParticleShape1 tab, expand the Particle Size rollout and set Radius to 0.5.

  9. Set the Timeline to 800. Rewind and play the animation. The nParticles start to fill up the surface, causing it to expand (see Figure 14.26). If some nParticles are passing through the surface, switch to the Nucleus solver and raise the Substeps value to 8.

    Placing the emitter inside the nCloth object causes it to fill with nParticles.

    Figure 14.26. Placing the emitter inside the nCloth object causes it to fill with nParticles.

  10. Select the pCube1 object in the Outliner.

  11. Choose nConstraint

    Placing the emitter inside the nCloth object causes it to fill with nParticles.
  12. If you play the scene, you'll see the surface burst open (Figure 14.27). Open the Attribute Editor for the nDynamic constraint. Set Glue Strength to 0.3 and Glue Strength Scale to 0.8; this will make the nConstraint more difficult to tear, so the bursting will not occur until around frame 500.

  13. To see two examples of Tearable Surface nConstraints, open burst.ma and burst2.ma from the chapter14scenes directory on the DVD.

    Adding a Tearable Surface nConstraint allows the surface to rip when a certain amount of force is applied.

    Figure 14.27. Adding a Tearable Surface nConstraint allows the surface to rip when a certain amount of force is applied.

nCloth and Rigid Body Simulations

A rigid body object is a piece of geometry that simulates the behavior of hard or rigid objects. They are best used to create the basis of an animation that would be difficult to create using keyframes alone. Bowling pins, pool balls, collapsing bridges, and colliding cars are examples of the types of scenes that benefit from rigid body simulations.

Maya has included a Rigid Body system as part of its dynamics since version 1. However, you can also simulate some rigid body dynamics using nCloth.

In this tutorial you'll use nCloth to simulate a small stone tower exploding, and this will be compared with using traditional Maya rigid bodies.

Rigid nCloth Objects

In Maya 2009, the process of creating an active rigid nCloth object is no different from creating a soft nCloth object; the difference is the settings used in the nCloth tab. In fact, the concrete nCloth preset is a perfect place to start. A passive rigid nCloth (nRigid) is the same type of passive collision object you've used in the previous tutorials.

  1. Open the tower_v01.ma scene form the chapter14scenes directory on the DVD. The scene contains a small stone tower on top of a hill.

  2. Open the Outliner and expand the tower group. There are three subgroups named static, passive, and active (Figure 14.28).

    The bricks of the small tower have been divided into groups.

    Figure 14.28. The bricks of the small tower have been divided into groups.

    The scene is designed so only one side of the tower will explode. Only a few stone bricks will be pushed out from the explosion; these bricks have been placed in the active group. The bricks in the passive group will be converted to passive colliders; they won't move but they will support the active brick. The bricks in the static group will be left alone. Since they won't participate in the explosion, they won't be active or passive, just plain geometry. This will increase the efficiency and the performance of the scene.

  3. Select the ground object and choose nMesh

    The bricks of the small tower have been divided into groups.
  4. In the Outliner, expand the passive group and Shift+click all of the passive bricks in the group. Choose nMesh

    The bricks of the small tower have been divided into groups.
  5. Expand the active group and Shift+click all of the active objects. Select nMesh

    The bricks of the small tower have been divided into groups.
  6. Rewind and play the scene. You'll see the active bricks sag and collapse in on themselves (see Figure 14.29).

  7. Expand the nClothBricks group and select the nCloth1 node. Open the Attribute Editor to the nClothShape1 tab. Use the Presets menu to apply the Concrete preset to this node (click the Presets button in the Attribute Editor and choose Concrete

    The bricks of the small tower have been divided into groups.
    Converting the active bricks to nCloth objects causes them to sag when the animation is played.

    Figure 14.29. Converting the active bricks to nCloth objects causes them to sag when the animation is played.

  8. Rewind and play the scene. The bricks don't sag, but they do collapse, and there is a fair amount of interpenetration problems. Fix this by adjusting some of the collision properties on the active objects and passive objects.

  9. Select the nRigid1 node in the Outliner in the nRigidBricks group, and open its Attribute Editor to the nRigidShape1 tab. Set Solver Display to Collision Thickness. Do the same for the nCloth1 object so you can see the collision thickness of both objects in the perspective view (for more information on collision properties, consult Chapter 13).

  10. There is a small gap between the bricks that could be closed up by raising the thickness of both objects. Set the collision thickness of both the nRigid1 node and the nCloth1 node to 0.05. This closes the gap, which reduces the amount of movement at the start of the animation (see Figure 14.30).

  11. In the Outliner, expand the nRigid group and Shift+click all of its members. Open the Channel Box and find the Thickness channel. Set it to 0.5. Using the Channel Box allows you to quickly set the value of the same channel on multiple selected objects at the same time. Do the same for the nodes in the nClothBricks group (see Figure 14.31).

  12. Select any one of the nCloth or nRigid nodes and, in the Channel Box, select the nucleus1 node in the Inputs section. Scroll to the bottom and set the Substeps channel to 6. This increases the accuracy of the simulation by increasing the number of times the Nucleus solver calculates each frame.

    Raising the collision thickness for both nCloth and nRigid bricks closes the gap between bricks.

    Figure 14.30. Raising the collision thickness for both nCloth and nRigid bricks closes the gap between bricks.

    You can increase the collision thickness for all selected nCloth and nRigid objects in the Channel Box.

    Figure 14.31. You can increase the collision thickness for all selected nCloth and nRigid objects in the Channel Box.

  13. Since the nCloth objects are too stiff to bend or fold, you can turn off Self Collide in the Channel Box for the selected objects. This improves performance slightly.

  14. Set Friction for all of the nCloth and nRigid objects to 5 and Stickiness to 1. This prevents the bricks from sliding out at the start of the animation.

  15. Rewind and play the scene. There is still movement, but the bricks should no longer collapse and penetrate each other.

Set nCloth Start Frame

To remove the movement of the bricks at the start of the animation, you can continue to tweak the thickness and solver settings until it's perfect. However, there are a few easier methods you can use to set the start time of the simulation.

For this particular scene, the explosion will occur at frame 20. From frames 1–19 you want the bricks to remain motionless. So, one way to postpone the evaluation of the nCloth dynamics is to set the Start Frame of the nCloth evaluation to frame 20.

The Start Frame attribute can be found in the Attribute Editor for the Nucleus solver. If you set Start Frame to 20, the Nucleus solver will not begin evaluating until frame 20. This works pretty well, except this means any other nDynamic nodes attached to this solver won't evaluate until frame 20 either. As one solution, you can add additional Nucleus solvers to the scene as you add additional nDynamic objects. Another solution is to break the connection between the individual nCloth objects and the Start Frame attribute on the nucleus nodes. The following steps demonstrate how to do this:

  1. In the Outliner, expand the nClothBricks group and select nCloth1. Open its Attribute Editor.

  2. In the Attribute Editor, expand the Time Attributes rollout. Notice that the Start Frame attribute is in yellow, indicating it has an incoming connection. This connection is coming from the nucleus1 node. Right-click on the Start Frame field and choose Break Connection (see Figure 14.32).

  3. Enter the value 20 in this field.

  4. Repeat these steps for the other nCloth nodes in the nClothBricks group (this attribute is not found in the Channel Box or the Attribute Spreadsheet, so unfortunately you need to repeat these steps for all of the nCloth objects). This is another opportunity to create a MEL script loop.

  5. Save the scene as tower_v02.ma. To see a version of the scene to this point, open the tower_v02.ma scene from the chapter14scenes folder on the DVD.

    Break the connection for the Start Frame attribute in the Attribute Editor for the nClothShape1 node.

    Figure 14.32. Break the connection for the Start Frame attribute in the Attribute Editor for the nClothShape1 node.

nCloth and Fields

To create the explosion you can add a radial field to the nCloth objects.

  1. Continue with the scene from the previous section or open the tower_v02.ma scene from the chapter14scenes directory.

  2. In the Outliner, expand the active group and Shift+click its members (when applying a field to nCloth objects, select the polygon objects, not the nCloth nodes—it seems arbitrary but that is how it works).

  3. From the nDynamics menu set choose Fields

    nCloth and Fields
    Apply a radial field to the selected active bricks.

    Figure 14.33. Apply a radial field to the selected active bricks.

  4. Switch to wireframe mode. In the Outliner select the field and use the Move tool to position it just behind the active bricks in the tower. Set the Translate X of the field to −2 and the Translate Y to 1.654.

  5. Select the radial field. In the Channel Box, set Magnitude to 100, Attenuation to 0, and Max Distance to 5. Rewind and play the animation. At frame 20 the bricks will fly out. The field does not affect the bricks until they become dynamic at frame 20.

    This works pretty well; however, the movement of the bricks is a little too uniform and boring. You can make it more interesting by changing the shape of the force exerted by the radial field.

  6. Select the radial field and set Magnitude to 400, Attenuation to 0.5, and Max Distance to 5.

    The Attenuation setting creates a falloff in the strength of the radial field so that force at the center of the field is stronger than at the edges. By raising the Magnitude value, you can counteract the weakening of the field caused by adding attenuation. Setting Max Distance to 3 makes the field more focused. For a discussion of the Attenuation and Max Distance settings, consult Chapter 13.

  7. Rewind and play the animation. At this point the explosion looks pretty good. If the bricks appear to stick together too much, you can lower the Stickiness value to 0.5.

  8. If you find that some bricks still penetrate each other after landing, you can activate the Trapped Check attribute and set a Crossover Push value of 0.1. These attributes are found in the Channel Box for the active bricks in the tower (Figure 14.34). These settings check for penetration between nCloth objects and then force the penetrating objects apart by a small distance.

  9. To reduce sliding on the ground, you can select the groundRigid object and increase Friction to 1. If the bricks appear to be floating above the ground, lower Collision Thickness on the groundRigid object to 0.01.

  10. Save the scene as tower_v03.ma. To see a version of the scene to this point, open tower_v03.ma from the chapter14scenes folder on the DVD (see Figure 14.35).

  11. Before leaving this section, create an nCache of the motion of the bricks (that is, select all the nCloth bricks and to go nCache

    Apply Fields to Select nCloth Objects
    The Trapped Check and Crossover Push settings reduce unwanted interpenetration problems.

    Figure 14.34. The Trapped Check and Crossover Push settings reduce unwanted interpenetration problems.

    The nCloth bricks are a good start to a convincing explosion.

    Figure 14.35. The nCloth bricks are a good start to a convincing explosion.

Traditional Rigid Body Dynamics

For larger scenes with more complex dynamics, using traditional rigid body dynamics may be a better alternative than using nCloth. Setting up rigid body dynamics is fairly straightforward. In this example, you'll use the same stone tower so you can compare the differences in workflow when using nCloth and traditional rigid body dynamics.

  1. Starting from the tower_v01.ma scene in the chapter14scenes directory, expand the active group and select all of the brick nodes in this group. Switch to the Dynamics menu set and choose Soft/Rigid Bodies

    Traditional Rigid Body Dynamics
  2. Expand the passive group, Shift+click all of the bricks in this group, and choose Soft/Rigid Bodies

    Traditional Rigid Body Dynamics
  3. Select the ground and choose Soft/Rigid Bodies

    Traditional Rigid Body Dynamics
  4. By default, there is no gravity attached to the active rigid bodies; to add gravity, you need to create a gravity field. Shift+click all of the members of the active group and choose Fields

    Traditional Rigid Body Dynamics
  5. If you play the scene, you'll see the bricks sag slightly. To animate their dynamics state, Shift+click the members of the active group, and set the Active attribute in the Channel Box to Off. Keyframe this value at frame 19 (see Figure 14.36); then move the timeline to frame 20, set Active to On, and set another keyframe.

  6. To make the bricks explode, select the members of the active group and add a radial field. Position the radial field behind the active bricks and set Magnitude to 400, Attenuation to 0.5, and Max Distance to 5.

  7. Select the active bricks and set their Mass value to 20 (see Figure 14.37). When you play the scene, the action of the bricks is very similar to the nCloth version, although you may notice that the performance on your machine is a little better compared to using nCloth.

    You can keyframe the Active state of the rigid bodies.

    Figure 14.36. You can keyframe the Active state of the rigid bodies.

    Increase the Mass value of the rigid bodies to make the bricks appear heavier.

    Figure 14.37. Increase the Mass value of the rigid bodies to make the bricks appear heavier.

    The solvers used to calculate traditional rigid body dynamics are in the Attribute Editor for the rigidSolver node. The three rigid solver types are Mid-Point, Runge Kutta, and Runge Kutta Adaptive. Mid-Point is the fastest but least accurate type, Runge Kutta is more accurate and slower, and Runge Kutta Adaptive is the most accurate and slowest method. You can leave the setting on Ringe Kutta Adaptive.

  8. Select the ground plane, and set both the Static and Dynamic Friction attributes in the Channel Box to 1.

  9. Shift+click the active bricks and, in the Channel Box, set Dynamic Friction to 0.5. Lower Bounciness to 0.1.

    Static Friction sets the level of resistance for a resting dynamic object against another dynamic object. In other words, if an object is stationary, this means how much it resists starting to move once a force is applied.

    Dynamic Friction sets how much a moving dynamic object resists another dynamic object, such as a book sliding across a table.

    Other settings to take note of include Damping and Collision Layer. Damping slows down the movement of the dynamic objects. If the simulation takes place under water, you can raise this setting to make it look as though the objects are being slowed down by the density of the environment.

    The collision layer specifies which objects collide with other objects. By default all rigid bodies are on collision layer 0. However if you set just the active bricks to collision layer 1, they react only with each other and not the ground or the passive bricks, which would still be on collision layer 0.

  10. Save the scene as rigidBodyTower_v01.ma. To see a version of the scene to this point, open rigidBodyTower_v01.ma from the chapter14scenes directory.

Baking Simulations

It's common practice to bake the motion of traditional rigid bodies into keyframes once you're satisfied that the simulation is working the way you want. This improves the performance of the scene as well as allows you to adjust parts of the animation by hand. Be aware that the number of keyframes affects the size of the scene (the memory space needed for storage on disk).

  1. In the Outliner, Shift+click the active bricks, and choose Edit

    Baking Simulations
  2. In the Channel Box, Shift+click the Translate and Rotate channels.

  3. In the Bake Simulation Options section, set Time Range to Time Slider. Set the Sample By option to 1 so a keyframe is created for each frame of the animation.

  4. Set the Channels option to From Channel Box. Keyframes are created for just the channels currently selected in the Channel Box. This eliminates the creation of extra, unnecessary keys.

  5. Turn on Smart Bake. This setting tells Maya to create keyframes only where the animation requires it instead of creating a keyframe on every frame of the animation.

    The Increase Fidelity option improves the accuracy of the smart bake. Fidelity Keys Tolerance specifies the baking tolerance in terms of a percentage. Higher percentages produce fewer keyframes but also allow for more deviation from the original simulation.

    Other important options include Keep Unbaked Keys, Sparse Curve Bake, and Disable Implicit Control. The Keep Unbaked Keys option keeps any key outside the baked range. Sparse Curve Bake keeps the shape of connected animation curves when baking. Since the bricks are using dynamics, this option does not apply. Disable Implicit Control is useful when the object's animation is being driven by Inverse Kinematic handles and other controls. Again this is not necessary when baking rigid body dynamics.

  6. Activate Increase Fidelity and set Fidelity Keys Tolerance to 1 percent. See Figure 14.38.

  7. Click the Bake button to bake the simulation into keyframes. The animation will play through as the keys are baked.

  8. When the animation is finished, select Edit

    Baking Simulations
  9. Save the scene as rigidBodyTower_v02.ma. To see an example of the scene that uses traditional rigid bodies, open the rigidBodyTower_v02.ma scene from the chapter14scenes folder on the DVD.

    The options for baking keyframes

    Figure 14.38. The options for baking keyframes

    The Graph Editor shows the animation curves for the baked simulation of the active bricks.

    Figure 14.39. The Graph Editor shows the animation curves for the baked simulation of the active bricks.

nParticle Instancing

nParticle instancing attaches one or more specified pieces of geometry to a particle system. The instanced geometry then inherits the motion and much of the behavior of the particle system. For this example, you'll instance debris and shrapnel to a particle system and add it to the current explosion animation. In addition, you'll control how the instance geometry behaves through expressions and fields.

Particle Debris

The goal for this exercise is to add bits of flying debris to the explosion that behave realistically. This means you'll want debris of various sizes flying at different speeds and rotating as the particles move through the air. The first step is to add an nParticle system to the scene that behaves like debris flying through the air.

  1. Open the tower_v03.ma scene from the chapter14scenes directory. Expand the tower group and the active subgroup. Switch to the nDynamics menu set. In the Outliner, select the members of the nClothBricks group and choose nCache

    Particle Debris

    It's easier to work in the scene if you create an nCache on your local hard drive. The scene will play through, and the animation of the bricks will be stored in the data folder of the current project.

  2. Rewind the scene and play it. The animation should play faster, and the bricks should fly out from the tower starting at frame 20.

  3. Choose nParticles

    Editing Cached nDynamics
  4. Choose nParticles

    Editing Cached nDynamics
  5. In the Volume Emitter Attributes rollout, set Volume Shape to Cylinder.

  6. In the Volume Speed Attributes rollout, set Away From Axis to 1, Along Axis to 0.5, Random Direction to 1, and Directional Speed to 4. Click Create to make the emitter (see Figure 14.40).

  7. Switch to wireframe mode. Select emitter1 in the Outliner, and use the Move and Scale tools to position the emitter at the center of the stone tower (set Translate Y to 3.1 and all three Scale channels to 2).

  8. Rewind and play the animation.

    The options for the volume emitter

    Figure 14.40. The options for the volume emitter

    The nParticles start pouring out of the emitter. They collide with the active and passive bricks but pass through the bricks in the back, which are not dynamic at all (see Figure 14.41). You can convert the static bricks to passive colliders; however, this adds a large number of new nRigid nodes to the scene, which may slow down the performance of the scene. These nodes may also have attributes that need to be set. Instead, you can create a single, simple collider object to interact with the nParticles. This object can be hidden in the render.

    The nParticles pass through the nondynamic bricks at the back of the tower.

    Figure 14.41. The nParticles pass through the nondynamic bricks at the back of the tower.

  9. Switch to the Polygon menu set and choose Create

    The nParticles pass through the nondynamic bricks at the back of the tower.
  10. Select the nParticle node, and in the Attribute Editor for the shape nodes set Enable to Off to temporarily disable the calculations of the nParticle while you create the collision object.

  11. Set the timeline to frame 100 so you can easily see the opening in the exploded tower.

  12. Select the cylinder and switch to face selection mode; delete the faces on the top and bottom of the cylinder and in the opening of the exploded tower (Figure 14.42).

    Delete the faces on the top and bottom of the cylinder. Select the faces near the opening of the exploded tower and delete them.

    Figure 14.42. Delete the faces on the top and bottom of the cylinder. Select the faces near the opening of the exploded tower and delete them.

  13. Set the scale and position of the cylinder so it blocks the nParticles from passing through the back of the tower (set Translate Y to 2.639, Scale X and Scale Z to 2.34, and Scale Y to 3.5.)

  14. Rename the cylinder collider. Switch to the nDynamics menu set and choose nMesh

    Delete the faces on the top and bottom of the cylinder. Select the faces near the opening of the exploded tower and delete them.
  15. Select the nParticles and turn Enable back on. Rewind and play the animation; the nParticles now spill out of the front of the tower once it breaks open (Figure 14.43).

    With the collision surface in place, the nParticles pour out of the opening in the front of the stone tower.

    Figure 14.43. With the collision surface in place, the nParticles pour out of the opening in the front of the stone tower.

nParticles and Fields

The effects so far look like a popcorn popper gone bad. To make it look as though the nParticles are expelled from the source of the explosion, you can connect the radial field to the nParticle.

  1. Select nParticle1 and rename it particleDebris.

  2. Open the Attribute Editor for particleDebris. Under the Time Attributes section, right-click on Start Frame and choose Break Connection. This removes the connection between the nParticle shape and the nucleus1 solver's Start Frame attribute. Type 20 into this field. The particle debris won't start emitting until frame 20.

    It's not necessary to have the debris continually spewing from the tower. You need only a certain number of nParticles. You can either set keyframes on the emitter's rate or set a limit to the number of nParticles created by the emitter. The latter method is easier to do and to edit later.

  3. In the Attribute Editor for particleDebris, expand the Emission Attributes rollout. Max Count is set to −1 by default, meaning that the emitter can produce an infinite number of nParticles. Set this value to 1200 (see Figure 14.44). After the number of nParticles reaches 1200, the emitter stops creating new nParticles. Select the emitter and set the rate to 2400. This means that the emitter will create 1200 nParticles in half a second, making the explosion faster and more realistic.

    Set Max Count to 1200, limiting the number of nParticles created by the emitter.

    Figure 14.44. Set Max Count to 1200, limiting the number of nParticles created by the emitter.

  4. To connect the radial field to the particle debris, select the particle debris object and Ctrl+click radialField1 in the Outliner. Choose Fields

    Max Count and nParticle Death
  5. Rewind and play the animation. Not all of the nParticles make it out of the tower; many of the nParticles are pushed down on the ground and toward the back of the collider object. To fix this, reposition the radial field.

    Because the animation of the bricks has been cached, changing the position of the field won't affect their movement. However, if you decide to change the animation of the bricks later on, the edited radial field will change the way the bricks move. In this case you can create a new radial field, disconnect the bricks from the original field, connect them to the new field, and make your changes.

  6. Set the Translate X of the field to 1.347 and the Translate Y to 0.364. (See Figure 14.45.)

  7. Save the scene as tower_v04.ma. To see a version of the scene to this point, open the tower_v04.ma scene from the chapter14scenes folder on the DVD.

    Once you reposition the radial field, the nParticles are sent flying out of the tower.

    Figure 14.45. Once you reposition the radial field, the nParticles are sent flying out of the tower.

If the nCloth bricks do not play back as expected, you may need to relink the nCache. Select one of the nCloth bricks, and open its Attribute Editor to the stoneTowerCache1 tab (the tab may have a different name depending on what name you used when creating the nCache). Use the Base Directory and Cache Name fields to relink the nCache.

nParticle Size and Mass

Next, to create a more interesting behavior for the nParticles you can randomize the mass. Creating randomized mass for an nParticle system using the ramps can be very confusing since the controls all work together. It's much easier to see what's going on if you adjust the Radius Scale settings and then transfer these settings to the Mass Scale settings. This way you get instant visual feedback that tells you how the controls work.

  1. To speed up playback of the scene, Shift+click all of the nRigid bricks and all of the nCloth bricks. Set the Is Dynamic channel to Off.

  2. Select the particleDebris object. In the Attribute Editor for the particleDebrisShape node expand the ParticleSize rollout. In the Particle Size attributes, set Particle Radius to 1. When you play the scene, all the nParticles should be the same size.

  3. In the Radius Scale attributes, set Radius Scale Input to Randomized ID. This randomizes the size of the particles based on their individual ID. If you play the animation, you'll notice that the nParticles are still the same size (see Figure 14.46). This is because the Radius Scale ramp has a value of 1 across the horizontal axis of the ramp. This is like picking a random lottery ball from a bin of balls all labeled 1.

  4. Create a new marker on the right side of the scale, and drag it down to 0.1. Play the animation; now the nParticles are all different sizes. The radius varies between 1 and 0.1. Now the available sizes vary between 0.1 and 1. This is like picking a random lottery ball from a bin of balls with values between 0.1 and 1 (see Figure 14.47).

    Even though Radius Scale is set to Randomized ID, the size of each nParticle is still the same.

    Figure 14.46. Even though Radius Scale is set to Randomized ID, the size of each nParticle is still the same.

    Once you edit the Input Scale ramp, the size of the nParticles becomes randomized.

    Figure 14.47. Once you edit the Input Scale ramp, the size of the nParticles becomes randomized.

  5. The size for each nParticle is randomized using its particle ID number as a seed value. This is still difficult to visualize. Set Radius Scale Input to Particle ID. The randomization factor is now removed. Play the animation. Each nParticle is progressively smaller.

    As the emitter creates nParticles, the Particle ID value increases. As the value increases, the downward slope of the ramp causes nParticles with higher ID values to be smaller. Once the particle ID value is larger than the Max Input value, the nParticles remain at a radius of 0.1.

  6. Set Input Max to 0.5. The nParticles get smaller faster (see Figure 14.48).

  7. Set Radius Scale Randomize to 1. This acts as a multiplier; the larger nParticles at the start of the sequence have a random radius range added to their initial radius. The smaller nParticles are still small, but their sizes within that range are randomized.

  8. Set Radius Scale Input back to Randomize ID and play the animation. The radius is now very random.

    Reducing Input Max while Radius Scale Input is set to Particle ID reduces the number of larger particle sizes.

    Figure 14.48. Reducing Input Max while Radius Scale Input is set to Particle ID reduces the number of larger particle sizes.

    What is interesting is that when Radius Scale Input is set to Randomize ID, you can alter the range of variation by adjusting either or both Input Max and Radius Scale Randomize. If you think of the ramp as representing possible random ranges, lowering Input Max shrinks the available number of random scales available to the randomize function, thus forcing the randomizer to have more "contrast" between values. Increasing Input Max makes more data points available to the randomize function, making a smoother variation between random values and producing less contrast.

    On top of this you can edit the ramp, adding points randomly or bias one side of the ramp to produce more larger radii or vice versa.

    Now we can take this information and apply it to the mass of the nParticles to create a more interesting behavior for the explosion.

  9. Set Radius Scale Randomize to 0, and remove the edits from the radius settings. Set the radius on the nParticles to 0.2.

  10. In the Dynamic Properties section, expand the Mass Scale rollout. Leave Mass at 1. Add a control point to the right side of the ramp, and drag it down so the selected value is 0.1.

  11. Set Mass Scale Input to Randomize ID.

  12. Set Input Max to 0.5.

  13. Set Mass Scale Randomize to 1.

  14. Play the animation. It looks pretty good, but you may notice that some nParticles get stuck in the air (see Figure 14.49).

    Randomizing the mass causes some nParticles to fly and others to get stuck in the air.

    Figure 14.49. Randomizing the mass causes some nParticles to fly and others to get stuck in the air.

    The Balls-style nParticle has a very small Drag value applied by default. nParticles with a very low or zero mass get stuck in the air because of this low value. The low end of the Mass Scale ramp is 0.1. Mass Scale Randomize acts as a multiplier, which in some cases causes the mass of a few nParticles to be 0. This causes them to be strongly affected by the Drag setting. To fix this, you can either set Drag to 0 or lower the Mass Scale Randomize value so that even the nParticles with the smallest mass never approach 0. The downside of removing the drag is that you lose some of the realism of the simulation. It's probably a better idea to lower Mass Scale Randomize.

  15. Set Mass Scale Randomize to 0.05.

  16. Save the scene as tower_v05.ma. To see a version of the scene to this point, open tower_v05.ma.

Instancing Geometry

To create the debris, you'll need to instance some premade geometry to each nParticle. This means that a copy of each piece of geometry will follow the motion of each nParticle.

  1. Continue using the scene from the previous section or open the tower_v05.ma scene from the chapter14scenes directory.

  2. The debris is contained in a separate file, which will be imported into the scene. Choose File

    Instancing Geometry
  3. The debris scene is simply a group of seven polygon objects in the shape of shards. Expand the debris group in the Outliner, Shift+click all of the members of the group, and choose nParticles

    Instancing Geometry

    In the Options window, all of the debris objects are listed in the order in which they were selected in the Outliner. Notice that each one has a number to the left in the list. This number is the index value of the instance. The numbering starts with 0.

  4. In the Particle Object To Instance drop-down menu, choose the particleDebrisShape object. This sets the instance to the correct nDynamic object (see Figure 14.50).

  5. Leave the rest of the settings at the default, and choose Create to instance the nParticles. In the Outliner a new node named instance1 has been created.

  6. Play the scene. Switch to wireframe mode, and zoom in closely to the nParticles so you can see what's going on.

You'll notice that each nParticle has the same piece of geometry instanced to it, and they are all oriented the same way (see Figure 14.51). To randomize which objects are instanced to the nParticles and their size and orientation, you'll create need to create some expressions.

The selected objects appear in the Instanced Objects list. Select the particleDebrisShape node in the Particle Object To Instance options.

Figure 14.50. The selected objects appear in the Instanced Objects list. Select the particleDebrisShape node in the Particle Object To Instance options.

Each nParticle has the same piece of geometry instanced to it.

Figure 14.51. Each nParticle has the same piece of geometry instanced to it.

nParticle Expressions

The new features of nParticles allow you to create more interesting particle effects than in previous versions of Maya without relying on expressions. However, in some situations expressions are still required to achieve a believable effect. If you've never used particle expressions, they can be a little intimidating at first, and the workflow is not entirely intuitive. Once you understand how to create expressions, they can unleash an amazing level of creative potential; combined with the power of the Nucleus solver, there's almost no effect you can't create. Expressions work the same way for both nParticles and traditional Maya particles.

There are two types of expressions you can create for a particle object: creation and runtime. The difference between creation and runtime is that creation expressions evaluate once when the particles are created (or at the start of the animation for particles that are not spawned from an emitter), and runtime expressions evaluate on each frame of the animation for as long as they are in the scene.

A good way to think of this is that a creation expression is like a trait determined by your DNA. When you're born, your DNA may state something like "your maximum height will be 6 feet 4 inches." So your creation expression for height would be maximum height = 6 feet 4 inches. This has been set at the moment you are created and will remain so throughout your life unless something changes.

Think of a runtime expression as an event in your life. It's calculated each moment of your life. If for some reason during the course of your life your legs were replaced with bionic extend-o legs that give you the ability to automatically change your height whenever you want, this would be enabled using a runtime expression. It happens after you have been born and can override the creation expression. Thus, at any given moment (or frame in the case of particles) your height could be 5 feet or 25 feet, thanks to your bionic extend-o legs.

If you write a creation expression for the particles that says radius = 2, each particle will have a radius of 2, unless something changes. If you then add a runtime expression that says something like "if the Y position of a particle is greater than 10, then radius = 4," then any particle that goes beyond 10 units in Y will instantly grow to four units. The runtime expression overrides the creation expression and is calculated at least once per frame as long as the animation is playing.

Randomizing Instance Index

The first expression you'll create will randomize which instance is copied to which nParticle. To do this you'll need to create a custom attribute. This custom attribute will assign a random value between 0 and 6 for each nParticle, and this value will be used to determine the index number of the instance copied to that particular particle.

  1. Select the particleDebris object and expand the Add Dynamic Attributes rollout. Click the General button (see Figure 14.52); a pop-up dialog box appears. This dialog box offers you options to determine what type of attribute will be added to the particle shape.

  2. In the Long Name field type debrisIndex. This is the name of the attribute that will be added to the nParticle. You can name it anything you want (as long as the name does not conflict with a preexisting attribute name). It's best to use concise names that make it obvious what the attribute does.

  3. Set Data Type to Float. A float is a single numeric value that can have a decimal. Numbers like 3, 18.7, and −0.314 are examples of floats.

  4. Set Attribute Type to Per Particle (Array). A Per Particle attribute contains a different value for each particle in the particle object. A Scalar attribute holds the same value for all of the particles in the particle object.

    The General button in the Add Dynamic Attributes section allows you to create your own custom attributes.

    Figure 14.52. The General button in the Add Dynamic Attributes section allows you to create your own custom attributes.

  5. Click OK to add the attribute.

  6. Now that you have an attribute, you need to create the expression to determine its value. Expand the Per Particle (Array) Attributes rollout, and you'll see Debris Index listed. Right-click on the field next to Debris Index and choose Creation Expression (see Figure 14.53).

  7. The Expression Editor opens, and debrisIndex is selected in the Attributes list. Notice that the Particle mode is automatically set to Creation.

  8. In the Expression field type debrisIndex=rand(0,6);. Remember that the list of instanced objects contains seven objects, but the index list starts with 0 and goes to 6 (see Figure 14.54).

    The new Debris Index attribute appears in the list of Per Particle (Array) Attributes. To create an expression, right-click and choose Creation Expression.

    Figure 14.53. The new Debris Index attribute appears in the list of Per Particle (Array) Attributes. To create an expression, right-click and choose Creation Expression.

    Add an expression to randomize the value of the debrisIndex attribute for each nParticle.

    Figure 14.54. Add an expression to randomize the value of the debrisIndex attribute for each nParticle.

    This adds a random function that assigns a number between 0 and 6 to the debrisIndex attribute of each nParticle. The semicolon at the end of the expression is typical scripting syntax and acts like a period at the end of a sentence.

  9. Click the Create button to create the expression. Rewind and play the animation; nothing has changed at this point—the same piece of debris is assigned to all the nParticles. This is because even though you have a custom attribute with a random value, you haven't told Maya how to apply the attribute to the particle.

  10. Expand the Instancer (Geometry Replacement) rollout in the Attribute Editor. In the General Options section, expand the Object Index menu and choose debrisIndex from the list (see Figure 14.55). Now when you rewind and play the animation, you'll see a different piece of geometry assigned to each nParticle.

    Assign the new debrisIndex attribute as the input for the Object Index attribute in the Instancer section of the nParticle's Attribute Editor.

    Figure 14.55. Assign the new debrisIndex attribute as the input for the Object Index attribute in the Instancer section of the nParticle's Attribute Editor.

Connecting Instance Size to nParticle Mass

Next you'll create an expression that determines the size of each nParticle based on its mass. This way larger pieces of debris will move slower than smaller ones.

The size of instances is determined by their Scale X, Scale Y, and Scale Z attributes, much like a typical piece of geometry that you work with when modeling in Maya. This is different from a Balls-type nParticle that uses a single radius value to determine its size.

The size attributes for instanced geometry are contained in a vector. A vector is an attribute with a three-dimensional value, as opposed to an integer or a float, which has only a single-dimensional value.

  1. Select the particleDebris object, and in the Attribute Editor, click the General button to create a new attribute. Set the Long Name value to debrisScale. Set Data Type to Vector and Attribute Type to Per Particle (Array). See Figure 14.56.

  2. In the Per Particle (Array) Attributes section right-click on the field next to debrisScale and choose to create a creation expression.

    Create another attribute and name it debrisScale; this time set Data Type to Vector.

    Figure 14.56. Create another attribute and name it debrisScale; this time set Data Type to Vector.

  3. In the Expression field of the Expression Editor you'll see the debrisIndex expression (note that the name debrisIndex has been expanded; it now says particleDebrisShape.debrisIndex=rand(0,6);. Maya does this automatically when you create the expression.

  4. Below the debrisIndex expression type debrisScale=<<mass,mass,mass>>;. Click Edit to add this to the expression (see Figure 14.57).

    Set the debrisScale attribute to be equivalent to the mass of each nParticle. Add the expression in the Expression Editor.

    Figure 14.57. Set the debrisScale attribute to be equivalent to the mass of each nParticle. Add the expression in the Expression Editor.

    The double brackets are the syntax used when specifying vector values. Using mass as the input value for each dimension of the vector ensures that the pieces of debris are uniformly scaled.

  5. In the Instancer (Geometry Replacement) attributes of the particleDebris object, set the Scale menu to debrisScale (see Figure 14.58).

  6. Rewind and play the animation. The pieces of debris are now sized based on the mass of the nParticles, but of course the mass of some of the particles is so small that the instanced particles are invisible. To fix this you can edit the expression.

    The size of the debris is determined by the mass of each nParticle. In some cases the mass is so small the instanced geometry can't be seen.

    Figure 14.58. The size of the debris is determined by the mass of each nParticle. In some cases the mass is so small the instanced geometry can't be seen.

  7. In the Per-Particle (Array) Attributes section, right-click on debrisScale and choose Creation Expression to open the Expression Editor. In the Expression field, add the following text above the debris scale expression:

    float $massScale = mass*3;
  8. Now edit the original debrisScale expression, as shown in Figure 14.59, so it reads:

    debrisScale = <<$massScale, $massScale, $massScale>>;

    By using the float command in the Expression Editor, you're creating a local variable that is available to be used only in the creation expressions used by the nParticle. The same variable and its value are not available for use in runtime expressions. The variable is preceded by a dollar sign. The $massScale variable is assigned the mass multiplied by three.

  9. Click Edit to implement the changes to the expression. Rewind and play the animation. It's an improvement; some debris pieces are definitely much bigger, but some are still too small. You can fix this by adding a clamp function. Make sure you click the Edit button in the editor after typing the expression.

    A clamp sets an upper and lower limit to the values generated by the expression. The syntax is clamp(lower limit, upper limit, input);.

    Edit the expression so the size of each nParticle is equal to the mass multiplied by three.

    Figure 14.59. Edit the expression so the size of each nParticle is equal to the mass multiplied by three.

  10. Edit the expression for the massScale variable so it reads float $massScale=clamp(2,5,mass*10);. Make sure you click the Edit button in the editor after typing the expression (Figure 14.60).

  11. Play the animation. Now you have a reasonable range of sizes for the debris, and they are all based on the mass on the particles.

  12. In the Attribute Editor for the particleDebris, set Shading Type to Point so you can see the instanced geometry more easily.

    After you add the clamp expression, the range of size for the debris is more reasonable.

    Figure 14.60. After you add the clamp expression, the range of size for the debris is more reasonable.

Rotation Expressions

Next you'll add some expressions to animate the rotation of the nParticles. The first task is to establish an initial random rotation, and then a runtime expression can be added to tie the velocity of the nParticles to their rotation as they move through space.

  1. Create a new Per Particle vector attribute and name it debrisRotate. Follow steps 1 and 2 from the previous section to do this.

  2. Make a creation expression for debrisRotate. In the Expression Editor, add these lines. Make sure you click the Edit button in the editor after typing the expression (Figure 14.61):

    float $randX = rand(0,180);
    float $randY = rand(0,180);
    float $randZ = rand(0,180);
    
    debrisRotate = <<$randX, $randY, $randZ>>;

    Notice that for this expression you want to have a different value for each dimension of the debrisRotate vector, so each piece of debris is rotated randomly on each axis as opposed to the debrisScale attribute, which needed the same value applied to each dimension of the vector. Each variable produces a different random value between 0 and 180 for each particle.

    To add a little more realism to the movement of the instances, you can have them rotate as they fly through the air. There are a number of ways to do this. For this example you can create a simple runtime expression that increments the rotation of each piece by the magnitude of its velocity.

    Add an expression to randomize the rotation of each instance.

    Figure 14.61. Add an expression to randomize the rotation of each instance.

    The mag function is a simple way to convert a vector value into a float by giving you the length of the vector. Magnitude (not to be confused with the magnitude of a field in this sense) is the square root of the sum of the square of each coordinate in the vector. It sounds more complicated than it is. The formula looks like this:

    Equation 14.1. 

    Add an expression to randomize the rotation of each instance.

    In this expression, you'll take the magnitude of the velocity of the particle and add it to the rotation of the instances. This is done in a runtime expression so it executes each frame. When you add a float to a vector, Maya returns the result as a vector. So the question you may be asking now is, why would you want to convert the velocity, which is a vector, into a float, and then add the float to the rotation, which is also a vector, only to get a vector as the result? In other words, why not just add velocity to rotation and keep them all vectors? Well, the reason is that when you add a float to a vector, the same value is added to each coordinate of the vector. In other words:

    n + <<x,y,z>> = <<n+x,n+y,n+z>>

    which gives you a different result than adding the velocity and rotation, which looks more like this:

    <<x1,y1,z1>>+<<x2,y2,z2>>= <<x1+x2,y1+y2,z1+z2>>

    The upshot is that adding velocity as a vector to rotation gives you a wobbly type of motion as opposed to the constant rotation you get by adding the magnitude of the velocity to rotation.

    The reason you want to use the magnitude of the velocity is so the instance stops rotating when it stops moving (that is, when velocity = 0).

  3. In the Expression Editor click the radio button to switch to Runtime After Dynamics mode.

  4. In the Expression field type (see Figure 14.62):

    debrisRotate=debrisRotate+mag(velocity);
    Add a runtime expression to increment the rotation of each nParticle by the magnitude of its velocity.

    Figure 14.62. Add a runtime expression to increment the rotation of each nParticle by the magnitude of its velocity.

  5. Click Create to make the expression. In the Instancer (Geometry Replacement) section of the Attribute Editor, set Rotation to debrisRotate (see Figure 14.63). Leave the other settings at the default. Rewind and play the animation.

  6. Set the timeline to 300 and create a playblast of the animation so you can see the explosion in real time.

  7. Save the scene as tower_v06.ma.

    Overall it's a pretty respectable start to an explosion effect. In the next section you'll add some smoke trails to the debris.

    The rotation of each instance is now randomized and animated according to the velocity of the nParticle.

    Figure 14.63. The rotation of each instance is now randomized and animated according to the velocity of the nParticle.

Creating Smoke Effects

To complete the look of the explosion you can use the cloud nParticle type to add a smoke trail to each of the pieces of debris. The cloud nParticle type uses a special shader to create the look of smoke in a software render. The thick cloud nParticle uses a special fluid shader to create a realistic-looking cloud. It takes longer to calculate and render than the standard cloud nParticle. Fluids are discussed in Chapter 16.

Using the Cloud nParticle Style

To add a smoke trail to the debris you can actually make each nParticle of the particleDebris object an emitter.

  1. Continue with the scene from the precious section or open the tower_v06.ma scene from the chapter14scenes directory.

  2. Choose nParticles

    Using the Cloud nParticle Style
  3. In the Outliner, select the particleDebris object. Choose nParticles

    Using the Cloud nParticle Style
  4. In the Outliner a new nParticle node has been added to the scene. Rename this node smokeParticle. If you expand the particleDebris object, you'll see that an emitter has been parented. This is the emitter for the smokeParticle (Figure 14.64).

    Since there are a total of 1200 particleDebris objects that will be emitted in the scene, each one of these will emit 40 cloud nParticles per second. This quickly adds up to a lot of nParticles. To avoid bogging the scene down, set a short life span on the smokeParticles.

    Add a new nParticle to the scene and rename it smokeParticle. Parent the emitter for this nParticle to the debrisParticle node.

    Figure 14.64. Add a new nParticle to the scene and rename it smokeParticle. Parent the emitter for this nParticle to the debrisParticle node.

  5. Select the smokeParticle object. Set Life Span to Random Range. Set Life Span Value to 2 and Life Span Random to 2. This means each cloud particle lasts between 1 and 3 seconds.

  6. Set Radius in the Particle Size rollout to 1.3. Expand the Radius Scale attributes and set Radius Scale Input to Age. Add two control points to the Radius Scale ramp, and edit the position of the points so that the ramp starts at 0.1 and slopes up smoothly to the right.

  7. Set Radius Scale Randomize to 0.1.

  8. In the Dynamic Properties section set Drag to 0.1, and make sure Ignore Solver Gravity is activated (see Figure 14.65). The smoke particles should not fall to the ground.

  9. Scroll down to the Emission Attributes section and set Inherit Factor to 0.5. This causes the smoke particle to inherit some of the motion of the particleDebris object, giving it a more believable motion as it flies out from each piece of debris.

    Edit the Dynamic Properties settings for the smokeParticle object in the Attribute Editor.

    Figure 14.65. Edit the Dynamic Properties settings for the smokeParticle object in the Attribute Editor.

  10. Scroll down to the Opacity Scale attributes in the Shading rollout. Set Opacity Scale Input to Age. Edit the Opacity Scale ramp so it starts at 0.7 on the left and slopes down to 0 on the right, as shown in Figure 14.66.

  11. Expand the Color attributes. Set Color Input to Age. Edit the Color ramp so it is bright yellow on the left side, fading quickly to light gray and then gradually to dark gray on the right of the ramp. This makes each smoke trail bright yellow on the end closest to the flying debris, fading out to dark gray over time.

  12. Expand the Incandescence section. Set Incandescence Input to Age. Edit the ramp so there is a small sliver of bright yellow on the left side that quickly fades to black.

    The shading settings for the smokeParticle

    Figure 14.66. The shading settings for the smokeParticle

  13. Select the emitter attached to the debris particle. Set a keyframe on the Rate attribute on frame 90. Move the timeline to frame 120, and set Rate to 0; set another keyframe.

  14. To create the effect of the smoke drifting upward, add some wind to the Nucleus solver. First select the particleDebris object and activate the Ignore Solver Wind option in the Dynamic Properties rollout so that the debris is not affected by the wind.

  15. Open the Nucleus solver and set Wind Speed to 3. Set Wind Direction to 0, 1, 0 so it pushes upward. Set Noise to 0.5 to add some turbulence.

  16. Save your scene. Rewind the animation and create a playblast to see the explosion in action (Figure 14.67). It should take anywhere from 5 to 10 minutes to create the playblast.

  17. Save the scene as tower_v07.ma. To see a finished version of the scene open tower_v07.ma from the chapter14scenes folder on the DVD.

    A playblast of the animation reveals a very dramatic explosion worthy of an episode of Mythbusters.

    Figure 14.67. A playblast of the animation reveals a very dramatic explosion worthy of an episode of Mythbusters.

The Bottom Line

Use nCloth

nCloth can be used to make polygon geometry behave dynamically to simulate a wide variety of materials. Using the presets that come with Maya, you can design your own materials and create your own presets for use in your animations.

Master it

Create the effect of a cube of gelatinous material rolling down the stairs.

Combine nCloth and nParticles

Because nCloth and nParticles use the same dynamic systems, they can be easily combined to create amazing simulations.

Master it

Make a water balloon burst as it hits the ground.

Use nCloth for rigid body simulations

nCloth can be used to simulate rigid dynamics as well as soft surfaces. The Concrete preset is usually the best place to start when creating an nCloth rigid body. nCloth objects have a large number of settings that can give you more control over their behavior than you would get using traditional rigid bodies.

Master it

Animate a wrecking ball destroying a wall of nCloth bricks.

Use traditional Maya rigid body dynamics

Traditional rigid body dynamics are not quite as powerful as nCloth objects, but they do calculate much faster and work better for simulations involving a large number of interacting pieces.

Master it

Animate a series of dominoes falling over.

Instance geometry to nParticles

Modeled geometry can be instanced to nParticles to create a wide variety of effects.

Master it

Create the effect of a swarm of insects attacking a beach ball.

Create nParticle expressions

nParticle expressions can be used to further extend the power of nParticles. Using expressions to automate instanced geometry simulations is just one of the ways in which expressions can be used.

Master it

Improve the animation of the insects attacking the beach ball by adding different types of insects to the swarm. Randomize their size, and create expressions so that larger insects move more slowly.

Create smoke effects

Using the cloud nParticle type, smoke can be added to a simulation. nCloth objects and nParticles can be turned into emitters to emit the smoke.

Master it

In the explosion scene from this chapter, make the nCloth bricks emit a smoke trail as they fly out from the tower.

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

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