//////////////////////////// // written by Mike Paixao // // instructions can be // // found at: // // mike.simpletofind.ca // //////////////////////////// { // this first section creates all the objects needed for the script // $sel = `ls -sl`; //$camera = `ls -sl`; //pickWalk -d down; //$camShape = `ls -sl`; //if (`size $sel` == 0 ) // error "nothing selected, grab your cam!"; //if ( `objectType -i "camera" $camShape[0]` == 0 ) // error "select a camera"; $near = `spaceLocator -n "cameraLoc" -p 0 0 0`; $char = `spaceLocator -n "characterLoc" -p 0 0 0`; $far = `spaceLocator -n "endLoc" -p 0 0 0`; $shader = `shadingNode -asShader surfaceShader`; $distanceTotal = `shadingNode -n "totalDistance" -asUtility distanceBetween`; $distanceCharacter = `shadingNode -n "characterDistance" -asUtility distanceBetween`; $characterPosition = `shadingNode -n "characterPosition" -asUtility multiplyDivide`; setAttr ($characterPosition + ".operation") 2; $distanceScale = `shadingNode -n "halfDist" -asUtility multiplyDivide`; setAttr ($distanceScale + ".operation") 2; setAttr ($distanceScale + ".input2X") 2; // default way of creating a ramp shader with a projection node // $rampProj = `shadingNode -asTexture projection`; $ramp = `shadingNode -asTexture ramp`; $threeDtexture = `shadingNode -asUtility place3dTexture`; connectAttr ($threeDtexture+ ".wim[0]") ($rampProj+ ".pm"); connectAttr ($ramp + ".outColor") ($rampProj+ ".image"); $twoDtexture = `shadingNode -asUtility place2dTexture`; connectAttr ($twoDtexture +".outUV") ($ramp + ".uv"); connectAttr ($twoDtexture+ ".outUvFilterSize") ($ramp + ".uvFilterSize"); addAttr -ln "fallof" -at double -dv .1 $char[0]; setAttr -e -keyable true ($char[0] + ".fallof"); setAttr ($twoDtexture +".wrapV") 0; select -r ($threeDtexture+".scalePivot") ($threeDtexture+".rotatePivot") ; move -yz -1 1; select -r $threeDtexture; rotate -r -os -90 0 0 ; move -rpr 0 0 0 ; parent $threeDtexture $near; select -r $far; move -r -os -wd 0 0 -2 ; aimConstraint -mo -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 $far $near; // connect the distance nodes to their corresponding locators // // and ramp to the shader // connectAttr -f ($rampProj + ".outColor") ($shader + ".outColor"); connectAttr -f ($near[0] + ".worldMatrix") ($distanceTotal + ".inMatrix1"); connectAttr -f ($far[0] + ".worldMatrix") ($distanceTotal + ".inMatrix2"); connectAttr -f ($near[0] + ".worldMatrix") ($distanceCharacter + ".inMatrix1"); connectAttr -f ($char[0] + ".worldMatrix") ($distanceCharacter + ".inMatrix2"); //pointConstraint -offset 0 0 0 -weight 1 $camera $near; connectAttr -force ($distanceTotal + ".distance") ($characterPosition + ".input2X"); connectAttr -force ($distanceCharacter + ".distance") ($characterPosition + ".input1X"); connectAttr -force ($distanceTotal + ".distance") ($distanceScale + ".input1X"); connectAttr -force ($distanceScale + ".outputX")($threeDtexture + ".scaleY"); // now modify the ramp section // setAttr ($ramp + ".colorEntryList[0].color") -type double3 1 1 1; setAttr ($ramp + ".colorEntryList[1].color") -type double3 0 0 0; setAttr ($ramp + ".colorEntryList[2].color") -type double3 0 0 0 ; setAttr ($ramp + ".colorEntryList[3].color") -type double3 0 0 0 ; setAttr ($ramp + ".colorEntryList[4].color") -type double3 1 1 1 ; setAttr ($ramp + ".colorEntryList[0].position") 0; setAttr ($ramp + ".colorEntryList[1].position") 0.4; setAttr ($ramp + ".colorEntryList[2].position") 0.5; setAttr ($ramp + ".colorEntryList[3].position") 0.6; setAttr ($ramp + ".colorEntryList[4].position") 1; connectAttr -f ($characterPosition + ".outputX") ($ramp + ".colorEntryList[2].position"); //print ("$fallof = `getAttr characterLoc.fallof`;\r\n$pos = `getAttr \" "+ $ramp +".colorEntryList[3].position\"`;\r\n\r\n "+ $ramp +".colorEntryList[3].position = "+ $ramp +".colorEntryList[2].position + $fallof;\r\n\r\n"+ $ramp +".colorEntryList[1].position = "+ $ramp +".colorEntryList[2].position - $fallof;"); $expression = `expression -s ("$fallof = `getAttr characterLoc.fallof`;\r\n$pos = `getAttr \" "+ $ramp +".colorEntryList[3].position\"`;\r\n\r\n "+ $ramp +".colorEntryList[3].position = "+ $ramp +".colorEntryList[2].position + $fallof;\r\n\r\n"+ $ramp +".colorEntryList[1].position = "+ $ramp +".colorEntryList[2].position - $fallof;") -o "" -n "DOFexpression" -ae 1 -uc all`; }