Monday, March 15, 2010

Mel : Matchmover's Handy Tool

with camera offset x y and overscan attribute you can pan left right and zoom on to the imageplane without affecting camera transform node. this is really handy specially for matchmoving when you are trying to lineup camera to the track geometry or fixing camera and you want to zoom into the imageplane really close without affecting camera.


global proc drag_Xpan(){
string $camName[] = `ls -sl`;
string $camShapeName[] = `listRelatives -s $camName[0]`;
dragAttrContext dxpan;
dragAttrContext -edit -ct ($camShapeName[0] +".horizontalFilmOffset") dxpan;
setToolTo dxpan;
}


global proc drag_Ypan(){
string $camName[] = `ls -sl`;
string $camShapeName[] = `listRelatives -s $camName[0]`;
dragAttrContext dypan;
dragAttrContext -edit -ct ($camShapeName[0] +".verticalFilmOffset") dypan;
setToolTo dypan;
}


global proc drag_Zoom(){
string $camName[] = `ls -sl`;
string $camShapeName[] = `listRelatives -s $camName[0]`;
dragAttrContext dzoom;
dragAttrContext -edit -ct ($camShapeName[0] +".overscan") dzoom;
setToolTo dzoom;
}


global proc resetCam(){
string $camName[] = `ls -sl`;
string $camShapeName[] = `listRelatives -s $camName[0]`;
setAttr ($camShapeName[0] +".horizontalFilmOffset") 0;
setAttr ($camShapeName[0] +".verticalFilmOffset") 0;
setAttr ($camShapeName[0] +".overscan") 1;
}

To test these procedures i am going to add these to the my custom maya shelf. if you want you can make hotkey for these to make it even quicker. its your choice. i personally use hotkeys for these. dig in thru my earlier post to see how to make hotkey thru mel.

but just for testing purpose i am adding them to shelf.


scriptToShelf "X" "drag_Xpan;" "1";
scriptToShelf "Y" "drag_Ypan;" "1";
scriptToShelf "Y" "drag_Zoom;" "1";
scriptToShelf "reset" "resetCam;" "1";


Select a camera and look thru that camera in current model panel. load any image in the imageplane so that we can test these procedures better to see whats happening. test them one at a time using middle mouse drag screen left-right. hold control key while dragging middle mouse will make the drag slower and once you done you can reset them to default value.

hope this is helpful. please make any suggestion if you have any.

No comments:

Integration/Tracking Demo Reel 2018 on Youtube