// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Procedure Name: // buildPerspLookthruMenu // // Description: // This procedure creates a menu item for each perspective // camera. New cameras can also be created through this // menu. When a menu item is selected the associated camera will // be placed in the model view. // // Input Arguments: // parent - menu name to build menu items for // panel - name of panel this menu is associated with // // Return Value: // None. // global proc buildPerspLookthruMenu( string $parent, string $panel ) { global string $gLegacyViewport; string $cameras[] = `listCameras -perspective`; // Rebuild menu // setParent -m $parent; menu -e -deleteAllItems $parent; python("from maya.app.stereo import stereoCameraRig"); for ($camera in $cameras) { // Prune out any children of camera rigs. Non camera // rigs only have 1 camera. // int $isMono = python("stereoCameraRig.rigRoot('"+$camera+"') == ''"); if ($isMono) { menuItem -l $camera -command ("lookThroughModelPanel "+$camera+" "+$panel); } } menuItem -divider true; menuItem -label (uiRes("m_buildPerspLookthruMenu.kNew")) -c ("{ string $camera[] = `camera -n persp -hc \"viewSet -p %camera\"`; "+ " viewSet -p $camera[0]; "+ " lookThroughModelPanel $camera[0] " + $panel+ "; " + " if (`optionVar -q \"viewportRenderer\"`== 2) ActivateViewport20; else setRendererInModelPanel $gLegacyViewport " + $panel + ";}" ); }