babylonReskinTool.mel 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. global proc reskinSelectedMeshes() {
  2. $influencers = `intSliderGrp -q -value myReskinInfluencers`;
  3. $selection = `ls -sl`;
  4. $selected = size($selection);
  5. if ($selected > 0) {
  6. $skinName = `textFieldGrp -q -text myReskinName`;
  7. if ($skinName != "") {
  8. $textField_exists = `objExists $skinName`;
  9. if ($textField_exists == 0) {
  10. waitCursor -state 1;
  11. $skinedCluster = $selection[0];
  12. $skinnedJoints = `skinCluster -q -inf $skinedCluster`;
  13. if ($selected > 1) {
  14. $duplicateObj = `duplicate $selection`;
  15. $createGrp = `group -n tempGroup`;
  16. $combine = `polyUnite -n $skinName $createGrp`;
  17. $deleteHistory = `delete -ch $combine`;
  18. delete $createGrp;
  19. } else {
  20. $duplicateObj = `duplicate -n $skinName $selection`;
  21. }
  22. $jnt = `select -add $skinnedJoints $skinName`;
  23. $selectionforBind = `ls -sl`;
  24. $newskin = `skinCluster -mi $influencers $selectionforBind`;
  25. $newSelect = `select -add $skinnedJoints $selection $skinName`;
  26. $transfer = `copySkinWeights -nm -sa "closestPoint" -ia "closestJoint"`;
  27. $cleared = `textFieldGrp -edit -text "" myReskinName`;
  28. $deleted = `delete $selection`;
  29. $deselect = `select -cl`;
  30. waitCursor -state 0;
  31. } else {
  32. error ("Skin name is already in use: " + $skinName);
  33. }
  34. } else {
  35. error "No name specified for re-skining.";
  36. }
  37. } else {
  38. error "No meshes selected for re-skining.";
  39. }
  40. }
  41. global proc babylonReskinTool() {
  42. string $window = `window -title "Reskin Geometry Tool"`;
  43. columnLayout -adjustableColumn true;
  44. textFieldGrp -label "New Skin Name" -text "" myReskinName;
  45. intSliderGrp -label "Max Influencers" -field true -minValue 1 -maxValue 8 -fieldMinValue 1 -fieldMaxValue 8 -value 4 myReskinInfluencers;
  46. button -label "Reskin Selected Meshes" -command "reskinSelectedMeshes()" myReskinButton;
  47. showWindow $window;
  48. }