Username
Password
Auto-login
Show my name in the online users list
Not a member?
Please register.
Forgot your password?
(2) May 2008
(1) January 2008
(1) November 2007
(2) September 2007
(7) August 2007
(2) July 2007
(1) June 2007
(3) May 2007
(4) April 2007
(8) March 2007
(9) February 2007
(2) January 2007
Basic cloth on character setup
Posted: Mar 23, 2007 - 05:45 PM
Category: nCloth
When creating cloth on a character one typically has the problem of getting the cloth into the correct starting pose for the simulation. This is frequently done by creating a little runup animation moving to the start pose, although this is rather tedious. Here is a somewhat easier to use setup:

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.
image1.jpg
Notice how if you pose the character ( transform the boxes ) the cloth moves with the character.
image2.jpg
When done playing with the controls one can select the skeleton and do MENU:"Skin:Go to Bind Pose" to get back to the original state. Now lets create some nCloth for this character.

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.
image3.jpg
The shirt was made from quads for a couple of reasons. Poly smooth works better with quads and it generally works well to do a poly smooth on the cloth output mesh( downstream of the nCloth node ) before rendering the cloth. Also with quads we create cross links for bend and stretch which ends up being more balanced in effect than if one had triangulated the mesh before making it nCloth. Also notice how the pockets are modelled. They are topologically non-manifold( T junctions ) which does not pose any problems for nCloth. However if one has detailed pockets and features that are more decoration it is worth considering omiting them from the simulating mesh, and then using the cloth output mesh as a wrap deformer on the detailed mesh.

5. Button the shirt together. To accomplish this we will constrain some points along the flap.
First select 6 cvs as shown:
image4.jpg
Now do MENU:"nConstraint:Component to Component"
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.
image5.jpg
Playback should look as follows:
image6.jpg
6. Improve the stretch and collision behavior.
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:
image7.jpg
Make the following changes to nClothShape1:
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)
image8.jpg
Now turn off the thickness display(solverDisplay=OFF) and playback. Note how the cloth selfCollision now fails around the collar and pocket regions:
image9.jpg
We need to increase the quality settings. The following settings should help.
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.
image10.jpg
7. Create a simple animation and simulate the cloth for this animation.
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".
image11.jpg
At the far lower left is the node "shirtWithPocketShape2Orig". Select it and in the attribute editor under object display toggle OFF "Intermediate Object". (It should show up in the viewport)
image12.jpg
Now in the hypergraph window find the node "nClothShape1" at the lower right and add it to the selection (shift click). Note that one needs to directly select the cloth shape in this case. Do "Edit NCloth:Rest Shape: Connect Selected Mesh to Rest Shape". A connection should appear in the hypergraph between these two nodes.
image13.jpg
Toggle "Intermediate Object" back to ON when done to hide the rest shape.

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.
image14.jpg
Initially this will just connect nearest pairs, which will not stiffen things very much. Instead set the constraint "Connection Method" to "Within Max Distance" then adjust the Max Distance attribute such that you get several cross connections. Be careful not to make the max distance too high or you can get a huge number of connections. This can stiffen the region so much that it may help to lower the constraint strength to keep it from being too rigid. Lowering the connection density can also help keep this from creating too many connections.
image15.jpg
b) Paint input mesh attract Make the "Input Mesh Attract" attribute on the cloth = 1 ( or 1.3 if you want it really rigid) then do "Edit nCloth: Paint Vertex Properties:Input Attract". Make the surface black wherever you wish it to be fully dynamic and white wherever you wish it to follow the bind skin animation on the input mesh. Note that this makes it follow the input animation which may stretch and look unnatural, however it can be quite useful because it is a way of blending between a deformer based animation and a dynamic one. Also note that the inputMeshAttract can be keyframed to vary the amount of blending during the simulation.
image16.jpg
c) Paint bend resistance Make the Bend Resistance relatvely high and then paint most areas dark, leaving the stiffer parts white. Note that this is somewhat inefficient, as it computes the full amount of internal bend iterations for the full surface and the painted values just scale the intensity of a bend iteration.


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)
image17.jpg
In order to post any comments, you must be logged in!
  Posted by Tak3D  on  05/13  at  06:16 PM

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?

  Posted by winterkewl  on  04/29  at  12:06 PM

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

  Posted by magido  on  01/22  at  08:06 AM

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/

  Posted by chandrubharathy  on  12/12  at  09:02 AM

Very Superp toturs.
but i don’t know how to maintain the nCache would you help me
Thanks

  Posted by Duncan Brinsmead  on  06/13  at  04:07 AM

For extreme motions you may need greater stretch resistance on the cloth and also greater substeps/ collide iterations on the nucleus node.
Duncan

 
Page 1 of 2 pages  1 2 >