RGB Color Cube
The above RGB Color Cube was created with the following code:
string $name;
string $tmp;
for ($x=0; $x<8; $x++)
{
for ($y=0; $y<8; $y++)
{
for ($z=0; $z<8; $z++)
{
$name = `shadingNode -asShader blinn`;
$tmp = $name + ".color";//blinnShader1.color
setAttr $tmp -type double3 ($x/7.0) ($y/7.0) ($z/7.0);
polySphere -ch on -o on -r .03;
xform -translation ($x/7.0) ($y/7.0) ($z/7.0);
hypershade -assign $name;
}
}
}
RGB Color Wheel
$numHues = 6.0;
$w= 360.0/$numHues;//width
$s = 1.0/10.0;
$value = 1.0;
$n = 6;
for ($i=0; $i<$numHues; $i++)
{
for($j=0; $j<$n; $j++)
{
$sphere = `polySphere -ch on -o on -r .3`;
move 10deg 0 10deg $sphere;
xform -r -ro 10deg 0 10deg;
$sat = $j * $s; // translate by number
$angle = $i * $w; //rotate ball
$hue = $angle/360.0;
//vector $v = <<1, 2, 3>>;
//shadingNode -asShader blinn;
//sets -renderable true -noSurfaceShader true
// -empty -name blinnSG;
//connectAttr -f blinn.outColor blinnSG.surfaceShader;
//assignCreatedShader "blinn" "" blinn "pSphere";
//sets -e -forceElement blinnSG;
//vector $c = hsv_to_rgb($v);
//xform -translation ($c.x) ($c.y) ($c.z);
//hypershade -assign $name;
}
};
I have worked and reworked this code so many times and I don't understand it.
Artistic Color Wheel
$w= 360.0/6;//width
$s = 1.0/2.0;
$value = 1.0;
//string $sphere [];
//$sphere = `polySphere -ch on -o on -r .5`;
$a1= 0.0;
$a2 = 60.0;
$h1 = 0.0;
$h2 = 60.0;
//$angle = $w / 6;
$n= 10;
$dhue = $h2 - $h1;
$sh = $dhue/$n;
$dangle = $a2 - $a1;
$sa = $dangle /$n;
$hues[];
$hues[0] = 0;
$hues[1] = .16;
$hues[2] = .32 ;
$hues[3] = .48;
$hues[4] = .64;
$hues[5] = .8;
$hues[6] = 1;
// $hues []= { 0,.16, .32, .48, .64, .8, 1}
for ($k=0; $k<6; ++$k)
{
$dhue = $hues[$k + 1] - $hues[$k];
$dangle = $hues [$k + 1] - $hues [$k];
for ($i=0; $i,6; ++$i)
{
for($j=0; $j<6; ++$j)
{
$ca = $a1 +$i * $sa;
$ch = $h1 +$i * $sh;
string $sphere [];
$sphere = `polySphere -ch on -o on -r .5`;
move $sphere 10deg 0 10deg;
xform -r -ro 10deg 0 10deg;
$sat = $j * $s; // translate by number
$angle = $i * $w; //rotate ball
$hue = $angle/360.0;
vector $v = <<1, 1, 1>>;
shadingNode -asShader blinn;
sets -renderable true -noSurfaceShader true
-empty -name blinnSG;
connectAttr -f blinn.outColor blinnSG.surfaceShader;
assignCreatedShader "blinn" "" blinn "pSphere6";
sets -e -forceElement blinnSG;
vector $c = hsv_to_rgb($v);
xform -translation ($c.x) ($c.y) ($c.z);
//hypershade -assign $name;
}
}
}
I understand the basic concepts from class such as the color wheel divided into 6 parts. But no matter what I can't get the code to work. My classmates, Casey and Rachel, gave me some advice about how to fix the problem, like including these lines in the saturation for loop:
string $sphere [];
$sphere = `polySphere -ch on -o on -r .5`;
and not using xform translation or adding angles.
I understand the basic concepts on paper, but coding them into Mel is confusing. Documentation is not always helpful. I will be getting a tutor immediately.
No comments:
Post a Comment