Lesson 3: Wrapping the high resolution mesh and simulating the pants during animation
 
 
 

In this lesson you will:

Lesson setup

To ensure the lesson works as described, do these steps before beginning:

  1. If you have not already done so, copy the nCloth Advanced Tutorial folder from the following location: http://www.autodesk.com/maya-advancedtechniques. Then, set the nCloth AdvancedTechniques directory as your Maya project.

    For this lesson, you need to access Maya geometry cache files in addition to the lesson scene file.

  2. Open the scene file named Character_LowRes_3.mb.

    This file can be found in the AdvancedTechniques directory that you set as your Maya project.

Wrapping the high resolution mesh

In this lesson, you use a wrap deformer to create an influence object that causes the high resolution mesh to behave like the simulated low resolution mesh. For more information about the wrap deformer, see What are deformers?.

To wrap the high resolution mesh

  1. In the Outliner, expand Character_HighRes, and show the Pants_HighRes object by selecting it, and then selecting Display > Show > Show Selection.

  2. -select the nCloth pants.
  3. From the Animation menu set, select Create Deformers > Wrap.

    A wrap node appears in the Attribute Editor, and in the Outliner, you can see that the Pants_LowResBase object has been added to the Character_LowRes group.

    NoteYou may need to expand Character_LowRes to see the Pant_LowResBase object in the Outliner.

  4. In the Attribute Editor, click the wrap1 tab.
  5. In the Wrap Attributes section, turn on Exclusive Bind.

    With Exclusive Bind turned on, each surface point (vertex) on the Pants_HighRes object is constrained or affected by the Pants_LowRes object vertices. This ensures that the Pants_HighRes object inherits the properties of the simulated nCloth pants.

  6. Hide the Pants_LowRes object, and play back the simulation.

When you play back the simulation, you notice the following:

With the high polygon count of the Pants_HighRes object, one would expect to see the simulation slow down. However, this is not the case, since the Nucleus solver is not simulating any data associated with the Pants_HighRes object. All Nucleus calculations involved in the simulation are still performed on the low resolution nCloth pants. The behavior of the Pants_HighRes object is being influenced by a new instance of the simulated nCloth pants, the Pants_LowResBase object.

The Pants_LowResBase object is the base shape for the deformation of the Pants_HighRes object, which is the wrap influence object. Like all wrap deformers, any difference in position, orientation, or shape between the base shape and the wrap influence object results in a deformation of the surface being influenced by the wrap deformer.

Simulating the nCloth pants on an animated character

In this section, you import geometry caches for the nRigid body and nRigid shoe objects and begin simulating the nCloth pants object while the body and shoes are animated.

Lesson setup

To ensure that this section of the lesson works as described, do these steps before beginning:

  1. Hide the Pants_HighRes object by selecting Pants_HighRes in the Outliner, and selecting Display > Hide > Hide Selection.
  2. Show the Pants_LowRes object by selecting Pants_LowRes in the Outliner, and selecting Display > Show > Show Selection.
  3. If you have not already done so, set the nCloth AdvancedTechniques directory as your Maya project.

Importing geometry caches

Before simulating the nCloth pants on the animated character, you need to import the geometry caches which animate the character’s body and shoes.

To import the geometry caches to animate the body and shoe meshes

  1. In the scene view, select the nRigid_Body object.
  2. From the Animation menu set, select Geometry Cache > Import Cache.
  3. In the Import window that appears, select Body_Animation.mc and click Import.
  4. In the scene view, select the nRigid_Shoes object.
  5. From the Animation menu set, select Geometry Cache > Import Cache.
  6. In the Import window that appears, select Shoes_Animation.mc and click Import.

You can play back the simulation to see how your nCloth pants behave when they are simulated with the animated character. However, it is difficult to closely inspect the simulation without being able to scrub the Time Slider. To make it easier to identify problems in the simulation, create a cache for the nCloth pants object. For information about nCaches, see nCaching overview.

To cache the nCloth pants simulation

  1. In the scene view, select the nCloth pants.
  2. From the nDynamics menu set, select nCache > Create New Cache > .

    The Create nCache Options window appears.

  3. In the Create nCache Options window, do the following:
    • Set the Cache directory to the folder where you want your caches saved.
    • Set the Cache Name to nCloth_PantsShape.
    • Beside File distribution, select One File.
    • Click Create.
  4. Play back the simulation.

Identifying problem areas in the simulated nCloth

