マテリアルの色のような、 3 つの数値によって構成されるアトリビュートをオブジェクトごとに切替えるには tripleSwitch を使用します。
2 つの NURBS の球を作成して lambert マテリアルをアサインし、 そのマテリアルに対し、オブジェクトごとに違うテクスチャーをアサインするスクリプトです。
global proc tripleSwitch1()
{
string $spname1[] = `sphere`;
string $spname2[] = `sphere`;
move 2 0 0;
string $sname = `shadingNode -asShader lambert`;
string $sgname = `sets -renderable true -noSurfaceShader true -empty`;
connectAttr -f ($sname + ".outColor") ($sgname + ".surfaceShader");
select -r $spname1[0] $spname2[0];
sets -e -forceElement $sgname;
string $tsname = `shadingNode -asUtility tripleShadingSwitch`;
connectAttr -f ($tsname + ".output") ($sname + ".color");
string $sphname[] = `listRelatives -s $spname1[0]`;
connectAttr ($sphname[0] + ".instObjGroups[0]") ($tsname + ".input[0].inShape");
$sphname = `listRelatives -s $spname2[0]`;
connectAttr ($sphname[0] + ".instObjGroups[0]") ($tsname + ".input[1].inShape");
string $txname1 = `shadingNode -asTexture fractal`;
string $plname1 = `shadingNode -asUtility place2dTexture`;
connectAttr ($plname1 + ".outUV") ($txname1 + ".uv");
connectAttr ($plname1 + ".outUvFilterSize") ($txname1 + ".uvFilterSize");
connectAttr -f ($txname1 + ".outColor") ($tsname + ".input[0].inTriple");
string $txname2 = `shadingNode -asTexture noise`;
string $plname2 = `shadingNode -asUtility place2dTexture`;
connectAttr ($plname2 + ".outUV") ($txname2 + ".uv");
connectAttr ($plname2 + ".outUvFilterSize") ($txname2 + ".uvFilterSize");
connectAttr -f ($txname2 + ".outColor") ($tsname + ".input[1].inTriple");
}
global proc tripleSwitch1()
string $spname1[] = `sphere`;
string $spname2[] = `sphere`;
move 2 0 0;
string $sname = `shadingNode -asShader lambert`;
string $sgname = `sets -renderable true -noSurfaceShader true -empty`;
connectAttr -f ($sname + ".outColor") ($sgname + ".surfaceShader");
select -r $spname1[0] $spname2[0];
sets -e -forceElement $sgname;
string $tsname = `shadingNode -asUtility tripleShadingSwitch`;
connectAttr -f ($tsname + ".output") ($sname + ".color");
string $sphname[] = `listRelatives -s $spname1[0]`;
connectAttr ($sphname[0] + ".instObjGroups[0]") ($tsname + ".input[0].inShape");
$sphname = `listRelatives -s $spname2[0]`;
connectAttr ($sphname[0] + ".instObjGroups[0]") ($tsname + ".input[1].inShape");
string $txname1 = `shadingNode -asTexture fractal`;
string $plname1 = `shadingNode -asUtility place2dTexture`;
connectAttr ($plname1 + ".outUV") ($txname1 + ".uv");
connectAttr ($plname1 + ".outUvFilterSize") ($txname1 + ".uvFilterSize");
connectAttr -f ($txname1 + ".outColor") ($tsname + ".input[0].inTriple");
string $txname2 = `shadingNode -asTexture noise`;
string $plname2 = `shadingNode -asUtility place2dTexture`;
connectAttr ($plname2 + ".outUV") ($txname2 + ".uv");
connectAttr ($plname2 + ".outUvFilterSize") ($txname2 + ".uvFilterSize");
connectAttr -f ($txname2 + ".outColor") ($tsname + ".input[1].inTriple");
string $spname1[] = `sphere`;
string $spname2[] = `sphere`;
move 2 0 0;
string $slname[] = `ls -sl`;
select $slname;
for($obj in $slname)
{
}
$sphname = `listRelatives -s $spname2[0]`;
connectAttr ($sphname[0] + ".instObjGroups[0]") ($tsname + ".input[1].inShape");
int $i = 0;
for($obj in $slname)
{
.
.
connectAttr ($sphname[0] + ".instObjGroups[0]") ($tsname + ".input["+$i+"].inShape");
.
.
$i++;
}
if(奇数か偶数か調べる)
{
string $txname1 = `shadingNode -asTexture fractal`;
string $plname1 = `shadingNode -asUtility place2dTexture`;
connectAttr ($plname1 + ".outUV") ($txname1 + ".uv");
connectAttr ($plname1 + ".outUvFilterSize") ($txname1 + ".uvFilterSize");
connectAttr -f ($txname1 + ".outColor") ($tsname + ".input["+$i+"].inTriple");
}
else
{
string $txname2 = `shadingNode -asTexture noise`;
string $plname2 = `shadingNode -asUtility place2dTexture`;
connectAttr ($plname2 + ".outUV") ($txname2 + ".uv");
connectAttr ($plname2 + ".outUvFilterSize") ($txname2 + ".uvFilterSize");
connectAttr -f ($txname2 + ".outColor") ($tsname + ".input["+$i+"].inTriple");
}