Also, turns out that creating and assigning shaders in mel doesn't work like you want. I think this will work in all versions of Maya:
Code: Select all
global proc meshLight() {
// create poly plane
string $lightPoly[] = `polyPlane -n emitter -sx 1 -sy 1 -w 5 -h 5 -ch 0`;
// get the poly plane shape node and triangulate
string $polyShape[] = `listRelatives -shapes $lightPoly[0]`;
polyTriangulate -ch 0 $polyShape[0];
// create lambert material
float $eRGB[] = { 0.75, 0.75, 0.75 };
string $lightLambert = `shadingNode -asShader lambert -name emitterMaterial`;
setAttr ($lightLambert+".incandescence") -type double3 $eRGB[0] $eRGB[1] $eRGB[2];
//string $lightSG = `shadingNode -asShader shadingEngine -name emitterMaterialSG`;
sets -renderable true -noSurfaceShader true -empty -name ($lightLambert+"SG");
connectAttr -f ($lightLambert+".outColor") ($lightLambert+"SG"+".surfaceShader");
// assign shader group
//connectAttr -f ($polyShape[0]+".instObjGroups[0]") ($lightSG+".dagSetMembers[0]");
select -r $polyShape[0];
sets -e -forceElement emitterMaterialSG;
// create curve arrow
string $curveName = `curve -ws -d 1 -p 0 0 0 -p 0 4 0 -p 1 3 0 -p -1 3 0 -p 0 4 0 -p 0 3 1 -p 0 3 -1 -p 0 4 0`;
string $curveShape[] = `listRelatives -shapes $curveName`;
// make the arrow a child of the emitter
parent $curveName $lightPoly[0];
// make curve transform and shape nodes reference objects so they can't be selected
setAttr ($curveName+".overrideEnabled") 1;
setAttr ($curveName+".overrideDisplayType") 2;
setAttr ($curveShape[0]+".overrideEnabled") 1;
setAttr ($curveShape[0]+".overrideDisplayType") 2;
// select emitter
select -r $lightPoly[0];
}
meshLight();