// =========================================================================== // 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. // =========================================================================== // // Render with current renderer to the editor. // Resolution and camera name is given. // This procedure finds the interactive render command for the current renderer // and renders into the editor. // The full path to the image file name is returned. // This function is evoked from renderWindowPanel.mel // // NOTE: // for the image to be recycled later, the renderer should write the // tmp image in the disk // global proc string renderWithCurrentRenderer( string $editor, string $camera, int $resolution[], int $doShadows, int $doGlowPass, string $option ) { global string $gBeforeFrameRenderCallbacks[]; global string $gAfterFrameRenderCallbacks[]; string $feature = "render"; string $renderer = currentRenderer(); string $command; int $err = 0; string $result = ""; if (`renderer -query -renderProcedure $renderer` != "") { $command = `renderer -query -renderProcedure $renderer`; // Suspend material view renderer while frame rendering is running renderer -materialViewRendererSuspend true; for($cmd in $gBeforeFrameRenderCallbacks) { eval($cmd); } float $startTime = `timerX`; $err = catch($result = `eval $command $resolution[0] $resolution[1] $doShadows $doGlowPass $camera $option`); float $renderTime = `timerX -startTime $startTime`; for($cmd in $gAfterFrameRenderCallbacks) { eval($cmd); } // Resume material view renderer renderer -materialViewRendererSuspend false; if( $err ) $result = ""; string $currentRendererName = currentRenderer(); string $renUIName = renderWindowCaption("", $renderTime); renderWindowEditor -edit -pca $renUIName $editor; } else { string $renUIName = `renderer -query -rendererUIName $renderer`; string $msg = (uiRes("m_renderWithCurrentRenderer.kCannotRender")); warning (`format -stringArg $renUIName $msg`); } return $result; }