nCloth Zipper

This example will show you how to create a zipper for your nCloth.

Set up the zipper

In order to create a zipper, you will first create a pair of nCloth objects for the zipper to connect.

To create the Input Mesh for your cloth

  1. Select Create > Polygon Primitives > Plane > .

    The Polygon Plane Options window opens.

  2. Select Edit > Reset Settings.
  3. Set the Plane options as follows:
    • Width divisions: 6
    • Height divisions: 6
  4. Click Create.

    Maya creates a plane centered at the origin.

  5. Select Create > Polygon Primitives > Plane.

    A second plane identical to the first plane is created in the same position.

To place the planes side by side

  1. Select the second plane.
  2. Open the Channel Box.
  3. Set TranslateX to 1.

    The second plane moves to the right such that the edges of the two planes touch.

To make the planes nCloth

  1. Click the first plane and shift-click the other to select both.
  2. Select nCloth > Create nCloth.

    Maya makes the planes nCloth.

  3. Playback the simulation.

    The planes fall.

To prevent the cloth from uniformly falling, you need to constrain its corners.

To constrain the corners of the cloth

  1. Shift -select both nCloth planes.
  2. Right-click the nCloth and select Vertex from the marking menu to switch to Vertex mode.

    The planes’ vertices appear.

  3. Select the vertices on the outer corners of each plane for a total of four selected vertices.
  4. Select nConstraint > Transform Constraint.
  5. Playback the nCloth simulation.

    The pair of nCloths are now held in place by their corners. Both cloths fall at the point where they join.

To join the two nCloths at their center

  1. Select both nCloths.
  2. Switch to Vertex mode.

    The nCloth vertices appear.

  3. Select all the vertices for both nCloths along their intersection.
    Note:

    Since the edges of both nCloths are on top of each other you may have difficulty choosing all the vertices on both planes. To make this process a bit easier, you can move the planes slightly apart from each other and then select the vertices. If you do this, make sure to return the planes to their original position before continuing with this example.

  4. Select nConstraint > Component to Component .
  5. Playback the nCloth simulation.

    The two nCloth objects are now joined at their center.

  6. Open the Attribute Editor and select the DynamicConstraintShape tab.
  7. Set the Constraint Method to Weld.

    The Weld setting ensures that there is no space between the two nCloth objects.

Control the zipper's state

To control the state of the zipper, you need to add a ramp texture to the Strength Map Attribute. This allows you to control the strength of the component to component bond between the two nCloth objects.

To add a ramp texture

  1. Select the first nCloth.
  2. Select Windows > General Editors > Hypergraph: Connections.

    Maya displays the Hypergraph: Connections window.

  3. Select the nComponent3 node.
  4. Open the Attribute Editor and click the small checkered box next to the Strength Map field.

    The Create Render Node window appears.

  5. In the right panel of the Create Render Node window, click .
  6. In the Ramp Attributes section of the Attribute Editor click the box with an x at the center of the color ramp to delete the green marker.
  7. Select the small red circle at the bottom left of the color ramp. The colored box next to Selected Color should change.
  8. Click the colored box next to Selected Color

    The Color Chooser that appears.

  9. Select black and move your mouse off the Color Chooser to close it.

    The bottom of the color ramp changes to black.

  10. In the Ramp Attributes section of the Attribute Editor select the small blue circle at the top left of the color ramp. The colored box next to Selected Color should change.
  11. Click the colored box next to Selected Color

    The Color Chooser appears.

  12. Select white and move your mouse off the Color Chooser to close it.

    The top of the color ramp changes to white.

  13. Playback the simulation.

    When you adjust the Selected Color slide bar during playback, the two planes zip and unzip.

Although adjusting the Selected Color produces the desired result, it is not the only possible method for controlling an nCloth zipper. You can use Texture Placement to achieve the same effect with a greater degree of control.

To edit the Texture Placement

  1. In the Ramp Attributes section of the Attribute Editor select the small circle at the bottom left of the color ramp.
  2. Set Selected Position to 0.45.
  3. Select the small circle at the top left of the color ramp.
  4. Set Selected Position to 0.5.
  5. Select the place2dTexture1 tab.
  6. Set Repeat UV to 1.0, 0.25.
  7. Playback the simulation.

    You can use the second value of the Offset attribute to adjust the state of the zipper during playback. A value of 0.55 produces a fully zipped state whereas a value of 0.175 produces a fully unzipped state.

You can now animate the zipper by keyframing the Offset value.

Create the zipper object

To control the zipper, you will need to create a zipper model and a hair follicle.

To create a controlling follicle

  1. Select the first plane.
  2. In the FX menu set select nHair > Create Hair > .

    The Create Hair Options window appears.

  3. Select Edit > Reset Settings.
  4. Set the hair options as follows:
    • U Count: 1
    • V Count: 1
  5. Click Create Hairs.

    A single hair follicle with a number of hairs appears. For this example you will only make use of the follicle, not the actual hair.

  6. Open the Outliner.
  7. Select hairSystem1 and pfxHair1 and press the Delete key.
  8. Select hairSystem1Follicles and then pPlane1Follicle.
  9. Select curve1 and press the Delete key.

    You now have a single follicle that you can use to control the zipper. You now need a model to represent the zipper.

To create a zipper model

  1. Select Create > Polygon Primitives > Cube > .

    The Polygon Cube Options window appears.

  2. Select Edit > Reset Settings.
  3. Click Create.
  4. Open the Attribute Editor.
  5. Select the pCube1 tab and set the Scale attribute to 0.092, 0.026, 0.094.
  6. Set the scene view to Vertex mode.
  7. Select the four vertices on the far side of the cube and select the scale tool.
  8. Slowly drag the ScaleX handle to the left until the cube forms a rough wedge shape. By dragging the ScaleX handle, you ensure that the end of the cube is only resized in the X direction.
  9. Open the Outliner.
  10. Select zipper in the Outliner and middle drag it onto pPlane1Follicle5050.
  11. The zipper object is now attached to the hair follicle you created earlier.
  12. Playback the simulation

    The zipper now sticks to the cloth.

Creating an expression for a zipper

In order for the zipper to behave properly it needs to be associated with the Offset V attribute that controls the state of the two nCloth objects. To do this you need to assign an expression that will drive the zipper’s interaction.

To position the zipper

  1. Select pPlane1FollicleShape5050.
  2. In the Attribute Editor set Parameter U to 1.0.

    The zipper should now be aligned with the center of the cloth. Adjusting the Parameter V attribute from 0 to 1.0 should now also move the zipper up and down the length of the edge.

To create an expression

  1. Select Windows > Animation Editors > Expression Editor.

    The Expression Editor window appears.

  2. Enter the following into the Expression field.

    place2dTexture1.offsetV = (1-pPlane1FollicleShape5050.parameterV) * 0.25 + 0.25

  3. Click Create and then Close.

Your zipper is now finished. To open and close the zipper you can now adjust the Parameter V attribute of the pPlane1Follicle5050.