Wednesday, February 16, 2011

Maya Difficulties and Insights 2/15/2011-Week 5

It is interesting and amazing how tiny mistakes made in Maya make a huge difference when running trying to run a program correctly. The following code is what I used to create the 3D dimensional color cube:

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

However, an error occured regarding the variable $name. After some help from Casey and Rachel, I realized that the variables $name and $tmp were not initialized. I then placed these two lines of code above the 3 for loops:

string $name;
string $tmp;

The color cube was created almost immediately. But one interesting point I discovered while working on this was that Mel programming is not case-sensitive like the Java programming language. The type string should not be capitilized. Also getting into the habit of checking carefully for tiny mistakes like missing tick marks and correct sign usage such as <, >, or =, would be tremendously helpful to my workflow.


In addition, trying to load the script file manually to recreate the color cube inside Maya came along with a few challenges. Trying to use the command action -o  in Mel does not work for opening the file. The script editor started to load the file but never finished because it couldn't read the file. The command that works was -import.  Scripts have to be saved to the Documents/Maya/Projects/Default/Scripts folder in order to be read into the Script Editor. I had to restart Maya and the Script Editor and enter the following code:

file -import "ColorCube.mel"

and put the file name in double quotations. The mel scripts will always have the extension of .mel. After these issues, the program worked fine.

Goal #1 : Try changing the colors of the color cube in Mel to represent deeper colors like those that were displayed on classmates PC computers.

Goal # 2: Figure out why the color ball that it supposed to represent full black color is displaying gray and how to make it black.

No comments:

Post a Comment