13 July, 2010

Cluster Deformer Weights

Each component affected by a cluster has its own weight stored in the deformer attribtue .wl (weightList). This attribute is inherited from weightGeometryFilter node. ".wl" is a two dimensional array with first dimension specifying an array related to each geometry object a cluster affects.e.g.

cluster1.wl[0] => array of weight values for nurbsCurve1

cluster1.wl[1] => array of weight values for nurbsCurve2

cluster1.wl[0][3] => cluster weight of nurbsCurve1.cv[3]

Now, let's say nurbsCurve1 has 8 CVs, out of which first four (0:3) are affected by cluster1. Hence the cluster1.wl[0] will have 8 actual weight values (keep in mind that you can do "getAttr cluster1.wl[0][1000]" even if 1000th CV does not exist, more on that later). Now,we change all weights to 0.5 using cmds.percent("cluster1", "nurbsCircle1", v=0.5). That will also change weights of CVs which are not affected by cluster1. Now if I go to "Edit Membership Tool" and add a CV to cluster1, by default its weight would be 0.5 instead of 1.

This may not be very useful, but this is one of those good to know aspects of Maya.