// 3D phantomWindow // written by jeremy cantor // June 18, 2006 global string $deleteOnExecute = "No"; global string $areWeDeleting = "No"; global string $temOrTran = "Template"; global float $transR = 0.85; global float $transG = 0.85; global float $transB = 0.85; global proc deleteExistingPhantoms() { if (`objExists "phantomObjectGroup"`) delete "phantomObjectGroup"; if (`objExists "phantomShader*SG"`) delete "phantomShader*SG"; } global proc deleteUnusedPhantomShaders() { for ($colorNumber = 1; $colorNumber < 10; $colorNumber++) { string $whatzShaderSG = "phantomShader" + $colorNumber + "SG"; if (`objExists $whatzShaderSG`) { string $shaderConnections[] = `listConnections -d false $whatzShaderSG`; if (`size $shaderConnections` < 2) delete $whatzShaderSG; } } int $whatzColor = `optionMenu -q -sl translucentColor`; string $whatzShaderSG = "phantomShader" + $whatzColor + "SG"; if (`objExists $whatzShaderSG `) floatSlider -e -en true translucencySlider ; else floatSlider -e -en false translucencySlider; } global proc swapTT() { string $currentPhantomGroup[] = `ls -sl`; for ($x=0; $x<(size($currentPhantomGroup)); $x++) { if (`gmatch $currentPhantomGroup[$x] "phantomGroup*"`) { if (`toggle -q -template $currentPhantomGroup[$x]` == 1) { toggle -state off -template $currentPhantomGroup[$x] ; string $tempKids[] = `listRelatives -c $currentPhantomGroup[$x]`; displaySmoothness -divisionsU 3 -divisionsV 3 -pointsWire 16 -pointsShaded 4 $tempKids; int $currentColor = `optionMenu -q -sl translucentColor`; string $currentShader = "phantomShader" + $currentColor; string $currentShaderSG = $currentShader + "SG"; if (!`objExists $currentShaderSG`) { shadingNode -n $currentShader -as lambert; sets -renderable true -noSurfaceShader true -empty -name $currentShaderSG; string $currentShaderOutColor = ($currentShader + ".outColor"); string $currentShaderSurface = ($currentShaderSG + ".surfaceShader"); connectAttr -f $currentShaderOutColor $currentShaderSurface; string $currentShaderColor = ($currentShader + ".color"); switch ($currentColor) { case 1 : setAttr $currentShaderColor -type double3 0.6 0.6 0.6 ; break; case 2 : setAttr $currentShaderColor -type double3 1.0 0 0 ; break; case 3 : setAttr $currentShaderColor -type double3 0 1.0 1.0 ; break; case 4 : setAttr $currentShaderColor -type double3 1.0 1.0 0 ; break; case 5 : setAttr $currentShaderColor -type double3 0 0 1.0 ; break; case 6 : setAttr $currentShaderColor -type double3 1.0 0.5 0 ; break; case 7 : setAttr $currentShaderColor -type double3 0 0 0 ; break; case 8 : setAttr $currentShaderColor -type double3 0 1.0 0 ; break; case 9 : setAttr $currentShaderColor -type double3 1.0 0 1.0 ; break; } updateTranslucency 0.85 0.85 0.85; floatSlider -e -en true translucencySlider ; } select -r $tempKids; string $shadeMe[] = `ls -sl -l -dag -g`; sets -e -nw -forceElement $currentShaderSG $shadeMe; select -r $currentPhantomGroup; } else { toggle -state on -template $currentPhantomGroup[$x] ; string $tempKids[] = `listRelatives -c $currentPhantomGroup[$x]`; displaySmoothness -divisionsU 0 -divisionsV 0 -pointsWire 4 -pointsShaded 1 $tempKids; } } } } global proc selectAll() { if (`objExists "phantomObjectGroup"`) { string $tempKids[] = `listRelatives -c "phantomObjectGroup"`; if (size($tempKids) != 0) select "phantomGroup_*"; } } global proc showAll() { if (`objExists "phantomObjectGroup"`) { string $selectedz[] = `ls -sl -l`; select -r "phantomObjectGroup"; showHidden; select -r "phantomGroup_*"; showHidden; select -r $selectedz; } } global proc hideAll() { if (`objExists "phantomObjectGroup"`) { string $selectedz[] = `ls -sl -l`; select "phantomGroup_*"; hide; select -r $selectedz; } } global proc hidePhantom() { string $currentPhantomGroup[] = `ls -sl`; if (`gmatch $currentPhantomGroup[0] "phantomGroup*"`) hide; select -r $currentPhantomGroup[0]; } global proc showPhantom() { string $currentPhantomGroup[] = `ls -sl`; if (`gmatch $currentPhantomGroup[0] "phantomGroup*"`) showHidden; select -r $currentPhantomGroup[0]; } global proc deletePhantom() { string $currentPhantomGroup[] = `ls -sl`; if (`gmatch $currentPhantomGroup[0] "phantomGroup*"`) delete; if (`objExists "phantomObjectGroup"`) {string $anyLeft[] = `listRelatives -c phantomObjectGroup`; if (size($anyLeft) == 0) delete phantomObjectGroup;} deleteUnusedPhantomShaders; } global proc removeVizSwap(){ string $currentPhantomGroup[] = `ls -sl -tr`; for ($x=0; $x<=size($currentPhantomGroup); $x++) if (`gmatch $currentPhantomGroup[$x] "phantomGroup*"`) { print ($currentPhantomGroup[$x] + "\n"); cutKey -cl -t ":" -f ":" -at "visibility" $currentPhantomGroup[$x]; setAttr ($currentPhantomGroup[$x] + ".visibility") 1; } } global proc enableVizSwap(){ text -e -en (`checkBox -q -v vizSwapCB`) holdForText; intField -e -en (`checkBox -q -v vizSwapCB`) holdFor; } global proc updateHoldFor(){ intField -e -v (`intField -q -v stepByPH`) holdFor; } global proc newSliderColor() { int $whatzColor = `optionMenu -q -sl translucentColor`; string $whatzShader = "phantomShader" + $whatzColor; string $whatzShaderSG = $whatzShader + "SG"; if (`objExists $whatzShaderSG`) {string $whatzTransl = $whatzShader + ".transparency"; float $whatzTranslValue[3] = `getAttr $whatzTransl`; floatSlider -e -v ($whatzTranslValue[1]) translucencySlider; floatSlider -e -en true translucencySlider;} else floatSlider -e -en false translucencySlider; string $currColor = `optionMenu -q -v translucentColor`; } global proc incrementColors(){ if (`radioButtonGrp -q -sl tempOrTrans` == 2) { int $whatzColor = `optionMenu -q -sl translucentColor`; if ($whatzColor < 9) $whatzColor = $whatzColor + 1; else $whatzColor = 1; optionMenu -e -sl $whatzColor translucentColor; } string $currColor = `optionMenu -q -v translucentColor`; } global proc callShader() { int $whatzColor = `optionMenu -q -sl translucentColor`; string $whatzShaderSG = "phantomShader" + $whatzColor + "SG"; if (`objExists $whatzShaderSG `) showEditor $whatzShaderSG; } global proc updateTranslucency(float $transR, float $transG, float $transB) { $transR = `floatSlider -q -v translucencySlider`; $transG = `floatSlider -q -v translucencySlider`; $transB = `floatSlider -q -v translucencySlider`; int $whatzColor = `optionMenu -q -sl translucentColor`; string $updateSG = "phantomShader" + $whatzColor + "SG"; string $updateTransl = "phantomShader" + $whatzColor + ".transparency"; if (`objExists $updateSG`) setAttr $updateTransl -type double3 $transR $transG $transB; } global proc walkToNextPhantom() { string $currentPhantomGroup[] = `ls -sl`; if (`gmatch $currentPhantomGroup[0] "phantomGroup*"`) pickWalk -d right; } global proc walkToPreviousPhantom() { string $currentPhantomGroup[] = `ls -sl`; if (`gmatch $currentPhantomGroup[0] "phantomGroup*"`) pickWalk -d left; } global proc enableRange() { text -e -en (`checkBox -q -v rangeCB`) rangeTextPH; intField -e -en (`checkBox -q -v rangeCB`) rangeStartPH; text -e -en (`checkBox -q -v rangeCB`) toTextPH; intField -e -en (`checkBox -q -v rangeCB`) rangeEndPH; text -e -en (`checkBox -q -v rangeCB`) byTextPH; intField -e -en (`checkBox -q -v rangeCB`) stepByPH; text -e -en false listTextPH; checkBox -e -v 0 listCB; textField -e -en false listFieldPH; } global proc enableList() { if (`checkBox -q -v listCB` == 1) { text -e -en false rangeTextPH; checkBox -e -v 0 rangeCB; intField -e -en false rangeStartPH; text -e -en false toTextPH; intField -e -en false rangeEndPH; text -e -en false byTextPH; intField -e -en false stepByPH; text -e -en true listTextPH; textField -e -en true listFieldPH; } else { text -e -en false listTextPH; textField -e -en false listFieldPH; } } ////////////////////////// ////////////////////////// global proc makePhantoms (string $deleteOnExecute, string $temOrTran, float $transR, float $transG, float $transB) { //proc open string $parentz[]; string $whatzPicked[] = `ls -sl -l`; int $numPicked = `size($whatzPicked)`; if ($numPicked == 0) {print "Nothing Selected\n"; return;} int $rangeStartPH = 0; int $rangeEndPH = 0; int $stepByPH = 1; int $frameSet[] = {}; string $frameList[] = {}; if (`checkBox -q -v rangeCB` == 1) { print "\nrange\n"; $rangeStartPH = `intField -q -v rangeStartPH`; $rangeEndPH = `intField -q -v rangeEndPH`; $stepByPH = `intField -q -v stepByPH`; for ($z = $rangeStartPH; $z <= $rangeEndPH; $z = $z + $stepByPH) { int $syze = size($frameSet); $frameSet[$syze] = $z; } } else if (`checkBox -q -v listCB` == 1) { print "\nlist\n"; string $getFrames = `textField -q -tx listFieldPH`; if ($getFrames == "") {print "Empty List\n"; return;} tokenize ($getFrames, " ", $frameList); for ($x=0; $x" -al "center" -c walkToNextPhantom; button -label "Pick All" -al "center" -c selectAll; button -label "clear" -al "center" -c "select -cl"; setParent ..; //row 2 rowColumnLayout -nc 3 -cw 1 115 -cw 2 110 -cw 3 75; button -label "Delete Phantom" -al "center" -c deletePhantom; button -label "Delete All Phantoms" -al "center" -c deleteExistingPhantoms; setParent ..; //row 3 rowColumnLayout -nc 4 -cw 1 60 -cw 2 45 -cw 3 65 -cw 4 55; button -l "Hide Phtm" -c hidePhantom; button -l "Hide All" -c hideAll; button -l "Show Phtm" -c showPhantom; button -l "Show All" -c showAll; setParent ..; //row 4 rowColumnLayout -nc 2 -cw 1 140 -cw 2 110; checkBox -l "One phantom at a time" -v 0 -onc "$areWeDeleting = \"Yes\"" -ofc "$areWeDeleting = \"No\"" checkBoxDel; checkBox -l "Cycle colors" -v 0 checkBoxCycle; // checkBox -l "Animated Phantom" animCB; setParent ..; //row 5 //rowColumnLayout -nc 4 -cw 1 145 -cw 2 30 -cw 3 15 -cw 4 30 -co 3 "left" 2; // checkBox -l "Bake individual selections" -en false bakeCB; // intField -en false -v `playbackOptions -q -min` bakeStart; // text -l "to" -en false toTextPH; // intField -en false -v `playbackOptions -q -max` bakeEnd; //setParent ..; //checkBox -e -onc "checkBox -e -en true bakeCB" animCB; //checkBox -e -ofc "checkBox -e -en false -v 0 bakeCB; intField -e -en false bakeStart; intField -e -en false bakeEnd; text -e -en false toTextPH" animCB; //checkBox -e -onc "intField -e -en true bakeStart; intField -e -en true bakeEnd; text -e -en true toTextPH" bakeCB; //checkBox -e -ofc "intField -e -en false bakeStart; intField -e -en false bakeEnd; text -e -en false toTextPH" bakeCB; //row 6 rowColumnLayout -nc 2 -cw 1 220 -cw 2 95; radioButtonGrp -nrb 2 -sl 1 -cw 1 120 -labelArray2 "TEMPLATED or" "TRANSLUCENT" -on1 "$temOrTran = \"Template\"" -on2 "$temOrTran = \"Translucent\"" tempOrTrans; button -vis false; setParent ..; //row 8 // floatSliderGrp -field true -cw 1 35 rowColumnLayout -nc 3 -cw 1 150 -cw 2 75 -co 2 "left" 5; floatSlider -min 0 -max 1 -v 0.85 -en true -dc "updateTranslucency $transR $transG $transB" -cc "updateTranslucency $transR $transG $transB" translucencySlider; optionMenu -cc newSliderColor translucentColor; menuItem -label "Grey"; menuItem -label "Red"; menuItem -label "Indigo"; menuItem -label "Yellow"; menuItem -label "Blue"; menuItem -label "Orange"; menuItem -label "Black"; menuItem -label "Green"; menuItem -label "Violet"; optionMenu -e -sl 1 translucentColor; int $whatzColor = `optionMenu -q -sl translucentColor`; string $whatzShaderSG = "phantomShader" + $whatzColor + "SG"; if (`objExists $whatzShaderSG `) floatSlider -e -en true translucencySlider ; else floatSlider -e -en false translucencySlider; setParent ..; //row 7 rowColumnLayout -nc 2 -cw 1 175 -cw 2 45; button -l "Swap Templated <--> Translucent" -c swapTT; button -l "shader" -c callShader; setParent ..; //row 9 rowColumnLayout -nc 8 -cw 1 20 -cw 2 40 -cw 3 40 -cw 4 20 -cw 5 45 -cw 6 20 -cw 7 35; checkBox -l "" -v 0 -cc enableRange rangeCB; text -l "Range" -en false rangeTextPH; intField -v (`playbackOptions -q -min`) -en false rangeStartPH; text -l " to" -en false toTextPH; intField -v (`playbackOptions -q -max`) -en false rangeEndPH; text -l " by" -en false byTextPH; intField -v 1 -en false -cc updateHoldFor stepByPH; setParent ..; //row 10 rowColumnLayout -nc 8 -cw 1 20 -cw 2 25 -cw 3 175; checkBox -l "" -v 0 -cc enableList listCB; text -l "List" -en false listTextPH; textField -en false listFieldPH; setParent ..; //row 11 rowColumnLayout -nc 4 -cw 1 20 -cw 2 110 -cw 3 30 -cw 4 60 -co 4 "left" 5; checkBox -v 0 -l "" -cc enableVizSwap vizSwapCB; text -l "Viz Swap --- Hold For" -en false holdForText; intField -v 1 -en false holdFor; button -l "Remove" -c removeVizSwap; setParent ..; //row 12 rowColumnLayout -nc 3 -cw 1 45 -cw 2 45 -cw 3 130 -co 3 "left" 5; button -l "< frame" -c "currentTime (`currentTime -q` - 1)"; button -l "frame >" -c "currentTime (`currentTime -q` + 1)"; button -label " MAKE PHANTOM(S) " -al "center" -c "makePhantoms $areWeDeleting $temOrTran $transR $transG $transB"; setParent ..; showWindow phantomWindow; } phantomWindow;