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;
}
}
};

Journal Post 3

A couple bits of code I found useful when working on the color cube. I ended up using them a lot, so I decided to write it down here for further reference.

select -all;
delete;
//to select then delete everything

file -import -type "mel" -ra true -namespace "color_cube" -pr -loadReferenceDepth "all" "/Users/Colin/color_cube.mel";

//to import the mel script

Journal Post 2

In class we came up with the code below for the color cube. A sphere is created for every x, y, and z in the three for-loops, producing an 8x8x8 cube made up of spheres.

for ($z = 0; $z < 8; ++$z)
{
for ($y = 0; $y < 8; ++$y)
{
for ($x = 0; $x < 8; ++$x)
{
polySphere -ch on -o on -r .05;
xform -translation ($x/8.0) ($y/8.0) ($z/8.0);
}
}
};

Journal Post 1



I watched a set tutorials on YouTube about MEL scripting. It starts off very simple with creating cubes and talking about different variable types (int, float, string) and eventually gets into loops and shows you how to disperse a bunch of cubes randomly in a 3D area.