global proc convertToLambert() { global string $newMatType; global int $preserve = 1; global int $transp = 1; //int $workOn = `radioButtonGrp -q -sl workOnGrp`; //if ($workOn == 2) // string $materials[] = `ls -sl -mat`; //else string $materials[] = `ls -materials`; $newMatType = `optionMenuGrp -q -v typeMenu`; for ( $mat in $materials ) { string $type = `nodeType $mat`; if ($mat != "lambert1") if ($mat != "layeredDepth") if ($mat != "shaderGlow1") if ($type != "particleCloud") { string $origMat = $mat; string $new = `createNode $newMatType`; replaceNode $origMat $new; delete $origMat; rename $new $mat; } } } global proc reAssignToDepth() { global string $newMatType;// = "lambert"; global int $preserve = 1; global int $transp = 1; string $materials[] = `ls -materials`; for ( $mat in $materials ) { // string $attributes[] = `listAttr -r -w -k $mat`; string $attributes[] = { "color", "ambientColor", "incandescence", "normalCamera", "diffuse", "translucence", "translucenceDepth", "translucenceFocus" }; string $type = `nodeType $mat`; string $depthName = `textFieldGrp -q -tx depthName`; string $attrName = `textFieldGrp -q -tx attrName`; string $depth[]; tokenize $depthName "." $depth; if ($mat != $depth[0]) if ($mat != "lambert1") if ($mat != "layeredDepth") if ($mat != "shaderGlow1") if ($type != "particleCloud") { for ($attr in $attributes) { string $attrType = `getAttr -typ ($mat + "." + $attr)`; string $source = `connectionInfo -sfd ($mat + "." + $attr)`; if ($source != "") if ($attr != "transparency") if ($attr != "transparencyR") if ($attr != "transparencyG") if ($attr != "transparencyB") disconnectAttr $source ($mat + "." + $attr); if ($attr == "color") { setAttr -type double3 ($mat + "." + $attr) 1 1 1; } else if ($attrType == "double3") setAttr -type double3 ($mat + "." + $attr) 0 0 0; else if ($attrType == "float") setAttr ($mat + "." + $attr) 0; } connectAttr $depthName ($mat + "" + $attrName); //connectAttr layeredDepth.outColor ($mat + ".ambientColor"); } } } global proc zDepthSetup() { global string $newMatType; global int $preserve = 1; global int $transp = 1; string $winName = "zDepthSetup"; if (`window -exists $winName`) deleteUI $winName; window -t "zDepthSetup" -wh 400 200 $winName; frameLayout -label "Setup Options" -borderStyle "in" // -cll 1 -li 10 -la "center" -mw 5 -mh 5 -w 275 ; rowColumnLayout -nr 7 //-rh 1 25 //-rh 2 25 //-rh 3 25 //-rh 4 50 //-rh 5 25 //-rh 6 25 //-rh 7 25 //-rowSpacing 1 2 //-rowSpacing 2 2 //-rowSpacing 3 2 //-rowSpacing 4 2 //-rowSpacing 5 2 ; //create Controls /* radioButtonGrp -en 0 -l "Work On" -l1 "All" -l2 "Selection" -sl 1 -nrb 2 -cal 1 "left" -cal 2 "left" workOnGrp ;*/ string $nodes[] = `listNodeTypes "shader/surface"`; optionMenuGrp -cc ("$newMatType = `optionMenuGrp -q -v typeMenu`") -label "Convert All Materials To" typeMenu ; for ($item in $nodes) { menuItem -l $item; } $newMatType = $nodes[0]; //setParent ..; /*rowColumnLayout -nr 1 -rh 1 50 //-columnSpacing 2 5 ;*/ checkBoxGrp -cal 1 "left" -en 0 -ncb 1 -l "Preserve Default Materials" -v1 1 -cc ("$preserve = `checkBoxGrp -q -v1 defMats`") defMats; checkBoxGrp -cal 1 "left" -en 0 -ncb 1 -l "Preserve Transparencies" -v1 1 -cc ("$transp = `checkBoxGrp -q -v1 trans`") trans; //text -l ""; textFieldGrp -l "Connect Material . Attr" //-cc ($oddSynchName = `textFieldGrp -q -tx SynchName`) -w 50 -h 25 -cal 1 "left" -cal 2 "left" -tx "DepthShader.outColor" depthName ; textFieldGrp -l "Connect To *. Attr" //-cc ($oddSynchName = `textFieldGrp -q -tx SynchName`) -w 50 -h 25 -cal 1 "left" -cal 2 "left" -tx ".ambientColor" attrName ; //setParent ..; rowColumnLayout -nc 3 -cw 1 100 -cw 2 100 -cw 3 100 -columnSpacing 1 5 -columnSpacing 2 5 -columnSpacing 3 5 ; button -w 100 -l "1. Convert" -c "convertToLambert()"; button -w 100 -l "2. Import Depth" -c "Import"; button -w 100 -l "3. Assign" -c "reAssignToDepth()"; // button -w 100 -l "test" -c ("print $newMatType"); showWindow $winName; }