View Full Version : Slight random rotation

02 February 2008, 12:10 PM
I've never really had a chance to use MEL, so please forgive me if this is a bit simple, but i can't figure it out (in the short amount of time I have).

I want to randomise, just slightly, the rotation of a few hundred simple 4-sided poly planes which represent glass panels so they'll pick up reflections in a more natural way.
Is there a simple way to do this?
They're currently separate objects, but once their rotation has been altered I'll be combining them.
Each pane is around 4 units high, and I only need to rotate them through X and Y, probably by no more than 0.5 - I don't need to rotate them through Z.
Here's an image, with units shown, in case it helps:

Should this be as simple as I think it should be?

Any help appreciated.


02 February 2008, 02:07 PM

try this.

Select all you Objects and run this:

string $obj[] = `ls -sl`;
float $RandomValue = .5;
for ($i=0; $i < size($obj);$i++)
setAttr ($obj[$i] + ".rotateX") `rand $RandomValue`;
setAttr ($obj[$i] + ".rotateY") `rand $RandomValue`;
// setAttr ($obj[$i] + ".rotateZ") `rand $RandomValue`;

you can play with the RandomValue to increase the randomness
Take care of your pivot...

02 February 2008, 05:36 PM

Thank you so much.

02 February 2008, 09:10 PM
I was also thinking about this and I was curious if you were doing any animation with this structure. Because I was thinking that you might also be able to make a locator or something to select that you could create an attr channel, on so that you could control the open and closing of these windows in groups, or all at once.

polyObject.rx = *(rand($randvalue)

With that I will play around with it some. But the whole purpose of that is for you to be able to control the degree in which the windows are opening, which would be affected by the time of day. As well as weather conditions.

CGTalk Moderation
02 February 2008, 09:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.