I have a scene with a rope bridge that has 60+ wooden planks...I'd like to use the same texture on each plank but obviously when rendered the planks will look exactly the same... so what I thought I'd do is change the translateFrameV value for each plank...of course this would mean a new shader for each plank...which I don't mind as far as scene size goes but it will be very time consuming to create each shader and change the translateFrameV values. ...so... over the last day or so I have been looking into doing something with mel that will: 1) duplicate one plank with it's SG as many time as I would like 2) change the translateFrameV value for each one using rand()
I am NOT a programmer. However I have found a few things that I thought would be useful, like setAttr place2dTexture1.translateV 0.5 which could be used inside a loop...but I can't find a few things: 1) how to select the place2dTexture node of either the currently selected object's SG or of all the SG in a scene 2) how to create a variable (an array I think) of these place2dTexture nodes and use them in a setAttr.. > setAttr place2dTexture"$nodeFromArray".translateV "$amountRandom"
I think this would be a useful script, it could be changed to modify any attribute, or a whole bunch...but I'm really not experienced with mel enough to really tackle this. any hints or advice would be great.
Here's a script that plows through what you asked for.. it should be easy enough for you to modify it to taste
//------------------begin string $oldshader; string $oldobject; //the following two strings are assigned manually which is the object that you want duplicated and the shader assigned to it $oldshader="plankSG"; $oldobject="plank1";
string $newshader[]; string $newobject[]; float $XX; int $CNT; int $MAX; $MAX=60; $CNT=0; while($CNT<=$MAX) {
$XX =rand 1;
//you will have to edit the name of the place texture node to be the same as the one used in the oldshader
now all I have to do is figure out how to move all those little guys away from each other...I think I'll investigate "smart Transform" and see if I can't add a little something to that script
well "smart transform" helped a bit but I couldn't get it to work.. so I tried just adding a few things:
//------------------begin string $oldshader; string $oldobject; //the following two strings are assigned manually which is the object that you want
duplicated and the shader assigned to it $oldshader="plankSG"; $oldobject="plank1";
string $newshader[]; string $newobject[]; float $XX; float $YY; int $CNT; int $MAX; //Change $gap to the amount of space you want in between each new object int $gap; $gap=0; //$thick is 1/2 the width (or radius) of the object in the direction of translation int $thick; $thick=2; //$moveZ is amount you want the object moved in Z int $moveZ; $moveZ=$thick + $gap; $MAX=5; $CNT=0; while($CNT<=$MAX) {
$XX =rand 1; $YY =rand 1;
//you will have to edit the name of the place texture node to be the same as the one used
// assigns new shader to new object sets -e -forceElement $newshader[0] $newobject[0]; $moveZ=$moveZ+$thick; $CNT=$CNT+1; } //-------------------end;
This works really well for all kinds of objects...except a nurbs cube...???....I get 1 new cube called plank2 then an error thay says "more than one object matches name: plank2" hmmm...have to work on it somemore...
I figure this can be changed for all sorts of uses...crazy old Maya eh?...need something done? just write a script!!....got to learm programming... :] thanks again.