ApplyNewMaterialWithFile

From scripting
Jump to: navigation, search
global proc ApplyNewMaterialWithFile(string $ObjName, string $NewLambertName, string $FileLoc, int $iii, float $R, float $G, float $B) {
string $nicklambert = $NewLambertName+$iii;
string $nickObjShape[] =` listRelatives pPlane1`;
string $nicklambertSG = $NewLambertName+$iii+"SG";
string $nicklambertoutcolor = $NewLambertName+$iii+".outColor";
string $nicklambertSGsS = $NewLambertName+$iii+"SG.surfaceShader";
string $nicklamberttrans = $NewLambertName+$iii+".transparency";
string $nicklambertIncan = $NewLambertName+$iii+".incandescence";
string $nicklambertColor = $NewLambertName+$iii+".color";
string $nickfile = $NewLambertName+"File"+$iii;
string $nickPlace2d = $NewLambertName+"Place2d"+$iii;

shadingNode -asTexture file -n $nickfile;
shadingNode -asUtility place2dTexture -n $nickPlace2d;
string $PF[] = {".coverage",".translateFrame",".rotateFrame",".mirrorU",".mirrorV",".stagger",".wrapU",".wrapV",".repeatUV",".offset",".rotateUV",".noiseUV",".vertexUvOne",".vertexUvTwo",".vertexUvThree",".vertexCameraOne"};
for ($PFcount=0;$PFcount<size($PF);$PFcount++) {
	connectAttr -f ($nickPlace2d+$PF[$PFcount]) ($nickfile+$PF[$PFcount]);
}
connectAttr ($nickPlace2d+".outUV") ($nickfile+".uv");
connectAttr ($nickPlace2d+".outUvFilterSize") ($nickfile+".uvFilterSize");
AEassignTextureCB  ($nickfile+".fileTextureName") "C:/Documents and Settings/BLAST/Desktop/Files/Trans.jpg" "image";
setAttr ($nickfile+".colorGain") -type double3 $R $G $B ;

shadingNode -asShader lambert -n $nicklambert;
//renderCreateBarCB -asShader "surfaceShader" lambert;
sets -renderable true -noSurfaceShader true -empty -name $nicklambertSG;
connectAttr -f $nicklambertoutcolor $nicklambertSGsS;
sets -e -forceElement $nicklambertSG $ObjName;
setAttr $nicklambertColor -type double3 $R $G $B;

defaultNavigation -force true -connectToExisting -source $nickfile -destination $nicklambertIncan;		
defaultNavigation -force true -connectToExisting -source $nickfile -destination $nicklamberttrans ;		
}


More information on materials and shaders, read pages 128-141 in YSYT.