Tuesday, March 1, 2011

Assignment 3 Part 2: Color Wheel


Color Wheel 1: Basic Single Ring Color Wheel
float $rotate =360/30.0;
//float $translate = 1.0;
string $name;
string $name2;
for ($x=0;$x<30.0;$x++)
{
    for ($y=0;$y<1;$y++)
//set 30 balls around
    {
        $name = `shadingNode -asShader blinn`;
        $name2 = $name + ".color";       
 $angle = $x * $rotate;
        $hue = $angle/360.0;       
//Assign Blinn shaders
        vector $color = hsv_to_rgb(<<$hue, 1, 1>>);
//Convert HSV to RGB       
        setAttr $name2 -type double3 ($color.x) ($color.y) ($color.z);
//Set shaders
        sphere -ch on -o on -po 0 -ax 0 1 0 -r 0.0538244 -nsp 4 ;
//Make Nurb Spheres       
        xform -translation 1 0 0;
        rotate -pivot .1 .1 .1 0 $angle 0;
//translating the balls to form circular shape
        hyperShade -assign $name;
//Assign shaders       
    }
}
;


Color Wheel 2: This time I tried to implement a color wheel with saturation values and greys

float $rotate = 360/30.0;
float $translate = 1.0/5.0;
string $name;
string $name2;
for ($x=0;$x<30.0;$x++)
{
    for ($y=0;$y<5;$y++)
//set 30 balls around added translate to keep balls closer together
    {
        $name = `shadingNode -asShader blinn`;
        $name2 = $name + ".color";       
 $angle = $x * $rotate;
        $saturate = $y * $translate;
        $hue = $angle/360.0;       
//Assign Blinn shaders
        vector $color = hsv_to_rgb(<<$hue, $saturate, 1>>);
//Convert HSV to RGB, set max of 1 (if RGB are all 1 it creates white)      
        setAttr $name2 -type double3 ($color.x) ($color.y) ($color.z);
//Set shaders
        sphere -ch on -o on -po 0 -ax 0 1 0 -r 0.0538244 -nsp 4 ;
//Make Nurb Spheres     
        xform -translation $saturate 0 0;
        rotate -pivot .1 .1 .1 0 $angle 0;
//translating the balls to form circular shape
        hyperShade -assign $name;
//Assign shaders       
    }
}
;

No comments:

Post a Comment