/* alien ForeSight v 1.0 ******what does this script do? this script creates a new tool to modify the camera offset and overscan. ******what do I have to do to use it? a) copy this file to your script directory b) copy the image "alienForeSight.bmp" to your icons directory c) add the line "alienForeSight()" to your userSetup.mel file (with no quotation marks) d) map the command "setToolTo alienForeSightTool;" to a shelf button or a shortcut d2) you can also copy the file "toolbox.mel" to your script directory, this will substitute the original toolbox and put the tool button at the bottom of the toolbox. ******how can I use it? use the shortcut or click the shelf button,and use the foreSight. When the tool is active with left mouse button you can pan changing the camera offset, and center mouse button let you zoom changing the overscan of the camera. mouse click + ctrl will reset the offset to 0 and the overscan to 1...awesome!!! ^_^ ******limitations ...no limitations! ^_^ ******thanks to Max Liani and his Active Zoom for the idea! ******credits Nicola Danese --> n.danese@ubik.it */ global proc alienForeSight () { //global var to get the offset and overscan global float $vertOffStart = 0; global float $horiOffStart = 0; global float $overScanStart = 0; draggerContext -pressCommand "onPress" -dragCommand "onDrag" -releaseCommand "onRelease" -cursor "crossHair" //-image1 "alienForeSight.bmp" alienForeSightTool; } global proc onPress() { global float $vertOffStart; global float $horiOffStart; global float $overScanStart; //get the initial press point float $pressPosition[] = `draggerContext -query -anchorPoint alienForeSightTool`; //get the active camera shape string $cam = getCurrentCameraShape(); //get camera attributes $vertOffStart = `getAttr ($cam + ".horizontalFilmOffset")`; $horiOffStart = `getAttr ($cam + ".verticalFilmOffset")`; $overScanStart = `getAttr ($cam + ".overscan")`; } global proc onDrag() { global float $vertOffStart; global float $horiOffStart; global float $overScanStart; //get the initial press position float $pressPosition[] = `draggerContext -query -anchorPoint alienForeSightTool`; //get the actual mouse position float $dragPosition[] = `draggerContext -query -dragPoint alienForeSightTool`; //check the mouse button int $press = `draggerContext -query -button alienForeSightTool`; //get the active camera shape string $cam = getCurrentCameraShape(); //che ck which mouse button and which modifier I'm using... int $mouseClick = `draggerContext -query -button alienForeSightTool`; string $mod = `draggerContext -query -modifier alienForeSightTool`; //mouse left button, change the camera offset if ($mouseClick == 1) { //analyze how much I change the offset float $hor = $vertOffStart - (($dragPosition[0] - $pressPosition[0])/1000); float $ver = $horiOffStart - (($dragPosition[1] - $pressPosition[1])/1000); setAttr ($cam + ".horizontalFilmOffset") $hor; setAttr ($cam + ".verticalFilmOffset") $ver; } //mouse center button, change the overscan else if ($mouseClick == 2) { //analyze how much I change the overscan float $over = $overScanStart + (($dragPosition[1] - $pressPosition[1])/500); if ($over < 0.001) { $over = 0.01; } setAttr ($cam + ".overscan") $over; } refresh; } global proc onRelease() { //get the active camera shape string $cam = getCurrentCameraShape(); //release mouse button with ctrl down?reset the camera! string $mod = `draggerContext -query -modifier alienForeSightTool`; if ($mod == "ctrl") { setAttr ($cam + ".horizontalFilmOffset") 0; setAttr ($cam + ".verticalFilmOffset") 0; setAttr ($cam + ".overscan") 1; } //get camera attributes float $vertOff = `getAttr ($cam + ".horizontalFilmOffset")`; float $horiOff = `getAttr ($cam + ".verticalFilmOffset")`; float $overScan = `getAttr ($cam + ".overscan")`; //print to video the attribute print ("VerOff: " + $vertOff + " *** HorOff: " + $horiOff + " *** OverScan: " + $overScan + "\n"); } //setToolTo alienForeSightTool; global proc string getCurrentCameraShape() { string $currentCamera; string $panel = `getPanel -wf`; if ( "modelPanel" == `getPanel -to $panel` ) { $currentCamera = `modelEditor -q -camera $panel`; } // have we returned the camera shape or transform node? string $camType[] = `ls -st $currentCamera`; if ( $camType[1] != "camera" ) { // don't have the shape node, so find it! string $camShape[] = `listRelatives -c -f -typ camera $currentCamera`; $currentCamera = $camShape[0]; } return $currentCamera; }