Level One Magic
"Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
VRP_updateRig.mel
/*
SCRIPT NAME:  VRP_updateRig
CREATED BY:   Andy Kelts
STUDIO:       Disney Interactive Media Group
DATE EDITED:  02/23/2010
_____________________________________________________________________________________________________________

Comments: Ths script allows you to import an un-rigged model file and transfer skin weights from the 
            old rigged model to the new.
*/


// ////////////////////////////////////////////////////////////////////////////
// Import the new model file and put all imported nodes in the namespace: new_model
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_importModel()
{
  string $fileName = `textFieldButtonGrp -q -tx vrur_modelFileTextBox`;
  if(!`file -q -ex $fileName`)
    error("No file specified for import.");
  print("Importing: " + $fileName + "\n");
  file -import -type "mayaBinary" -ra true -namespace "new_model" -options "v=0" -loadReferenceDepth "all" $fileName;
  frameLayout -e -en 0 vrur_modelFileFrame;
}

// ////////////////////////////////////////////////////////////////////////////
// Export the rigged model as an unrigged model to the file specified
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_exportModel()
{
  string $fileName = `textFieldButtonGrp -q -tx vrur_modelFileTextBox`;
  if(!`file -q -ex $fileName`)
    error("No file specified for export.");
  print("Exporting: " + $fileName + "\n");
  // file -import -type "mayaBinary" -ra true -namespace "new_model" -options "v=0" -loadReferenceDepth "all" $fileName;
  // frameLayout -e -en 0 vrur_modelFileFrame;
}

