Thursday, May 1, 2008

what the MEL is going on?

Tacky title I know.

But I decided to post up my first real MEL script.

I don't have an offcial title for it as of yet, but for now lets just call it "Feng's Round em Up"

basically its takes all shaders the user selects evaluates what bump map if any is plugged in creates an mia round corners node, attaches the bump to the node, which in turn is plugged into the shader's bump channel.

"What? Is that some fancy Altaic language you speakin?"

no.. lemme just show you some pictures..

it takes things that look like this!


into this!



So those interested in the script it's free to use and modify.

SCRIPT!

///author David Feng
///name of script Round Em UP!
///
///

string $daWindow = `window -title "Feng's Round Em Up!"
-widthHeight 470 190`;

columnLayout;
text "Welcome to Feng's mia_roundcorner application script\n";
text "*Ensure that Mental Ray plugin is loaded shader only works with Mental Ray.";
text "Please select the shaders you with to apply roundness to and then use the button below";
text "\n";
button -label "round em up!" -command "roundEmUp";
text "\n";
button -label "close" -command ("deleteUI -window " + $daWindow);


showWindow $daWindow;

global proc roundEmUp()
{
string $selectedShader[] =`ls -selection`;
string $selected;
//print $selectedShader;

for ($selected in $selectedShader) {
//create roundcorners and rename it as subchild of shader//
mrCreateCustomNode -asTexture "" mia_roundcorners;
select -r mia_roundcorners1 ;
string $newName= $selected + "_mia_roundcorners";
rename mia_roundcorners1 $newName;
//get name of attribiute bump and connect to roundcorners
string $zeebump = `connectionInfo -sourceFromDestination ($selected + ".normalCamera")`;
connectAttr -force $zeebump ($newName+".bump_vector");
//connect roundcorners into shader bump node//
setAttr ($newName+".bump_mode") 5;
setAttr ($newName+".radius") 1;
connectAttr -force ($newName+".outValue") ($selected + ".normalCamera");
print ($selected + " has been rounded! TADOW!\n");
};
}

No comments: