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
It’s Slinky, it’s Slinky!
Posted: Apr 05, 2007 - 04:58 PM
Category: nCloth
Here is how to do the "fun and the best of the toys" using Maya nCloth.(Sing Along)

The slinky is a special type of near zero tension spring. It is constructed with a flat ribbon of metal that resists shear and bend in the ribbon plane but easily bends down the axis of the spring. We can simulate it with nCloth by constructing a long spiral cloth ribbon and giving it similar properties.

1. Model the slinky
We can model the slinky using one of my favorite tricks, which involves creating a spiral using only a 2 cv curve on a nurbs cylinder.
a) MENU "Create: Nurbs Primitives: Cylinder"

b) MENU "Modify: Make Live"

c) MENU "Create: Cv Curve Tool"

In the options set curve degree to 1. Then add a cv to the top and bottom edges of the cylinder and hit enter to create a 2 cv curve on surface. Now comes the fun part.
image1.jpg
d) Create the spiral. Select the two curve cvs and edit their values in the channel box. The Y attribute will determine the number of coils. Set one to zero and the other to 300. The curve on surface display will look crude, but don't worry as the actual curve is precise.
image2.jpg
e) Select the curve and do MENU "Surfaces:Edit Curves: Duplicate Surface Curves". Then repeat so you now have two 3d curves.

f) Scale up the second duplicated curve in X and Z (1.2, 1.0, 1.2) One can scale in x an z only by dragging the Y (yellow) scale box while holding the control key.
image3.jpg
g) Select the two duplicated curves and do MENU "Surfaces: Loft"
You now have the basic slinky shape, but nCloth needs a poly mesh, not a nurbs surface.
image4.jpg
h) MENU "Modify: Convert: Nurbs to Polygons"
Initially we have way too many polygons. It is critical that we triangulate the nurbs to get the most efficient mesh for simulation. On the created nurbsTessellate node set the following:
Enable Advanced Tessellation = ON
PolygonType = Quads
Format = General

General Tessllation Options:
UV Type = Per Surf # of Isoparms in 3D
U Number = 414
V Number = 1
image5.jpg
i) Hide the nodes "nurbsCylinderShape1" and "loftedSurfaceShape1", as they are now really upstream construction history. If desired instead of setting visibility you may wish to set "Intermediate Object" to true, which indicates more that they are used as construction history. You may also wish to either hide the nurbs curves or turn off curve display.
image6.jpg
The basic slinky model is now complete.


2. (optional) Apply a bend deformer to the slinky: MENU "CreateDeformers: Nonlinear: Bend" (You can use the deformer to pose the start shape of the slinky, however it will not be used in this tutorial)


3. Select the slinky ("nurbsToPoly1") and do MENU: "nCloth: Create nCloth".
Enable "Use Plane" on the nucleus node for ground collisions, move the slinky above the ground plane and playback. At this point it looks more like a cloth slinky than a metal one and has some self collision problems as well.
image7.jpg
4. Adjust the selfCollisions settings. On the nCloth node set solver display to selfCollision to preview the collide width. The values that were picked when the cloth was created are pretty good so the thickness can be left at 0.028, although the following needs to be set to keep the borders from interpenetrating:
selfCollisionFlag = "Full Surface"
image8.jpg
5. Make the slinky much stiffer. First off we will need more than the max iterations settings on the nCloth, so lets just set it to a very high value ( do not confuse this with the self collide iterations )
Max Iterations = 10000
Then we can set the stiffness related attributes high. In particular shear resistance is helpful because the stretch crosslinks cannot stiffen the skinny quads as much as we would like. (normally shear resistance is not needed because the more efficient stretch/compression cross links keep quads from shearing) Bend affect how much the slinky pulls apart, and doesn't need to be as high because the metal ribbons can bend much more along the flat side.
Stretch Resistance = 3000
Compression Resistance = 3000
Shear Resistance = 1000
Bend Resistance = 500

Also we increase the mass so that air drag has an insignificant effect.
Mass = 10

6. Set the general scene scale and collision quality. The slinky is now stiffer but still has collision problems when we playback. On the nucleus node change the following:
Substeps = 20 (For the finished animation you may wish to bump this to 100 or more to avoid self collision problems, but 20 was enough to create the avi in this demo)
SpaceScale = 0.4

Initially the slinky was 2 meters wide in term of dynamics, the space scale of 0.4 makes this .8 meters wide, which is still a very large slinky. However the net result is that gravity is not quite so strong and things move a bit in slow motion. If you really want to simulate at full slinky speed(small things move fast) then make this lower and increase the stiffness attributes as well as the substeps.

