I use ngSkinTools plug-in for Maya 2016 in order to skin my models, but usually when I’m done smoothing all the weights I found many vertices with up to 7-8 influences and Apex clothing tool complaining about it. So I looked for a way to set the max influence value on the fly but found none, and I end up learning a bit of MEL scripting and coding my own MaxInfluence script. I’m sharing it if anyone need it:
{
/*SCRIPT PARAMETER*/
int $MaxInfluence = 4;
/******************/
string $Selection] = `ls -sl`;
string $Skin = `findRelatedSkinCluster $Selection[0]`;
int $VertsCount] = `polyEvaluate -v $Selection[0]`;
int $i = 0;
for(; $i < ($VertsCount[0] + 1); $i++) // Iterate over all mesh vertices
{
string $Vertex = $Selection[0] + ".vtx" + $i + "]"; // Variable to store current vertex
float $Weights] = `skinPercent -ignoreBelow 0.0001 -query -value $Skin $Vertex`; // Array of all influences not null
if(size($Weights) > $MaxInfluence) // If (number of influences > max number of influences)
{
int $j;
float $Max]; for($j = 0; $j < size($Weights); $j++) $Max$j] = 0.0; // Init Max array
for($W in $Weights) // Iterate over all positive influences
{
int $k;
for($j = size($Weights); $j >= 0 && $W > $Max$j]; $j--); $j++; // Move the target influence down until the bottom is reached (-1) or the next influence is greater
for($k = size($Weights); $k > $j; $k--)
{
$Max$k] = $Max$k - 1];
}
$Max$k] = $W;
}
float $PruneValue = $Max$MaxInfluence] + 0.0001;
print ($PruneValue + "
");
skinPercent -pruneWeights $PruneValue $Skin $Vertex;
}
}
}
Just make sure that the target mesh is selected and run the script. If you want you can change the max influence parameter at the beginning of the script (maybe for performance purpose). Hope this helps!