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
Falling leaves with nCloth and Paint Effects
Posted: Feb 27, 2007 - 11:21 AM
Category: nCloth
sunsetLeaf.zip (scroll to the bottom to download related material)

With nCloth, Maya users finally have a simple method for handling falling leaves. One can also easily attach leaves to branches and have the attachments broken by windforces by using nCloth constraints with glue strength. The basic workflow is very simple. Make a paint effects tree, convert it to poly, select the leaves and make nCloth. What follows is a more detailed tutorial.

1. Create a Paint Effects Tree
In general it helps to use a tree that will convert to poly well and which will not have too many segments per leaf. Here is a brush preset that should work OK. Put the following two files in your maya location "treesMesh" directory. (Do "Paint effects:Get Brush" and you will see the full pathname near the top left of the visor window)
oakBigLeaf.mel (scroll to the bottom to download related material)
oakBigLeaf.mel.icon

You should now be able to select the preset "oakBigLeaf" in the visor and then create a tree by painting on the ground.
2. MENU "Modify: Convert: Paint Effects to Polygons"

3. Select the Leaves
4. MENU "nCloth: Create nCloth"
The leaves will now fall downward during playback. On the nucleus node turn on "Use Plane" to collide with the ground. The playback will be rather slow. To speed things up set the substeps and max collision iterations on the nucleus node to 1. Also turn off "Self Collide" on the nClothShape. (If you want to collide the leaves with each other you can enable this, but you will likely wish to make the selfCollideWidthScale 1.0 and lower the thickness a bit) The simulation should now playback quickly. Raise the friction on the nCloth and the planeFriction on the nucleus node so the leaves don't slide too much.
5. Increase the nCloth bend resistance
The preset in this tutorial has a little bend on the leaves so that they will curl as they fall, in typical leaf fashion. We need some bend stiffness for this to work. The Stretch/Compression/Bend resistance can all be set to 1.0 (if you have more segments on the leaves then you will need higher values)

6. Increase Lift and Drag on the nCloth
Setting both attributes to 0.3 works pretty well. In general if you make the lift higher than the drag it will be too energetic, but it provides a nice control over the character of motion. You can also make the tangential drag a little higher than zero so that there is some resistance to motion in the plane of the leaf. With tangentialDrag at 1 and lift at 0 we have simple uniform drag which looks boring and unnatural:
If we lower the tangentialDrag to 0 but still have zero lift the effect is somewhat more interesting, but you still don't get the desired looping motion:
When we add in the effect of lift the animation becomes much more natural:
7. Have some fun!
We can play with various cloth attributes during playback to see how it affects the simulation. Try editing the wind strength and direction on the nucleus node to blow the leaves around. You can pull all the leaves back onto the tree by raising "Input Mesh Attract". Note that if one animates the original pfx tree( with turbulence for example) then this attraction is to the animated leaf positions. One could have the tree blowing around using turbulence on the pfx brush node then animate the inputMeshAttract from 1 to zero to release the leaves. Raising deform Resistance will freeze the overall group of leaves as if they were in a block of ice. Lowering it will then "melt" the ice (not realistic, but still fun).



The rest of this tutorial will cover how to attach the leaves to the tree and dynamically break the attachments(through wind or tree shaking) such that the leaves don't all fall at once.

8. Select the leaves and the tree

9. MENU: "nConstraint: Component to Component"

