The general workflow is to do a bind skin on your cloth to your skeleton before making it nCloth. It will then deform and translate with your character when you set its start position. An additional advantage is that one can use input mesh attract on the nCloth to control how much the cloth is dynamic and how much it follows the skeletal animation. It is important that the skinned cloth be weighted to avoid self intersection and collision on deformation if you you wish to use it to define the starting cloth position. However it is OK if the deformation stretches the cloth because the cloth relaxation step can resolve this. A little bit of intersection with the body is OK as well, as the trapped check on the passive nRigid node can resolve simple overlaps. One can bind the cloth to the skeleton or apply the character's skin as a wrap deformer to the cloth. This latter setup is quicker to get working as one may not need to paint weights, however binding to the skeleton(bind skin) will evaluate faster.
Lets setup some cloth on a simple rigged character:
1. Unzip and load the file TunShu_BindClothSkin.ma
TunShu_BindClothSkin.zip (scroll to the bottom to download related material)
This is a character file (courtesy of Yiqun Chen) with a simple rig and clothing that is already bound to the skeleton and weighted. There is no nCloth in this file yet.


2. Select the shirt and do MENU "nCloth:Create Ncloth"
3 Select the pants and the body and do MENU "nCloth:Create Passive"
For now we will not bother making the pants cloth but simply collide with them. When you playback the cloth will move but very slowly because it thinks the character is about 150 meters tall.
4. On the node nucleus1 set the "Space Scale" to 0.01. Dynamics treat units as being meters regardless of the unit setting, and this character was modelled in cm. Lowering the space scale value will increase the effect of gravity, and dealing with full gravity generally requires higher substeps and stretch resistance settings than the default. Now when you playback the cloth should fall and sag.

5. Button the shirt together. To accomplish this we will constrain some points along the flap.
First select 6 cvs as shown:

On the constraintShape node set:
Constraint Methode = "Rubber Band"
This allows the flaps to get closer than the constaint distance. The links are like strings instead of springs. However in practice the flaps won't get any closer because they are already within the selfCollision width.


The stretch around the new "button" constraint looks bad and the overall cloth is two stretchy. The default self collision method is vertex which is rather crude. Set nClothShape1:SolverDisplay to selfCollisionThickness to see what is going on:

selfCollideWidthScale = 1
Thickness = 0.5
SelfCollisionFlag = VertexFace
StretchResistance = 100
CompressionResistance = 40
Bend Resistance = 1
(note that you won't see the effect of changing selfCollisionFlag on the width display until you refresh or tumble the display)


nClothShape1.MaxSelfCollideIterations = 12
nucleus1.Substeps =8
nucleus1.MaxCollisionIterations = 10
On playback the shirt should not stretch too much and the collisions are now OK, although it is a bit slower.

a) Create an initial pose at the start frame taking care that the cloth does not self intersect.
b) Key this pose by right mousing over any of the control boxes and selecting "Key All" (drag to right).
c) Turn off "Enable" on the nucleus node to temporarily disable the cloth solve.
d) Select the shirt and do MENU "NCloth: Display Input Mesh". This hides the solved mesh and displays the input one which is simply the bind skin mesh with no dynamics.
e) Change the frame, edit the pose and key the pose( as in "b" above ), repeating until you have an animation you like.
f) Simulate and cache. Select the shirt, do "NCloth: Display Current Mesh", turn enable ON for the nucleus node and then cache the range of your animation. It is useful to set the playback range to the range you wish to cache so that when scrubbing you don't go outside the cached range( which then invokes a solve ).
If you get artifacts in your animation such as a vertex that gets locked in self collision try enabling selfTrappedCheck on the nCloth node. This often fixes things. Alternately you can increase substeps or check to make sure there is no self interpenetration at the start frame. The other thing to check for is cloth being trapped between the rigid animation. For example if the arm penetrates into the body trapping cloth with it, the cloth will do its best to push out from the body when the arm come out of the body, but it could cause self collision problems if two bits of cloth were trapped. Self trapped check helps, but it is best to avoid the penetration of the arm into the body in the first place. For cases of extreme penetration the pushout attribute on the body nRigid node can also help.
8. Set Rest Shape for cloth to the bind pose. Select the shirt and do MENU: "Windows: HyperGraph: Connections".



The node "shirtWithPockeShape2Orig" is now defined as the shape the cloth is trying to achieve in terms of stretch rest lengths and bend rest angles. The translation/rotation of this mesh do not matter, only its shape. Note that the effects of rigidity and input mesh attract will still attract to the underlying input cloth mesh, not this one, which is only used for bend, stretch and compression resistance.
The bind skin deformation of the input cloth mesh can stretch and bend the base shape of the cloth. By default the simulation uses the shape at the start of the simulation as the rest shape. Now if you set the start pose to something really stretched the cloth will pull back when you simulate. You can then do relax initial state to get a natural looking start position. Note that if the deformer on the cloth input mesh has highly stretched it at the start frame then it might snap suddenly at the start frame, like a rubber band that has been stretched and suddenly released. Relax initial state can usually handle this, but there may still be cases where it works better to do a preroll animation of the character moving from the rest shape to the start pose. It really depends on the particulars of the animation and setup.
9. Stiffen selected parts of cloth.
Parts like the collar and pockets may change shape or flop around too much during the simulation. There are several ways that we can stiffen them:
a) Constrain between neighboring components
Select cloth cvs in the region you wish to stiffen(like te collar) and create a Component to Component constraint.



10. Select the shirt and do "Mesh: Smooth" Or one could also do "Proxy:Subdiv Proxy". These both smooth the cloth mesh after simulation and create a nice quality surface when the mesh is made of quads. One thing to keep in mind is that one needs to select vertices on the non-smooth mesh if creating constraints for them and such. (display input mesh or temporarily lowering the subdivision level to zero on the polySmoothFace node will work)

Hey, Duncan.
I have a question. I am trying to do this with nCloth, but I am failing miserably, so you can guide me through a right direction for doing the following thing. Especially how to set up nColoth constrain between the plate and the character’s hand.
1) there is a character. He hold a dish plate and the cloth over it.
2) He lays down the plate(a cloth over it) on the desk.
3)He picks up the cloth out from the plate.
4) He lifts up the cloth high( he pulls the cloth out from the plate). (End)
Should I use regular parent constraint or nCloth constraint only? Should I use Local or World nCloth simulation? How do you make it, playback friendly?
If there is any chance you can give me a detailed tutorial of this?
Hey Duncan, I’ve noticed with nCloth that even if you have the solver disabled that the nucleus tries to run up from frame 1 everytime you jump in the timeline. . . do you know of anyway to get the solver to be in a disabled state and not run up until needed?
great article btw.
~k
Hi Duncan
first of all realy big thanks for your tutors. its help alot.
i was plaing with your character and looks werry good. after that i create my own character. like dimentor (from Harry Poter).
its like a live roub withaut human inside…
so the idea was make this roub alive.
i’m create this roub. create a dummy inside. and animate it. and then i run a simulation , and when the dummy heand come near torso my roub bikome unstabil....
i c that mr. bigbearent have the same problem ...
i was truing to increes stretch resistance,substeps/ collide iterations.
its take alot of time to calculate the cache. but the result was the same.
maby you will help me to find out .what did i do wrong ?
many thanks.
Magido.
PS. sorry for my english/
Very Superp toturs.
but i don’t know how to maintain the nCache would you help me
Thanks
For extreme motions you may need greater stretch resistance on the cloth and also greater substeps/ collide iterations on the nucleus node.
Duncan



