Thursday, February 17, 2011

Journal Post 4

My code for the color cube, with color this time. There's only about four more lines of code then before. The "ball" and "color" variables are assigned in the for-loops. A color is assigned to each sphere with RGB values corresponding to its x, y, and z position.

for ($z = 0; $z < 8; ++$z)
{
for ($y = 0; $y < 8; ++$y)
{
for ($x = 0; $x < 8; ++$x)
{
$ball = `shadingNode -asShader lambert`;
$color = $ball + ".color";
setAttr $color -type double3 ($x/8.0) ($y/8.0) ($z/8.0);
$objname = `polySphere -ch on -o on -r .05`;

xform -translation ($x/8.0) ($y/8.0) ($z/8.0);

hyperShade -assign $ball;
}
}
};

No comments:

Post a Comment