Hey guys,
I wrote this script in MEL to assign a planar projection to each selected face (or to convert a selected object to it's faces and then assign the projections to them), as well as a material. The script also adjusts the ImageCenterX, ImageCenterY, ImageScaleU, ImageScaleV, and RotationAngle of the planar projection. The texutre used in the material is a texture atlas filled with 31 textures that all tile together. The idea is to assign a random tile to each face of an object.
Okay, this all works great except for one thing. Every now and again, the tile image ends up upside down or sideways compared to the faces adjacent, and therefore no longer tiles properly (probably becuase of the vertex order or whatever). No problem, I thought, I can just write a script to flip a selected face 90 degrees with the push of a button until it is the right direction.
This turned out to be much much harder than the original script! The problem I'm having is I can't get from "selected face" to "PolyPlanarProj" in order to read out the current RotationAngle value, which I need before I can add 90 degrees to it. This is the script I've been playing with:
string $select[] = `ls -sl`;
//grab a list of the selected faces
string $faceList[] = `filterExpand -sm 34`;
for($i=0; $i<size($faceList); $i++)
{
select $faceList[$i];
$angle = `polyPlanarProjection -query -ra`;
print ($angle);
$angle += 90;
$angle %= 360;
print ($angle);
polyPlanarProjection -edit -ra $angle;
//flip the scales (not done yet)
// setAttr ($result[0] + ".imageScaleU") 0.125; //TODO
// setAttr ($result[0] + ".imageScaleV") 0.250; //TODO
}
//restore the original selection
select -r $select;
Of course that is not working, because (I guess?) polyPlanarProjection isn't associated with a face, it's associated with the parent object. So the query is just (silently) failing.
Anyone have any advice? I'm not super fluent in MEL, so there's probaby an obvious solution I'm missing