Username
Password
Auto-login
Show my name in the online users list
Not a member?
Please register.
Forgot your password?
(1) October 2008
(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
A Bag of Marbles using nCloth
Posted: Feb 08, 2007 - 01:20 PM
Category: nCloth
Ah marbles! For many boys of my generation marbles were the first introduction to wheeling, dealing and capitalist hording of collectable stuff.
image1.jpg
I feel sorry for my son's generation which substituted Pogs for this pastime.
image2.jpg
Little cardboard milk bottle tops?? Give me a break!

This tutorial uses a trick where one can have an nCloth behave like a particle system where the particles can self collide. This is vastly more efficient than trying to model all the marbles as little rigid ncloth spheres. The marbles are in the bag and thus do not need to render. I will show in a later tutorial how to render these nCloth "particles" using the standard Maya particle rendering.
bagOfMarbles.avi
We first define a mesh for the marbles. All we are interested in the the vertices from the mesh, not the edges or faces. Maya requires that a mesh have edges and faces, however, so we will construct a lattice that has a non-manifold geometry. ( Non-manifold geometry can have more than 2 faces share an edge, as in a T junction ) We will make a 3x3x3 lattice, or 9 marbles.

1. MENU "Create: Polygon Primitives: Plane"

Set the subdivisions on the polyPlane node to 2,2.

2. MENU "Edit Mesh: extrude"
On the polyExtrudeFace node set:
localTranslateZ = 1.0
divisions = 2
image3.jpg
3. Go back to object selection mode( pPlane1 should be selected )

4. MENU "Edit Mesh: merge"
This operation combines all the common cvs together and makes the surface non-manifold, however all we are interested in is that we now have a uniform lattice of cvs with no overlapping cvs.
image4.jpg
5. Select the object again(pPlane1)

6. MENU "nCloth: Create nCloth"

On the nClothShape node set:
Solver Display = "Collision Thickness"
Collision Flag = "Vertex"
Self Collision Flag = "Vertex"
Thickness = 0.25
Lift = 0.0
(lift looks at surface normal so we don't want it)
Tangential Drag = 1.0 (this makes the drag ignore the surface normal)
Stretch Resistance = 0
Compression Resistance = 0
Bend Resistance = 0


The cloth is now a bunch of colliding particles, with no stiffness defined between the particles.
image5.jpg
7. Turn on "Use Plane" on the nucleus node
You can now playback. The particles should jump up and settle down on top of each other. They jump up because of interpenetration with the ground on the start frame, and they settle in a stack because they are EXACTLY balanced on top of each other. Move the box (pPlane1) up a bit so it is well above the ground and give it a little rotation. Note that you should be at or before the start frame to see the cloth object update when you transform it. Now when you play back it should fall like a pile of marbles.
image6.jpg
The output cloth mesh is still drawing, and will render. We do not wish to see this, but making it invisible will cause update problems on the solve. A workaround is to draw it as bounding box in the interactive and turn off all its render options:

8. Edit the mesh "outputCloth1"
RenderStats:
Cast Shadows OFF
Motion Blur OFF
Primary Visibility OFF
Visible in Reflections OFF
Visible in Refractions OFF


ObjectDisplay: Drawing Overrides
Enable Overrides ON
Level Of Detail = Bounding Box


With these settings it will simulate the particles but we will not get the mesh in the viewports or the render. It is possible to plug the mesh output into a particle system for rendering, but we will discuss that in a coming tutorial on using nCloth for particle water effects.

Now we can create the cloth bag to contain the particles. We will use a simple uniform sphere for the bag, but you could model something more like a real marble bag if desired.

9. Create a uniform sphere as outlined in the tutorial Creating a sphere with very uniform triangles.
Scale and position the sphere to be above the ground plane and enclosing the 9 "marbles".
image7.jpg
10. MENU "nCloth: Create nCloth"

When you playback you should now have have a bag filled with marbles that falls on the ground. The self collision on the bag may have some problems however. Temporarilly make solver display="Self Collision Thickness" and increase "Self Collide Width Scale" until the spheres touch. Alternately you could lower this value to 1.0 and set "Self Collision Flag" to "Full Surface", although this may be a little slower.
image8.jpg
Lets now constraint the top of the bag to keep it from falling:

11. Select a few cvs at the top of the cloth bag

12. MENU "nConstraint: Transform"


On playback the bag should now be attached at its top. You can keyframe the position of the transform constraint if desired so that it drags the bag around. Note that the default cloth settings are rather stretchy. You may wish to increase the stretch resistance somewhat. This is even more important if you increase the resolution of the cloth bag. Also the vertices of the bag initially have the same mass as the "marbles". If you increase the mass on the marbles (nCloth1) then they will push the bag more than they are pushed by the bag. However this also allows the bag to stretch more under the weight of the marbles, which in turn requires higher stretch resistance on the bag.
image9.jpg
Now for fun we can try sucking air out of the bag to better display the shape of the marbles inside:

13. On the bag (nClothShape2) set Pressure to -0.5.
On playback the bag should behave as if air had been sucked out of it and collapse like a shrinkwrap onto the marbles. If you make the pressure much lower you may need to increase the substeps or collision iterations to avoid collision problems. Keyframing the pressure lowering, starting at zero would also help avoid a sudden pop at the start.

14. Select the bag and the marbles and do MENU "nCache: Create New Cache".
You can now playback at full speed.

15. For final rendering you may wish to select the bag and do MENU "Mesh: Smooth".

This is a triangle, not a quad mesh, so the linear smooth method will work better. A subdivision level of 1 with 2 divisions per face works well.
image10.jpg
check the movie \"bagOfMarbles.avi\"
In order to post any comments, you must be logged in!