Pages

Wednesday, May 27, 2009

Rotation dependent on color

I found an interesting question in ScriptSpot forum and i spend a little time to help him out. More details and my explanation you can find in the forum topic. So instead of rewrite my post i'll just mark about.

The question is how to rotate array of objects by Y axis according to theirs wirecolor, where they have random grayscale color and rotation must be in interval between 0 and 90 degrees. And there is my script for:

for i in selection do
( -- assign random grayscale color
    i.wirecolor.r = random 0 255
    i.wirecolor.g = i.wirecolor.b = i.wirecolor.r
    -- test result to Listener (optional)
    print i.wirecolor
    -- handle variables to achieve rotation b/n 0 and 90 deg.
    perc = (i.wirecolor.r as float) / 255
    ang = 90 * perc
    -- finaly rotate them
    doRotate = rotate i ang y_axis
) -- thats all :)

    -- and test scene result here:

No comments:

Post a Comment

Thanks for your comment