PDA

View Full Version : MEL Scripting


Boo Boo Juice
06-14-2005, 02:12 AM
I don't know if anyone here is savvy in MEL scripting. It is a scripting language in MAYA, and i am having trouble with this assignment for class. What it is supposed to do is create a big box in the center, and several other boxes surrounding it in a certain way. The problem is, I keep getting this error:
// Error: cubeClone(<<0,0,0>>, 1.0, 0.25, $level);
//
// Error: Wrong number of arguments on call to cubeClone. //

Here is my code for the project:
global vector $dir[6] = { << 1, 0, 0 >>, << -1, 0, 0 >>,
<< 0, 1, 0 >>, << 0, -1, 0 >>,
<< 0, 0, 1 >>, << 0, 0, -1 >> };

proc cubeClone(vector $center, float $height, float $width, float $depth, float $fraction, int $level)
{
polyCube -height $height -width $width -depth $depth;
move -absolute ($center.x) ($center.y) ($center.z);

if ( 0 == $level )
return;


global vector $dir[6];
for ( $i = 0; $i < 6; $i ++ )
{

float $childHeight = $height * $fraction * rand(0.5, 1.0);
float $childWidth = $childHeight;
float $childDepth = $childHeight;

vector $childCenter = $center + ($height + $width + $depth + $childHeight + $childWidth + $childDepth) * $dir[$i];
cubeClone( $childCenter, $fraction, $level-1);

}
}

proc myButtonAction( string $intSliderGrp)
{
$level = `intSliderGrp -q -value $intSliderGrp`;
cubeClone(<<0,0,0>>, 1.0, 0.25, $level);
}


string $myWindow = `window
-title "Fractal Boxes"
-widthHeight 400 200
-menuBar on
-titleBar on`;
menu
-label "About";
menuItem
-label "About this demo"
-command "window -title \"About FractalBalls\"; showWindow; ";

columnLayout
-rowSpacing 10;

rowLayout;
string $myIntSliderGrp = `intSliderGrp -min 0
-max 3
-label "Level for FractalBalls:"
-field true`;

setParent ..;

rowLayout
-numberOfColumns 3
-columnWidth3 133 133 133;

button
-label "New Scene"
-command "file -f -new;";
button
-label "Create Boxes"
-command "myButtonAction($myIntSliderGrp)";
button
-label "Undo"
-command "undo";
showWindow $myWindow;

I think I kind of understand what the error is saying, but I don't totally understand.

Delphi Dude
06-14-2005, 04:56 AM
proc cubeClone(vector $center, float $height, float $width, float $depth, float $fraction, int $level) <- this procedure has 6 parameters ($center, $height, $width, $depth, $fraction and $level)

Assuming <<0,0,0>> is a vector rather than 3 distinct parameters, you're obviously missing 2 parameters when making the following call:

cubeClone(<<0,0,0>>, 1.0, 0.25, $level)

The solution should be to supply the missing parameters, and I assume it's the $height and $width that are missing.

Boo Boo Juice
06-14-2005, 05:29 AM
Thats what I figured as well, but I can't figure out what to put in there. I've put various random numbers but nothing turns out the way it is supposed to.