When you play back the simulation, you notice the following problems with the nCloth pants object:

Dolly and tumble the scene while scrubbing the Time Slider so that you can closely observe each problem area.

Editing Substeps

A useful first step to fixing simulation issues is to increase the number of Nucleus solver Substeps and Max Collision Iterations. Substeps specify the number of times per frame that the Maya Nucleus solver calculates everything involved in the simulation, from the collision detection between nCloth and passive collision objects, to the effects of Dynamic Properties attributes and the dynamic constraints. Adjusting Substeps allows you to control how the simulation time is broken up into calculation segments. Simulation quality and collision accuracy generally improve with increasing substeps values. Max Collision Iterations specify the maximum number of collision iterations per frame for this Maya Nucleus solver. A high number of Substeps or Max Collision Iterations may result in slower solving.

Depending on the complexity of your scene, the default values of 3 Substeps and 4 Max Collision Iterations may work well when simulating a static scene in which only gravity and wind are affecting the nCloth objects. When the nCloth begins to move and self collide, higher Substeps values are required to ensure accurate collision detection, especially on fast-moving objects. Increasing Max Collision Iterations becomes important when the number of nCloth collisions increases, and when dynamic constraints are added to your object. For more information, see Substeps and Max Collision Iterations.

To edit Substeps and Max Collision Iterations

  1. In the Attribute Editor, click the nucleus1 tab.
  2. In the Solver Attributes do the following:
    • Set Substeps to 7.
    • Set Max Collision Iterations to 8.

  3. Before playing back the simulation to see the results of these new settings, you need to replace the simulation's previous nCache or create a new nCache. Otherwise, your changes will not appear in the simulation.

    Replacing a cache file overwrites the existing nCache with a new file. Since you will cache your simulation a number of times in the lesson, using Replace Cache is the best way to reduce the number of cache files saved to your hard disk. To replace the previous nCache, select nCache > Replace Cache.

  4. When the Create Cache Warning appears, click Replace Existing.
  5. Play back the simulation.

When you play back the simulation, you notice that starting at frame 1030, the polygon faces in the area of the knees look more realistic. The cloth deformation is now spread over more faces, making it look more realistic. However, not all of the simulation problems were resolved. Higher Substeps and Max Collision Iterations may be required.

Because increasing Substeps and Max Collision Iterations cause the Nucleus solver to perform more calculations each simulated step, it slows down the simulation. To develop a balance between simulation quality and performance, it is useful to identify the specific areas or frames in the simulation that require higher Substeps and Max Collision Iterations. You can then animate the Substeps and Max Collision Iteration values over the duration of the simulation by setting keyframes.

To set keyframes for Substeps and Max Collision Iterations

  1. In the Time Slider, go to frame 1000.
  2. In the Attribute Editor, select the nucleus1 tab.
  3. In the Solver Attributes section, do the following:
    • Set Substeps to 5.
    • -click the Substeps attribute field, and select Set Key from the pop-up menu.

    • Set Max Collision Iterations to 6
    • -click the Max Collision Iterations attribute field, and select Set Key from the pop-up menu.
  4. Continue setting keyframes in your simulation using values from the following table:
    Frame Substeps Max Collision Iterations
    1019 5 6
    1020 7 8
    1022 9 12
    1025 15 20
    1060 9 12
  5. Cache your simulation ( nCache > Replace Cache) and play it back.

Fine tuning nCloth attributes

When you play back the cache, you notice that the overall quality of the simulation has improved. However, there are still problem areas in the waist and in the crotch. For example, at frame 1030, poor self collisions in the area of the crotch are resulting in undesirable polygon deformations. To improve the quality your simulation, you can start to fine tune the Dynamic Properties attributes.

When fine adjusting nCloth attributes, such as the Dynamic Properties attributes, it is useful to create a duplicate of the nCloth mesh at different frames of your simulation. When you play back the simulation, you can then compare your currently simulated nCloth against the duplicate mesh and evaluate:

To help solve the problems in the crotch area, you can increase Bend Resistance so that the edges of the polygons better retain their shape. For more information, see Bend Resistance.

To create a duplicate mesh and edit Bend Resistance

  1. In the Time Slider, go to frame 1030.
  2. In the scene view, select the nCloth pants and select Edit > Duplicate.
  3. In the Outliner, select Pants_LowRes1 and in the scene view, move the mesh object to the right of your character.

  4. In scene view, select the original nCloth pants object, and in the Attribute Editor, click the nCloth_PantsShape tab.
  5. In the Dynamics Properties section, set Bend Resistance to 5.

  6. Cache the simulation ( nCache > Replace Cache) and play it back.

