// =========================================================================== // 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. // =========================================================================== // // Description: // Implement a tool context that simulates flying the camera // through a scene. // // // Procedure Name: // getFlyThroughCamera // // Description: // Get the active camera for the model view under the pointer. // // Input Arguments: // None. // // Return Value: // The name of the camera or an empty string. // proc string getFlyThroughCamera() { string $camera = ""; string $panel = `getPanel -underPointer`; if ($panel != "") { // // Make sure the panel is a model view and contains a // perspective camera. // string $type = `getPanel -typeOf $panel`; if ($type == "modelPanel" ) { $camera = `modelPanel -query -camera $panel`; } else { // Look for stereo panels string $editors[] = `lsUI -editors -type scriptedPanel`; for ($i=0 ; $i= abs($position[0] - $gFlyThroughLastPosition[0])) { if ($position[1] > $gFlyThroughLastPosition[1]) { // // Move forward. // dolly -relative -distance (-$stepForwardDistance) $camera; } else if ($position[1] < $gFlyThroughLastPosition[1]) { // // Move backward. // dolly -relative -distance $stepForwardDistance $camera; } } else { if ($position[0] > $gFlyThroughLastPosition[0]) { // // Move right. // track -right $stepSideDistance $camera; } else if ($position[0] < $gFlyThroughLastPosition[0]) { // // Move left. // track -left $stepSideDistance $camera; } } $refresh = true; // Need to update the anchor position and camera rotation so that // when the camera stops moving further look actions are relative // to where the Ctrl key was released. // $gFlyThroughAnchor = $position; $gFlyThroughRotation = `getAttr ($camera + ".rotate")`; } } } $gFlyThroughLastPosition = $position; if ($refresh) refresh -currentView; } // // Description: // Create the context. // { if (`draggerContext -exists flyThroughContext`) deleteUI flyThroughContext; draggerContext -pressCommand ("flyThroughPress ; undoInfo -swf 0") // turn off undo -dragCommand "flyThroughDrag" -releaseCommand ("undoInfo -swf 1 ; flyThroughRelease") // turn on undo -cursor "fly" -image1 "flyThrough.png" flyThroughContext; }