PDA

View Full Version : Slight random rotation


CurtJ
02-14-2008, 11:10 AM
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:

http://www.curtjackson.co.uk/img/CG/panes_1.jpg

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

Any help appreciated.

Thanks

GiantG
02-14-2008, 01:07 PM
Hi.

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...

CurtJ
02-14-2008, 04:36 PM
Perfekt!

Thank you so much.

Hitchcock
02-17-2008, 08: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 = locator.windows *(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-17-2008, 08: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.