By default each cv on the leaf object is connected to the nearest cv on the tree object, and visa versa. Instead we only want connections where the leaves touch the tree. To do this set the constraint "Connection Method" to "Within Max Distance"
Now when you playback some leaves will fall, because all their cvs are further the the default "0.1" Max Distance from the tree cvs. We can simply increase the Max Distance to about 0.3. Playback will now be slower because this creates many connections( some redundant ones ). The longer connections can help keep the leaves from twisting about the branch. A more accurate connection would involve connecting edges to edges and using the bendStrength on the constraint to keep the leaves from twisting, although this is much slower to compute. To do this lower the constraint max distance to about 0.08 and on the two nComponent nodes set "Component Type" to edge.
10. Set glue strength so bonds can break.
Set the constraint glue strength to about 0.2 and increase the wind speed on the nucleus node to blow leaves off the tree. Note that one may wish to type values greater than 1.0 into the wind speed. Alternately you could have turbulence animation on the oakBigLeaf brush to shake the leaves off. One could also key the brush Uniform Force attribute to bend the tree. Note that if you are using an edge to edge constraint with bend strength then you also need to set the constraint "Bend Break Angle".
In the following animation the brush Path Follow attribute was animated to bend the tree, following by an increase in Wind Speed on the nucleus node.
If we just constraint the end vertices of each leaf to the tree then they will droop a lot. If you are using a distance based constraint, then you could increase the distance so that more of the leaf is constrained. This will keep it from drooping, although if you make the distance too great the leaves will be somewhat rigid. As well this can create a great many connections to the branches.

One other technique, although this is slower generally, is to select all edges on the leaves and all edges on the tree when creating the component to component constraint.(or you can simply edit the two nComponent nodes you have currently to be “all edges") Enable distance based and make the max distance very low. Turn on bend (on the constraint). Note that bend on a constraint only works when constraining edges to edges. Also you will need to set the bend break angle(like glue strength for bend). I think there is a problem where it can still try to compute the bend even after the glue bond is broken, so you need to make sure that the bend break angle is low enough.

If you want it to be more efficient you could select just the edge on the end of the leaves and the edges on the tree nearest these edges, but this might take a while to do. (one problem is the extra constraints to edges around skinny branches… if one makes the max distance small enough to avoid these then some leaves won’t get connected at all)

Once you have the setup working you can avoid the small relaxation at the beginning by doing relax initial state on the cloth.

The following project below (sunsetLeaf.zip) contains the scenes sunsetLeafFall.ma and sunsetLeafBlow.ma as well as source image files.
In order to post any comments, you must be logged in!
  Posted by Duncan Brinsmead  on  02/14  at  02:54 PM

If we just constraint the end cvs of each leaf to the tree then they will droop a lot. If you are using a distance based constraint, then you could increase the distance so that more of the leaf is constrained. This will keep it from drooping, although if you make the distance too great the leaves will be somewhat rigid. As well this can create a great many connections to the branches.

One other technique, although this is slower generally, is to select all edges on the leaves and all edges on the tree when creating the component to component constraint.(or you can simply edit the two nComponent nodes you have currently to be “all edges") Enable distance based and make the max distance very low. Turn on bend (on the constraint). Note that bend on a constraint only works when constraining edges to edges. Also you will need to set the bend break angle(like glue strength for bend). I think there is a problem where it can still try to compute the bend even after the glue bond is broken, so you need to make sure that the bend break angle is low enough.

If you want it to be more efficient you could select just the edge on the end of the leaves and the edges on the tree nearest these edges, but this might take a while to do. (one problem is the extra constraints to edges around skinny branches… if one makes the max distance small enough to avoid these then some leaves won’t get connected at all)

Once you have the setup working you can avoid the small relaxation at the beginning by doing relax initial state on the cloth.

  Posted by depthvfx  on  06/20  at  03:21 AM

Hi Duncan, thank you for this really awesome tutorial!
One thing I would like to know is how can I keep the leaves in their position, ie. not flopping around the branch when I start the playback? has this got to do with the constraint or is it rigidity on the ncloth object?

Thanks
Ben

  Posted by fedaykin38  on  03/06  at  09:58 PM

Thank you very mutch !
why didn’t I think to that before smile

  Posted by belaljami  on  03/04  at  01:38 PM

thank you for your project sharing

  Posted by rockus_123  on  02/28  at  11:05 AM

Thank you Duncan for your work.

 
Page 1 of 1 pages