7. Create the passive scene geometry. In this example we wanted some stairs. This can be quickly created by setting the subdivisions on a plane and moving cvs in a side ortho view. Although any method should work fine. Just make sure that the normals face outward( towards the slinky.. if you collide with both sides then turn off trapped check on the nRigid ) and that the poly count is not excessively high. The steps should be just a little wider than the slinky. When done select the geometry and do "nCloth: Create Passive".
image9.jpg
8. Start the slinky at the top of the stairs. I initially had a tricky time trying to get the slinky started. I found a simple trick is to create a cylinder, make it a passive object and then rotate the slinky 90 degrees and drop on the cylinder to get it to start in the desired shape. Or you could try using the bend deformer described in step 2.
image10.jpg
At this point you should be able to run and get the desired playback. You may wish to also increase the friction on the stairs and the ground for better contact as the slinky moves.
image11.jpg
9. Cache out the finished simulation: MENU "nCache:Create New Cache"


10. Smooth and thicken the slinky for rendering.
First smooth the slinky: MENU "Mesh: Smooth". On the polySmoothFace node turn OFF "Keep Geometry Borders".
Now thicken it: MENU "Edit Mesh: Extrude". On the polyExtrudeFace node turn ON "Keep Faces Together" and set the "Local Translate" to 0 0 0.028. (this is the nCloth thickness). Note that everything done to this point has history, so you can go back and change the total number of coils by editing the curve cv position, or deform the shape of the original nurbs cylinder, etc. Of course this will require re-caching the simulation.
image12.jpg
11. Shade and render For this example I used Mental Ray raytracing with soft reflections on the slinky combined with spotlights with soft raytrace shadows. One could increase the shadow rays count on the spotlights to reduce the dotty quality of the lighting if desired. Also I raised the motion blur "time constrast" to speed up the render. If you want smoother motion blur lower this value.
In order to post any comments, you must be logged in!
  Posted by n8skow  on  04/23  at  10:37 AM

excellent tutorial duncan.

I’d like to apply some of the same functionality to a spring I’ve built that is attached at both ends to two different pieces of geometry - so that it stretches out kinda like slinky but maybe a bit stiffer so it doesn’t sag in the middle - i’m not clear on how to constrain it to my two pieces of geometry so i can see the deformation in real-time. maybe I should just go with a wire-deformer instead?

  Posted by cyclic  on  04/14  at  09:03 AM

Hi Duncan, another impressive tutorial and demo.  I’ve always wanted to simulate a slinky going down some stairs with dynamics but never fully hashed it out with the current dynamics system.  I also saw the skinning demo with nCloth at GDC and asked Steven about getting a copy of the script, which he replied with a grin and said that it was created by a game studio for Autodesk to use in demos.  He showed the animated hell-hound walking and simulating the neck thing in real-time (sweet demo)…

I look forward to the performance updates in nCloth and hope you keep creating these amazing blog posts.  Outstanding job as a whole and that guy talking about Ron Fedkiw just doesn’t understand the work involved with these simulations. 

May all your attempts be sub-linear.  All the best.

  Posted by Duncan Brinsmead  on  04/13  at  02:34 AM

Brian… That GDC demo was by Steven Roselle, who is currently working on a bonus tools script to do the automated setup( although I can’t say when this will appear in bonus tools). Basically the workflow he describes initially constructs a surface (using a loft) based on multiple skeleton chains. The surface is made into nCloth and the output nCloth mesh is used to drive the skeleton. His script has different options for the way this is set up, but the closest match to the cloth involves point constraining the joints to the cloth surface. 

  Posted by birdimus  on  04/11  at  12:53 AM

Hey Duncan, great tutorials--
I’ve been playing with ncloth for a few days now, and I think we are going to use it in our pipeline.
I saw an Autodesk demo at GDC where they cached the ncloth simulation and attached the cache to a skeleton--almost like a reverse skinning operation.  I don’t know if you have a link to the video, or know how to reproduce that effect.
We need to bake the simulation, and get it into an FK based game engine--so this feature is key. 

  Posted by Duncan Brinsmead  on  04/08  at  05:55 AM

Mason… did you move the slinky above the groundplane before simulating? If not it would get pushed up the way you describe( I’ll fix a typo in step 3: “above” not “about” ). I would not get bent out of shape over the speed in this example. A slinky is actually a challenge to simulate and requires extreme settings for stiffness and quality. Vertically the slinky hits many layers of self collision. It is a thin ribbon, yet needs the stiffness of steel, so stretch/compression resistance is 3000, which is the highest I’ve used on anything. The number of internal solver iterations is proportional to the stiffness levels, so for high stiffness it can be slow (for very high stiffness one can use the rigidity attribute, but that wouldn’t work for a slinky).  We are working on some new solving methods that could dramatically speed up this example (although I can’t discuss when this might appear in Maya). Also note that in the example file there is downstream construction history (a smooth and extrude) that also slows it down a bit.

 
Page 1 of 2 pages  1 2 >