Friday, 26 October 2012

nCloth instances

I have been working on a confetti shot and wanted to use nCloth. I decided to use a particle emitter and to instance the nCloth object onto the particles - but how? If I were to simply assign the nCloth object to the instance, then each instance would be identical. I wanted to have a different starting point in the nCloth cache for each instance. Unfortunately Maya's instancer doesn't support this kind of connection. I tried to use an userScalarPP attribute along with a particle sampler to access the cacheStart attribute on the nCloth cache, but that didn't work.

Here's how I did it:

First cache the nCloth object

Export the nCloth as a sequence of OBJs. I used a python script called objsExporter_v2 from Christos Parliaros

Re-import the OBJ sequence using Dave Girard's objSequenceImporter

Use the imported OBJs to create an instancer with cycling set to On

On the particle object I setup a per-particle attribute; cyclePP and used this to select the correct OBJ in the sequence. For example, if there are 30 OBJs in your sequence, in the creation expression:


and in the Runtime before dynamics:

cyclePP=(cyclePP+1) % 30;

so the nCloth object will loop through the cache and start from the beginning at the end of the loop.


  1. Interesting! I've been searching for a way to instance nCloth. I'm doing a simulation of cells around an artery. I was hoping not to have to ctrl d 200 nCloth objects. Will give this a go. Thanks for sharing.

  2. Could you possibly post or email me a little more specifics? Maybe a screen shot of your ParticleShape Instancer Attribute Editor Panel? Confused a bit for setting Cycle Options and where to apply the cyclePP Per Particle expression attribute. Also what settings for new Attribute... Make att = Keyable? Data Type = Float? Type = Per particle(array)? Should the expression reflect the nParticleShape name: Cell_nParticleShape.CyclePP=0;? Would be greatly appreciated 8^)