// ////////////////////////////////////////////////////////////////////////////
// Smooth bind the meshes selected in the mesh list
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_skinMeshes()
{
  string $oldMeshes[] = `textScrollList -q -si vrur_skinnedMeshList`;
  string $newMeshes[];
  int $errors = 0;
  for($i=0;$i  {
    if(`objExists $oldMeshes[$i]` == 0)
    {
      print("// Error: Original skinned mesh does not exist: " + $oldMeshes[$i] + "\n");
      $errors++;
    }
    $newMeshes[$i] = "new_model:" + $oldMeshes[$i];
    if(`objExists $newMeshes[$i]` == 0)
    {
      print("// Error: New skinned mesh does not exist: " + $newMeshes[$i] + "\n");
      $errors++;
    }
    else
    {
      if(findRelatedSkinCluster($newMeshes[$i]) != "")
      {
      print("// Error: New mesh is already skinned: " + $newMeshes[$i] + "\n");
      $errors++;
      }
    }
  }
  if($errors)
    error("Skinned meshes missing. Check Script Editor for details.");
  int $jointSetting = `radioButtonGrp -q -sl vrur_jointRadioButton`;
  for($i=0;$i  {
    if(`objExists $oldMeshes[$i]`)
    {
      string $cluster = findRelatedSkinCluster($oldMeshes[$i]);
      string $joints[] = {};
      if($jointSetting == 1)
        $joints = `skinCluster -q -inf $cluster`;
      else if($jointSetting == 2)
        $joints = `skinCluster -q -wi $cluster`;
      print($newMeshes[$i] + " smooth-bound to " + size($joints) + " joints.\n");
      // int $jointCount = 1;
       // for($joint in $joints)
        // print("\t" + ($jointCount++) + ": " + $joint + "\n");
      // print("\n");
      string $clusterName = `substitute "Shape" $newMeshes[$i] "Cluster"`;
      skinCluster -name $clusterName -mi 3 -dr 3 -tsb -rui 0 -omi 1 $joints $newMeshes[$i];
      select -cl;
      select -add $newMeshes[$i];
      select -add $oldMeshes[$i];
      $joints = `skinCluster -q -inf $clusterName`;
      // print("Actual bind: " + size($joints) + "\n");
      // print($joints);
    }
  }
}

// ////////////////////////////////////////////////////////////////////////////
// Transfer weights from old to new for all meshes selected in the mesh list
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_transferWeights()
{
  int $warnings = 0;
  string $oldMeshes[] = `textScrollList -q -si vrur_skinnedMeshList`;
  string $newMeshes[];
  int $errors = 0;
  for($i=0;$i  {
    if(`objExists $oldMeshes[$i]` == 0)
    {
      print("// Error: Original skinned mesh does not exist: " + $oldMeshes[$i] + "\n");
      $errors++;
    }
    $newMeshes[$i] = "new_model:" + $oldMeshes[$i];
    if(`objExists $newMeshes[$i]` == 0)
    {
      print("// Error: New skinned mesh does not exist: " + $newMeshes[$i] + "\n");
      $errors++;
    }
  }
  if($errors)
    error("Skinned meshes missing. Check Script Editor for details.");
  int $weightSetting = `radioButtonGrp -q -sl vrur_weightRadioButton`;
  // set the preferred transfer settings
  string $ia[] = { "name", "closestJoint", "oneToOne" };
  string $sa = "-sa \"closestPoint\"";

  // get weight transfer settings from most recent values
  if($weightSetting == 2)
  {
    $ia = {};
    int $value = `optionVar -q copySkinWeightsSurfaceAssociationOption`;
    switch ($value) 
    {
      case 2:
        $sa = "-sa \"rayCast\"";
        break;
      case 3:
        $sa = "-sa \"closestComponent\"";
        break;
      case 4:
        $sa = "-uv";
        break;
      default:
        $sa = "-sa \"closestPoint\"";
        break;
    }
    for($i=1;$i<4;$i++)
    {
      $value = `optionVar -q ("copySkinWeightsInfluenceAssociationOption" + $i)`;
      print($value + "\n");
      if($i > 1)
        $value--;
      switch ($value)
      {
        case 1:
          $ia[$i-1] = "closestJoint";
          break;
        case 2:
          $ia[$i-1] = "closestBone";
          break;
        case 3:
          $ia[$i-1] = "oneToOne";
          break;
        case 4:
          $ia[$i-1] = "label";
          break;
        case 5:
          $ia[$i-1] = "name";
          break;
        default:
          break;
      }
    }
  }
  for($i=0;$i  {
    int $validSkins = 0;
    string $masterCluster = findRelatedSkinCluster($oldMeshes[$i]);
    string $slaveCluster = findRelatedSkinCluster($newMeshes[$i]);
    if($masterCluster == "")
      print("// Error: " + $oldMeshes[$i] + " has no skin cluster input. It must be skinned before weights can be transferred.\n");
    else
      $validSkins++;
    if($slaveCluster == "")
      print("// Error: " + $newMeshes[$i] + " has no skin cluster input. It must be skinned before weights can be transferred.\n");
    else
      $validSkins++;
    if($validSkins == 2)
    {
      if($weightSetting == 3 || $sa == "-uv")
      {
        string $uvSet = `textField -q -tx vrur_uvTextField`;
        string $uvs[] = { $uvSet, $uvSet };
        if(stringArrayContains("uvWeight", `polyUVSet -q -auv $oldMeshes[$i]`) == 0)
        {
          string $uvSets[] = `polyUVSet -q -cuv $oldMeshes[$i]`;
          $uvs[0] = $uvSets[0];
          warning($oldMeshes[$i] + " has no UV set: " + $uvSet + ". Using current UV set for transfer: " + $uvs[0]);
          $warnings++;
        }
        if(stringArrayContains("uvWeight", `polyUVSet -q -auv $newMeshes[$i]`) == 0)
        {
          string $uvSets[] = `polyUVSet -q -cuv $newMeshes[$i]`;
          $uvs[1] = $uvSets[0];
          warning($newMeshes[$i] + " has no UV set: " + $uvSet + ". Using current UV set for transfer: " + $uvs[1]);
          $warnings++;
        }
        $sa = "-uv \"" + $uvs[0] + "\" \"" + $uvs[1] + "\"";
      }
      string $command = "copySkinWeights -ss " + $masterCluster + " -ds " + $slaveCluster + " -noMirror " + $sa;
      for($each in $ia)
        $command += " -ia \"" + $each + "\"";
      // print("Skin weight command:\n\t" + $command + "\n");
      eval($command);
      print("Skin weights transferred\n\tFrom:\t" + $oldMeshes[$i] + "\t\tTo:\t" + $newMeshes[$i] + "\n");
    }
    else
      $warnings++;
  }
  if($warnings > 0)
    warning("There may be errors in weight transfer. Check script editor for details.");
}

// ////////////////////////////////////////////////////////////////////////////
// Get a list of nodes that influence a given node without duplicates
// ////////////////////////////////////////////////////////////////////////////
proc string[] getConnectionList(string $endNode)
{
  string $nodes[] = `listConnections -d off -s on $endNode`;
  for($node in $nodes)
    $nodes = stringArrayRemoveDuplicates(stringArrayCatenate($nodes, getConnectionList($node)));
  return $nodes;
}

// ////////////////////////////////////////////////////////////////////////////
// Rebuild an old shading network with its imported counterparts
// ////////////////////////////////////////////////////////////////////////////
proc renameMeshTextures(string $mesh)
{
  print("\tRebuilding shading network assigned to:\t" + $mesh + "\n");
  namespace -set ":";
  int $numFaces[] = `polyEvaluate -f $mesh`;
  string $shaders[] = `listSets -type 1 -o ($mesh + ".f[1:" + $numFaces[0] + "]")`;
  for($shader in $shaders)
  {
    if(startsWith($shader, "new_model:"))
    {
      string $shadingNetwork[] = getConnectionList($shader + ".surfaceShader");
      for($node in $shadingNetwork)
      {
        string $oldNode = `substitute "new_model:" $node ""`;
        if(`objExists $oldNode`)
        {
          // print("\tDeleting " + $oldNode + "\n");
          delete $oldNode;
        }
        // print("\tRenaming " + $node + "\n");
        rename $node $oldNode;
        string $connections[] = `connectionInfo -dfs ($oldNode + ".message")`;
        for($conn in $connections)
          if(startsWith($conn, "new_model:"))
          {
            string $newName = basenameEx(`substitute "new_model:" $conn ""`);
            // print("\tRenaming " + $conn + "\n");
            rename (basenameEx($conn)) $newName;
          }
      }
      string $oldShader = `substitute "new_model:" $shader ""`;
      if(`objExists $oldShader`)
      {
        string $shapes[] = `sets -q $oldShader`;
        // print($shapes);
        if(size($shapes))
          sets -e -forceElement ("new_model:" + $shader) $shapes;
      }
      // print("\tRenaming " + $shader + "\n");
      rename $shader $oldShader;
    }
  }
}

// ////////////////////////////////////////////////////////////////////////////
// Replace the shading network assigned to one mesh with the shading network assigned to another
// ////////////////////////////////////////////////////////////////////////////
proc replaceMeshTextures(string $oldMesh, string $newMesh)
{
  print("\tReplacing shaders assigned to the following mesh:\t" + $newMesh + "\n");
  if(`objExists ($oldMesh)` && `objExists($newMesh)`)
  {
    int $numFaces[] = `polyEvaluate -f $oldMesh`;
    string $oldShaders[] = `listSets -type 1 -o ($oldMesh + ".f[1:" + $numFaces[0] + "]")`;
    $numFaces = `polyEvaluate -f $newMesh`;
    string $newShaders[] = `listSets -type 1 -o ($newMesh + ".f[1:" + $numFaces[0] + "]")`;
    if(size($oldShaders)==1 && size($newShaders)==1)
    {
      if(`checkBox -q -v vrur_keepOriginalShaderCheckBox` == 1)
      {
        print("\tAssigning shader: " + $oldShaders[0] + " to mesh: " + $newMesh + "\n");
        sets -e -forceElement $oldShaders[0] $newMesh;
      }
      else
      {
        print("\tAssigning shader: " + $oldShaders[0] + " to all meshes with shader: " + $newShaders[0] + "\n");
        string $shapes[] = `sets -q $oldShaders[0]`;
        if(size($shapes))
            sets -e -forceElement $newShaders[0] $shapes;
      }
    }
    else
    {
      if(size($oldShaders)>1)
        warning($oldMesh + " has multiple shaders assigned to it. Automatic shader transfer would cause problems.");
      if(size($newShaders)>1)
        warning($newMesh + " has multiple shaders assigned to it. Automatic shader transfer would cause problems.");
    }
  }
}

// ////////////////////////////////////////////////////////////////////////////
// Delete one mesh and replace it in its hierarchy placement and with another
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_replaceMeshes()
{
  string $oldMeshes[] = `textScrollList -q -si vrur_skinnedMeshList`;
  string $newMeshes[];
  int $errors = 0;
  for($i=0;$i  {
    if(`objExists $oldMeshes[$i]` == 0)
    {
      print("// Error: Original skinned mesh does not exist: " + $oldMeshes[$i] + "\n");
      $errors++;
    }
    $newMeshes[$i] = "new_model:" + $oldMeshes[$i];
    if(`objExists $newMeshes[$i]` == 0)
    {
      print("// Error: New skinned mesh does not exist: " + $newMeshes[$i] + "\n");
      $errors++;
    }
    else
    {
      if(findRelatedSkinCluster($newMeshes[$i]) == "")
      {
      print("// Error: New mesh is not skinned: " + $newMeshes[$i] + "\n");
      $errors++;
      }
    }
  }
  if($errors)
    error("Skinned meshes missing. Check Script Editor for details.");
  for($i=0;$i  {
    print("Replacing " + $oldMeshes[$i] + " with " + $newMeshes[$i] + "...\n");
    replaceMeshTextures($oldMeshes[$i], $newMeshes[$i]);
    string $namespace = ":";
    string $pieces[] = stringToStringArray($oldMeshes[$i], ":");
    if(size($pieces)>1)
    {
      $namespace = "";
      for($j=0;$j        $namespace += $pieces[$j] + ":";
    }
    namespace -set $namespace;
    string $oldParents[] = `listRelatives -f -p $oldMeshes[$i]`;
    string $newParents[] = `listRelatives -f -p $newMeshes[$i]`;
    $pieces = stringToStringArray($oldParents[0], "|");
    string $grandparent = "";
    for($j=0;$j      $grandparent = $grandparent + "|" + $pieces[$j];
    delete $oldParents[0];
    rename $newMeshes[$i] $oldMeshes[$i];
    string $newNode = `rename $newParents[0] $pieces[size($pieces)-1]`;
    parent $newNode $grandparent;
    string $skinCluster = findRelatedSkinCluster($oldMeshes[$i]);
    rename $skinCluster (`substitute "new_model:" $skinCluster ""`);
    if(`checkBox -q -v vrur_keepOriginalShaderCheckBox` == 0)
      renameMeshTextures($oldMeshes[$i]);
    namespace -set ":new_model";
    string $nodes[] = `namespaceInfo -ls`;
    namespace -set $namespace;
    for($node in $nodes)
      if(startsWith($node, $skinCluster))
        rename $node (`substitute "new_model:" $node ""`);
  }
}

// ////////////////////////////////////////////////////////////////////////////
// Remove everything from inside a namespace and delete the namespace
// ////////////////////////////////////////////////////////////////////////////
proc decimateNamespaces(string $namespaces[])
{
  string $currentNamespace = `namespaceInfo -cur`;
  for($namespace in $namespaces)
  {
    string $pieces[] = stringToStringArray($namespace, ":");
    namespace -set $pieces[size($pieces)-1];
    string $members[] = `namespaceInfo -ls`;
    if(size($members) > 0)
    {
      print($namespace + " has " + size($members) + " nodes to be removed.\n");
      for($member in $members)
        if(`objExists $member`)
        {
          // print("Deleting\t" + $member + "\n");
          catch(`delete $member`);
        }
    }
    string $childNamespaces[] = `namespaceInfo -lon`;
    if(size($childNamespaces) > 0)
      decimateNamespaces($childNamespaces);
    if(size(`namespaceInfo -lon`) == 0)
      if(size(`namespaceInfo -ls`) == 0)
      {
        print("Removing empty namespace: " + $namespace + "\n");
        namespace -set (":" + $currentNamespace);
        namespace -rm $pieces[size($pieces)-1];
      }
  }
}

// ////////////////////////////////////////////////////////////////////////////
// remove the new_model namespace and all its inhabitants
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_cleanupUnusedImport()
{
  namespace -set ":";
  if(stringArrayContains("new_model", `namespaceInfo -lon`))
    decimateNamespaces({"new_model"});
}

// ////////////////////////////////////////////////////////////////////////////
// automate all transfer steps at once
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_doTransfer()
{
  // /////////////////////////////////////////////
  // check for existing meshes in import namespace
  // and import file if none
  // /////////////////////////////////////////////
  namespace -set ":";
  if(stringArrayContains("new_model", `namespaceInfo -lon`))
  {
    namespace -set "new_model";
    if(size(`namespaceInfo -ls`) > 0)
      warning("Import namespace exists and has members. File must be imported manually.");
    namespace -set ":";
  }
  else
    vrur_importModel();

  // smooth skin transfer pieces to root
  vrur_skinMeshes();
  // transfer weights from old to new
  vrur_transferWeights();
  // delete old, reparent new
  vrur_replaceMeshes();
  // remove unused new
  vrur_cleanupUnusedImport();
  // remove unused shading networks
  hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");
  // save update settings
  vrur_saveSettings();
}

// ////////////////////////////////////////////////////////////////////////////
// Refresh the UI list of skinned meshes
//  does not include meshes in the new_model namespace
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_refreshSkinnedMeshList()
{
  // print("vrur_refreshSkinnedMeshList()\n");
  string $meshes[];
  string $skinClusters[] = `ls -l -typ "skinCluster"`;
  for($each in $skinClusters)
    $meshes = stringArrayCatenate($meshes,`skinCluster -q -g $each`);
  textScrollList -e -ra vrur_skinnedMeshList;
  $meshes = sort(stringArrayRemoveDuplicates($meshes));
  for($mesh in $meshes)
    if(startsWith($mesh, "new_model:") == 0)
      textScrollList -e -a $mesh vrur_skinnedMeshList;
}

// ////////////////////////////////////////////////////////////////////////////
// select items within the skinned mesh list (0 = All, 1 = None, 2 = Invert Selection)
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_selectMeshList(int $mode)
{
  int $max = `textScrollList -q -ni vrur_skinnedMeshList`;
  if($mode==0)
    for($i=1;$i<=$max;$i++)
      textScrollList -e -sii $i vrur_skinnedMeshList;
  if($mode==1)
    for($i=1;$i<=$max;$i++)
      textScrollList -e -dii $i vrur_skinnedMeshList;
  if($mode==2)
  {
    int $selected[] = `textScrollList -q -sii vrur_skinnedMeshList`;
    for($i=1;$i<=$max;$i++)
      textScrollList -e -sii $i vrur_skinnedMeshList;
    for($i=0;$i      textScrollList -e -dii $selected[$i] vrur_skinnedMeshList;
  }
}

// ////////////////////////////////////////////////////////////////////////////
// Set the import file
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_setModelFile(string $folder, string $type)
{
textFieldButtonGrp -e -tx $folder vrur_modelFileTextBox;
}

// ////////////////////////////////////////////////////////////////////////////
// create file browser window to select import file
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_createModelFileBrowser ()
{
string $myDir = `textFieldButtonGrp -q -tx vrur_modelFileTextBox`;
fileBrowserDialog -m 0 -ds 0 -fc vrur_setModelFile -an "Choose output folder:"; 
}

// ////////////////////////////////////////////////////////////////////////////
// re-enable the import functionality in the UI and reset settings to last saved or default
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_resetUI()
{
  frameLayout -e -en 1 vrur_modelFileFrame;
  if(`objExists "updateRigScriptNode"` == 1)
    scriptNode -eb updateRigScriptNode;
  vrur_refreshSkinnedMeshList();
}

// ////////////////////////////////////////////////////////////////////////////
// update management of vrur_uvTextField depending on weighting option selected
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_weightRadioChange()
{
  int $selected = `radioButtonGrp -q -sl vrur_weightRadioButton`;
  if($selected == 3)
    textField -e -en 1 vrur_uvTextField;
  else
    textField -e -en 0 vrur_uvTextField;
}

// ////////////////////////////////////////////////////////////////////////////
// Save tool settings to a script node in the file
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_saveSettings()
{
  if(`objExists "updateRigScriptNode"` == 0)
    scriptNode -n "updateRigScriptNode" -st 0;
  string $stringValue = `textFieldButtonGrp -q -tx vrur_modelFileTextBox`;
  string $command = "textFieldButtonGrp -e -tx \"" + $stringValue + "\" vrur_modelFileTextBox;\n";
  int $intValue = `radioButtonGrp -q -sl vrur_jointRadioButton`;
  $command += "radioButtonGrp -e -sl " + $intValue + " vrur_jointRadioButton;\n";
  $intValue = `radioButtonGrp -q -sl vrur_weightRadioButton`;
  $command += "radioButtonGrp -e -sl " + $intValue + " vrur_weightRadioButton;\n";
  if($intValue == 3)
  {
    $stringValue = `textField -q -tx vrur_uvTextField`;
    $command += "textField -e -tx \"" + $stringValue + "\" vrur_uvTextField;\nvrur_weightRadioChange();\n";
  }
  $intValue = `checkBox -q -v vrur_keepOriginalShaderCheckBox`;
  $command += "checkBox -e -v " + $intValue + " vrur_keepOriginalShaderCheckBox;\n";
  // print($command);
  scriptNode -e -bs $command updateRigScriptNode;
  print("Tool Settings saved to file: " + `file -q -sn` + ".\n");
}

// ////////////////////////////////////////////////////////////////////////////
// update the size of the UI window
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_updateUI()
{
  int $height = 127;
  if(`frameLayout -q -cl vrur_modelFileFrame` == 0)
    $height += 44;
  if(`frameLayout -q -cl vrur_skinnedMeshesFrame` == 0)
    $height += 176;
  if(`frameLayout -q -cl vrur_stepsFrame` == 0)
    $height += 257;
  if(`frameLayout -q -cl vrur_settingsFrame` == 0)
    $height += 44;
  window -e -h $height vrur_windowGUI;
}

// ////////////////////////////////////////////////////////////////////////////
// Hide all meshes other than the ones selected in the skinned mesh list
// ////////////////////////////////////////////////////////////////////////////
global proc vrur_isolateMeshes()
{
  string $oldMeshes[] = `textScrollList -q -si vrur_skinnedMeshList`;
  if(size($oldMeshes) == 0)
  {
    warning("No meshes selected in Skinned Meshes list. Please select at least one to isolate.");
    return;
  }
  string $newMeshes[];
  select -cl;
  for($i=0;$i  {
    if(`objExists $oldMeshes[$i]` == 1)
      select -add $oldMeshes[$i];
    $newMeshes[$i] = "new_model:" + $oldMeshes[$i];
    if(`objExists $newMeshes[$i]` == 1)
      select -add $newMeshes[$i];
  }
  showHidden -all;
  HideUnselectedObjects;
}

// ////////////////////////////////////////////////////////////////////////////
// Create the GUI
// ////////////////////////////////////////////////////////////////////////////
global proc VRP_updateRig()
{
  if (`window -ex vrur_windowGUI`)
   deleteUI -window vrur_windowGUI;
  window -tlb 1 -title "Update Rig" -s 0 vrur_windowGUI;
    columnLayout -adj true;
      frameLayout -bs "etchedIn" -cll 1 -l "Model File" -cc vrur_updateUI -ec vrur_updateUI vrur_modelFileFrame;
         columnLayout -adj true;
            textFieldButtonGrp -label "" -cal 1 "left" -buttonLabel "Browse" -buttonCommand vrur_createModelFileBrowser -cw 1 1 -cw 2 320 -cw 3 90 vrur_modelFileTextBox;
            rowColumnLayout -nc 2 -cal 1 "left" -cal 2 "right" -cw 1 195 -cw 2 195;  
              button -l "Import Model" -bgc 0.8 1 0.8 -w 100 -c vrur_importModel;
              button -l "Export Model" -w 100 -c vrur_exportModel;
            setParent..;
          setParent..;
      setParent..;
      frameLayout -bs "etchedIn" -cll 1 -l "Skinned Meshes" -cc vrur_updateUI -ec vrur_updateUI vrur_skinnedMeshesFrame;
        columnLayout -adj true;
          textScrollList -nr 10 -ams 1 vrur_skinnedMeshList;
          rowColumnLayout -nc 4 -cw 1 105 -cw 2 95 -cw 3 95 -cw 4 95 -co 1 "right" 5;
            button -l "Refresh List" -bgc 1 0.8 0.8 -c vrur_refreshSkinnedMeshList;
            button -l "Select All" -bgc 0.8 1 0.8 -c "vrur_selectMeshList(0)";
            button -l "Select None" -c "vrur_selectMeshList(1)";
            button -l "Invert Selection" -c "vrur_selectMeshList(2)";
          setParent..;
          columnLayout -cat "left" 0 -cal "center";  
            button -l "Isolate Selected Meshes" -bgc 0.6 0.6 1 -w 200 -c vrur_isolateMeshes;
          setParent..;
        setParent..;
      setParent..;
      frameLayout -bs "etchedIn" -cll 1 -cl 1 -l "Transfer Steps" -cc vrur_updateUI -ec vrur_updateUI vrur_stepsFrame;
        columnLayout -adj true;
          frameLayout -bs "etchedIn" -cll 0 -l "Skinning" -cc vrur_updateUI -ec vrur_updateUI vrur_skinSettingsFrame;
            columnLayout -adj true;
              radioButtonGrp -nrb 2 -label "Skin to Joints" -la2 "All Influences" "Weighted Only" -vr -cw2 120 200 -select 1 vrur_jointRadioButton;
              columnLayout -cat "left" 120 -cal "center";  
                button -l "Skin Selected Meshes" -bgc 0.8 1 0.8 -w 200 -c vrur_skinMeshes;
              setParent..;
            setParent..;
          setParent..;
          frameLayout -bs "etchedIn" -cll 0 -l "Weight Transfer" -cc vrur_updateUI -ec vrur_updateUI vrur_weightSettingsFrame;
            columnLayout -adj true;
              radioButtonGrp -nrb 3 -label "Weight Transfer" -la3 "Preferred" "Most Recent Settings" "UV Set" -vr -cw2 120 200 -select 1 -cc vrur_weightRadioChange vrur_weightRadioButton;
              columnLayout -cat "left" 120 -cal "center";  
                columnLayout -cat "left" 15 -cal "left";
                  textField -tx "uvWeight" -w 120 -en 0 vrur_uvTextField;
                setParent..;
                button -l "Transfer Weights" -bgc 0.8 1 0.8 -w 200 -c vrur_transferWeights;
              setParent..;
            setParent..;
          setParent..;
          frameLayout -bs "etchedIn" -cll 0 -l "Cleanup" -cc vrur_updateUI -ec vrur_updateUI vrur_cleanupFrame;
            columnLayout -cat "left" 120 -cal "center";
              checkBox -l "Keep Original Shaders" -v 0 vrur_keepOriginalShaderCheckBox;
              button -l "Replace Selected Meshes" -bgc 0.8 1 0.8 -w 200 -c vrur_replaceMeshes;
              button -l "Remove Unused Imported Nodes" -bgc 0.8 1 0.8 -w 200 -c vrur_cleanupUnusedImport;
            setParent..;
          setParent..;
        setParent..;
      setParent..;
      frameLayout -bs "etchedIn" -cll 1 -cl 1 -l "Tool Settings" -cc vrur_updateUI -ec vrur_updateUI vrur_settingsFrame;
        columnLayout -cat "left" 120 -cal "center";
          button -l "Save settings to file" -w 200 -bgc 0.6 0.6 1 -c vrur_saveSettings;
          button -l "Reset UI" -bgc 0.6 0.6 1 -w 200 -c vrur_resetUI;
        setParent..;
      setParent..;
      button -l "Do All Transfer Steps" -bgc 0.1 1 0.1 -c vrur_doTransfer;
  window -e -w 400 -h 365 -s 1 vrur_windowGUI;
  showWindow vrur_windowGUI;
  vrur_resetUI();
  vrur_updateUI();
}

Back to Main

© 2003-2013 Andrew Kelts