// =========================================================================== // 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. // =========================================================================== // // // Creation Date: 16 April 2001 // // Procedure Name: // art3dPaintCheckDefautBrush // // Description: // Makes sure that the nodes that store the default paint effects brushes // for paint, blur, and smear have been created. // // Input Arguments: // $mode - mode to make sure default brush exists for ("Paint", "Smear", // or "Blur") // // Return Value: // None. // global proc art3dPaintCheckDefaultBrush( string $mode ) { string $defaultBrushName; string $defaultBrushScript; // Nodes which store the saved brush settings // global string $gArt3dPaintLastPaintBrush = "art3dPaintLastPaintBrush"; global string $gArt3dPaintLastBlurBrush = "art3dPaintLastBlurBrush"; global string $gArt3dPaintLastSmearBrush = "art3dPaintLastSmearBrush"; // These are the names of the brushes that we will use as defaults // string $defaultPaintBrush = "Airbrush/defaultPaint"; string $defaultSmearBrush = "Airbrush/defaultSmear"; string $defaultBlurBrush = "Airbrush/defaultBlur"; // Names that the default brush had when the saved settings were in place // (e.g. fire1) // global string $gArt3dPaintLastPaintBrushName; global string $gArt3dPaintLastBlurBrushName; global string $gArt3dPaintLastSmearBrushName; // Check if the default brushes exist // int $defaultPaintExists, $defaultSmearExists, $defaultBlurExists; switch ( $mode ) { case "Paint": $defaultBrushName = $gArt3dPaintLastPaintBrush; $defaultBrushScript = $defaultPaintBrush; $gArt3dPaintLastPaintBrushName = basename( $defaultBrushScript, "" ); break; case "Smear": $defaultBrushName = $gArt3dPaintLastSmearBrush; $defaultBrushScript = $defaultSmearBrush; $gArt3dPaintLastSmearBrushName = basename( $defaultBrushScript, "" ); break; case "Blur": $defaultBrushName = $gArt3dPaintLastBlurBrush; $defaultBrushScript = $defaultBlurBrush; $gArt3dPaintLastBlurBrushName = basename( $defaultBrushScript, "" ); break; default: string $fmt = (uiRes("m_art3dPaintCheckDefaultBrush.kUnsupportedMode")); error `format -s "art3dPaintCheckDefaultBrush" $fmt`; } if ( `objExists $defaultBrushName` ) { // The brush node already exists; return; } // Figure out where the brushes live // string $brushDir = getenv( "MAYA_LOCATION" ) + "/Examples/Paint_Effects/"; // Make a copy of the existing selection // string $currSelection[] = `ls -sl`; // Make a copy of the current brush so that we can put it back // string $defaultName = getDefaultBrush(); string $copyReasults[] = `duplicate $defaultName`; string $defaultCopy = $copyReasults[0]; // Create the node where we will store the brush settings in the future // createNode "brush" -n $defaultBrushName; int $ok = false; string $brushBaseName = basename( $defaultBrushScript, "" ) + ".mel"; if ( `exists $brushBaseName` ) { // The paint brush is in our script path. Use that instead. This // will allow users to override the default brush by putting a // brush script in their own script directory // if ( !catch( eval( "source " + $brushBaseName ) ) ) { $ok = true; } } if ( !$ok ) { // Need to pick up the brush out of the brushes directory // if ( !catch( eval( "source \"" + $brushDir + $defaultBrushScript + ".mel\"" ) ) ) { $ok = true; } } if ( !$ok ) { string $fmt = (uiRes("m_art3dPaintCheckDefaultBrush.kFailedToLoadBrush")); error `format -s $defaultBrushScript $fmt`; } // Store the brush settings for the default brush we just loaded into our // save node // copyNode( getDefaultBrush(), $defaultBrushName ); // Put back the old default brush // brushPresetSetup(); copyNode( $defaultCopy, getDefaultBrush() ); rename( getDefaultBrush(), $defaultName ); delete $defaultCopy; // Set the paint effects brush mode. // string $currContext = `currentCtx`; art3dPaintCtx -e -brushtype "effectsBrush" $currContext; art3dPaintEffectsBrushCallback( "art3dPaintCtx" ); // Replece the old selection list so that we don't modify Maya's state // select -r $currSelection; }