When you play back the simulation, you notice that the cloth is bending more realistically in the crotch area. In the Time Slider go to frame 1030, and compare your simulated nCloth to the duplicate mesh. Dolly and tumble the scene so that you can closely observe the improved area.

Editing Quality Settings and resolving interpenetrations

When you play back the simulation and compare the problem areas with duplicate meshes, you notice that the problem areas between frame 1030 and 1035 still persist.

Another way to improve simulation quality is to edit the Self Collision Flag and Quality Settings attributes, which affect the nCloth component collisions and self collisions. By default, Self Collision Flag is set to VertexFace, which means that the nCloth object's vertices and faces collide with each other. Setting Self Collision Flag to Full Surface sets all of the object components (vertices, edges, and faces) to participate in self collisions.

When simulating a low resolution mesh, increasing the number of potential self collision areas of the nCloth object is important because of the mesh’s low vertex, edge, and face count. Setting Self Collision Flag to Full Surface on high resolution nCloth meshes increases simulation time. This is less of an issue with low resolution meshes, which makes this alternative much more appealing for iterative simulation tests. For more information, see Collisions.

To edit the Self Collision Flag attribute

  1. In the Time Slider, go to frame 1033.
  2. In the scene view, select the nCloth pants and select Edit > Duplicate.
  3. In the Outliner, select Pants_LowRes2 and in the scene view, move the mesh object to the left of your character.

  4. In scene view, select the original nCloth pants object, and in the Attribute Editor, click the nCloth_PantsShape tab.
  5. In the Collisions section, set Self Collision Flag to Full Surface.

After initial fine adjustments to the Self Collision attribute, you edit the Quality Settings to improve collisions and self collisions in the simulation. This will resolve any remaining interpenetrations between the nCloth pants object and the nRigid shoes. You can also increase Thickness or create a Thickness Map to improve collision detection.

To edit the Quality Settings

  1. In the Attribute Editor, select the nCloth_PantsShape tab.
  2. In the Quality Settings section, do the following:
    • Make sure Max Iterations is set to 10000.
    • Turn on Trapped Check.
    • Turn on Self Trapped Check.

  3. Cache the simulation and then play it back.

In the Time Slider, go to frame 1033, and compare your simulated nCloth to the duplicate mesh. Dolly and tumble the scene so that you can closely observe the problem area. When you are satisfied with your observations, delete the Pants_LowRes1 and Pants_LowRes2 duplicate meshes.

Comparing the wrapped nCloth simulation with the simulated high resolution mesh

To complete the attribute adjustments of the nCloth pants object, you compare the wrapped nCloth simulation to the reference character object (the original simulated high resolution mesh).

To compare the low and high resolution nCloth meshes

  1. Hide the Pants_LowRes object, selecting it in the Outliner, and then selecting Display > Hide > Hide Selection.
  2. Show the Pants_HighRes object by selecting it in the Outliner, and then selecting Display > Show > Show Selection.
  3. Using the Display Layer editor, turn on Visible to display the Reference_Character object in the scene view.
  4. Hide the Reference_Shirt object, selecting it in the Outliner, and then selecting Display > Hide > Hide Selection.
  5. In the Shading menu, turn off Wireframe on Shaded.
  6. Scrub through the Time Slider to compare how the nCloth meshes behave in the animation. Dolly and tumble the scene so that you can closely observe the problem area.
    NoteIf the Reference_Character is not animated in the scene view when you play back or scrub the simulation, you may need to reconnect the reference character’s caches to their respective objects. See Reconnecting objects to existing caches.

Reconnecting objects to existing caches

  1. In the Outliner, select the object whose cache you want to reconnect.
  2. In Attribute Editor, select the object’s cache node.

    For example, if you are reconnecting the cache for the character’s body, select the Body_AnimationCache1 tab.

  3. In the Cache File section, make sure that Base Directory is set to the AdvancedTechniques project data folder by clicking the icon.
  4. In the Browse for Folder window, click OK.

Observations

When you play back or scrub the simulation, you notice the following:

TipTo force the pant legs of the nCloth pants to simulate in the same way as the pant legs on the reference character object, you can adjust the Friction attribute.