Pages

Sunday, November 11, 2012

Tip MEL to set Toon Outline Parameters


Hi,
Here is MEL script I wrote to set some automatic toon outline values to render a mesh with wireframe in Maya.   It still needs some work, and I'm guessing a Python implementation may be more usable (optional crease line width parameters etc).   I show an application of this script on a character I designed and modeled.









The script needs the geometry name, geometry shape name, and the toon outline shape name.


na_makeToonOutline("polySurface37", "polySurfaceShape44", "pfxToonShape1");


Cheers
Nate

/**Given geometry its shape and toon shape set some defaults so can preview character with outlines
*@pre toon created already for your character. ( RENDERING > Toon > assign outline )
*@note change creaseLineWidth and creaseColor according to character
*@note no error checking on types etcs transform, mesh, pfxToon, object existence
*/
global proc
na_makeToonOutline(string $geoName, string $geoShapeName, string $toonShapeName)
{
    
    //MEL making toon outline
    
    if( `objectType $geoName` != "transform"){ error("Require Geometry param 1");}
    if( `objectType $geoShapeName` != "mesh" && `objectType $geoShapeName` != "nurbsSurface" ){ error("Require Shape param 2");}
    if( `objectType $toonShapeName` != "pfxToon"){ error("Require pfxToon Shape param 3 --RENDERING > Toon > assign outline");}
    
    
    //PUT LINE WIDTH HERE
    //
    float $lineWidth = 0.30; 
    
    //PUT LINE COLOR HERE
    //
    float $creaseRGB[] = {0.0,0.618,0.618}; 

    //PUT GEO HERE
    //
    string $geo = $geoName;
    string $geoShape = $geoShapeName;
    
    //PUT TOON SHAPE HERE
    //
    string $toonShape = $toonShapeName;
    
    setAttr ($toonShape+".profileLines") 0;
    setAttr ($toonShape+".borderLines") 0;
    setAttr ($toonShape+".hardCreasesOnly") 0;
    setAttr ($toonShape+".creaseAngleMin") 0;
    setAttr ($toonShape+".creaseAngleMax") 0;
    setAttr ($toonShape+".creaseLineWidth") $lineWidth;
    setAttr ($toonShape+".creaseColor") -type double3 $creaseRGB[0] $creaseRGB[1] $creaseRGB[2] ;
    
}


Inspired by Savio Fernandes (artbycrunk dot com),  Where I first learned about using toon outline to render a mesh in wireframe.