nCloth Vertex Editor (mel script)

By -
Duration
3 mins

Here is a mel script that will allow you to easily edit per vertex nCloth values by selecting vertices and editing values directly with a slider, rather than by using the paint tool. First put the following mel file in your local scripts directory: nClothVertexEditor.mel (you'll find this at the bottom) Note that if you are using Maya2009 or later you should download nClothVertexEditor2009.zip. The other older version only works with Maya2008. Startup maya then enter "nClothVertexEditor" into the command line. A small window should appear.

Select vertices on an nCloth then set the desired vertex attribute in the window. The slider will show the current value for those vertices which you can then change. If the selected vertices have different values then the slider will show the average value and a message appears indicating a range of values. If desired one can also randomize the values using the randomization slider. Drag the string "nClothVertexEditor" onto the shelf so that in future you can simply click on the shelf button to bring up the editor. Let's experiment on a simple poly plane. Set its subdivisions to about 30x30, make it nCloth, then type : nClothVertexEditor Select a couple of vertices, set the attribute to "inputAttract" and the value to 1.0. The cloth should fall except for the selected vertices, which are now attracting to input mesh. This is similar to a transform constraint.

If you wished to have less stretching near these vertices you could either increase the substeps or give the neighboring vertices a small amount of inputAttract. Select some more points, make the attribute "wrinkle" and edit the slider value to displace the rest position. (First make the bend resistance at least 1 on the nCloth... otherwise one can only see the effect on edge restlength)

Note how with wrinkle selected the slider range goes from -1 to 1. This makes it possible to displace on both sides of the surface. You can select a large block of vertices and increase the randomization to make the surface lumpy. (Depending on the size of your mesh you may need to also adjust the wrinkleMapScale on the nCloth node to set the min/max wrinkle displacement)

The values one can set range from 0-1 for all attributes except wrinkle, which goes from -1 to 1. The per vertex values are multipliers of the same named attributes on the nCloth node. Thus for more stretch resistance per vertex than 1.0 increase the stretchResistance attribute on the nCloth node. Also do not use this a tool for setting the value of ALL vertices on an nCloth. Instead set the attribute mapType to "None" on the nCloth node and set the per cloth, not per vertex attribute. If desired you can also edit vertices from multiple nCloth and nRigid nodes at once. NOTE: Currently the randomization can be a bit confusing in that the vertex value slider currently gets reset to the average value for the selected vertices after each edit. With the randomization at a non-zero value the value slider will thus jump to a lower value after one adjusts it. The vertices were set to a spread of values, some lower than the slider value, so the average is thus lower.

nClothVertexEditor.zip nClothVertexEditor2009.zip
Published In
Tags
  • nCloth
8 Comments
To post a comment please login or register
| 9 years ago
Ok, I've attached a version of the script that works with Maya2009 and later( nClothVertexEditor2009.zip). Duncan
| 9 years ago
I have a fix for this script, but have not yet uploaded it. You can fix the existing one by simply replacing the two instances of "nParticle" with "nBase". (the node derivation for nCloth changed in 2009) Duncan
| 9 years ago
Thanks Scott for pointing this out. The window does not seem to be responding to selection events. I'll check it out and see if I can post a fix. Duncan
| 9 years ago
Looks like this script does not work in 2009. Duncan is there any chance you can update this script? Maybe add dynamic constraint weight support while your digging around in there. Thanks Scott
| 10 years ago
In order to change the rest length over time you can do nCloth: set rest shape to input mesh. Then if the input shape has an animated deformation the rest shape will be continually set to the changing shape. This is very useful when wants to do things like snakes or objects that deform with muscles. If desired you can also instead set the rest shape to a second mesh of a matching topology.
| 10 years ago
Hi Ducan, awesome script has there been any development on mapping the rest length in the new release? or is this at all possible through the API, i feel this is the only real limitation with ncloth but its something that would really expand on the use of ncloth as a simulation tool. is there a way to modify the length of springs over time by using something like initial state of the mesh which could effect only a mesh area. cheers john
| 11 years ago
The restLengthScale is currently not a mappable or per vertex attribute( on either the nCloth or nConstraint ), thus this editor would not work with it. Hopefully at some point we will make it a mappable attribute, as I have often wanted control over that. It might be especially nice if one could control it separately in U,V for the nCloth.
| 11 years ago
Could you do this for rest length scale on a dynamic constraint?
*Save $66 per month on Autodesk's Suggested Retail Price (SRP) when purchasing 1 year term 3ds Max or Maya subscription.