Created
September 1, 2013 09:06
-
-
Save Neill3d/6403208 to your computer and use it in GitHub Desktop.
MEL Script for reseting skin bind pose.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Reset bind pose for selected mesh with skin cluster | |
// | |
// it will copy object, bind with the same weights, copy weights, delete old object | |
// | |
// Author Sergey Solohin (Neill3d) 2013, e-mail to: s@neill3d.com | |
// www.neill3d.com | |
// | |
string $selection[] = `ls -sl`; | |
for ($obj in $selection) | |
{ | |
select -r $obj; | |
string $newObj[] = `duplicate -smartTransform`; | |
//-- get list of skin joints | |
string $jointsList[] = `skinCluster -q -inf $obj`; | |
select -r $jointsList; | |
select -cl; | |
for ($s in $jointsList) | |
if (nodeType($s) == "joint") | |
select -add $s; | |
select -add $newObj; | |
// bind skin cluster | |
string $newSkinCluster[] = `skinCluster -tsb -mi 4`; | |
// add all other influences | |
for ($s in $jointsList) | |
if (nodeType($s) != "joint") | |
{ | |
//string $relatives[] = `listRelatives -shapes $s`; | |
//string $objShape = $relatives[0]; | |
select -r $newObj; | |
skinCluster -e -ug -ai $s; | |
} | |
setAttr ($newSkinCluster[0] + ".useComponents") 1; | |
// copy skin weights | |
select -r $obj; | |
select -add $newObj; | |
copySkinWeights -noMirror -surfaceAssociation closestComponent -influenceAssociation name; | |
// delete old object and rename a new one | |
delete $obj; | |
rename $newObj $obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment