Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Dynamics & Special Effects (https://simplymaya.com/forum/forumdisplay.php?f=33)
-   -   Fireworks (https://simplymaya.com/forum/showthread.php?t=9005)

Dann 17-11-2003 11:16 PM

Fireworks
 
I'm messing with Maya's fireworks. I want to use a MEL script to control the colors as described in the docs, but cannot figure it out.

Remake Color Palette
Quote:

If you want to replace the entire sparks color palette with a custom palette, you can specify a custom MEL procedure name. Maya looks for the custom procedure by searching your user scripts directory for a MEL script with the same name.

Your procedure should include the following syntax:

global proc vector[] myFireworksColors( int $numColors )

In this syntax, the argument $numColors specifies the total number of colors requested. The return value should be an array of vectors with the new colors in it.
If you made individual color changes, you can return to the custom or default color palette by clicking Reset from colorProcedureName.
So I made a MEL script that says
global proc vector[] myFireworksColors( int $numColors );

I get an error though
// Error: global proc vector[] myFireworksColors( int $numColors );arksColor[1], $sparksColor[2]>>; //
// Error: Syntax error //

Any thoughts on what I should be doing?

kbrown 17-11-2003 11:52 PM

You have to do something like this:

Code:

global proc vector[] myFireworksColors( int $numColors )
{
        int $i;
        vector $vMyColorArray[];
        float $r, $g, $b;
       
        for($i = 0; $i < $numColors; $i++)
        {
                $r = rand(0, 1);
                $g = rand(0, 1);
                $b = rand(0, 1);
               
                $vMyColorArray[$i] = << $r, $g, $b >>;
        }
       
        return $vMyColorArray;
}

Hope I didn't make too many typos since I didn't tested it :)

Dann 18-11-2003 12:35 AM

Hey kBrown,

Thanks for the assist, but a wierd thing is happening. When I created a script with that text called myworks02.mel, I get an error message
// Error: Cannot find procedure "myworks02". //

If I remove that text and go back to the simple command I had before that did nothing, it finds the script but of course doesn't work. I'm guessing it's a bogus error message meaning something else is wrong.

As I try to dissect and understand your MEL, might there be an error in the "for" condition? Doesn't it set $i to 0 every time? should it for $i ==0?

Also, $i is defined as an integer, but with no value. Does that automatically make it's value 0?

Thanks again,
-dann

kbrown 18-11-2003 08:55 AM

Quote:

Originally posted by Dann
Hey kBrown,

Thanks for the assist, but a wierd thing is happening. When I created a script with that text called myworks02.mel, I get an error message
// Error: Cannot find procedure "myworks02". //

Lemme guess. You didn't source your script? Just say "source myworks02.mel" in the command line. Or restart Maya. Otherwise Maya doesn't know a thing about your script.

One way would have been to copy-paste the script in to the script editor and execute it. This way the global procedure would have persisted in the memory until you quit Maya...

Quote:

Originally posted by Dann
If I remove that text and go back to the simple command I had before that did nothing, it finds the script but of course doesn't work. I'm guessing it's a bogus error message meaning something else is wrong.

Not sure what you mean here...

Quote:

Originally posted by Dann
As I try to dissect and understand your MEL, might there be an error in the "for" condition? Doesn't it set $i to 0 every time? should it for $i ==0?

Also, $i is defined as an integer, but with no value. Does that automatically make it's value 0?

Thanks again,
-dann

No, the script is a working one. I tested it after posting it :)

The $i is defined as an integer and because I didn't assign it a value maya initializes it to 0.

The for loop is alright too. Please excuse my bad explanation but it's like:
Code:

// for( <iterator and initial value>, <test condition>, <what to do on every round )
  for(          $i = 0            , $i < $numColors ,  $i++                      )

Basically $i is first set to 0 and on every round it is incremented by 1 ($i++). The loop is repeated as long as the test condition is true ($i < $numColors).

ragecgi 18-11-2003 03:28 PM

Thanks K!!!

Dann 18-11-2003 06:11 PM

K,

First, let me say thank you for your help and patience with me. However I still cannot get this to work.

Quote:

Originally posted by kbrown
Just say "source myworks02.mel" in the command line. Or restart Maya. Otherwise Maya doesn't know a thing about your script.

One way would have been to copy-paste the script in to the script editor and execute it. This way the global procedure would have persisted in the memory until you quit Maya...
When I type "source myworks02.mel" in the command line, not much happens (I suppose it's just loading into memory so not much would happen.) But then when I try and and put "myworks02" or "myworks02.mel" in the Fireworks creation box, I still get the same error. "Cannot find procedure". I even tried putting "source myworks02.mel" in the Firworks creation, but that didn't work either.

Any thoughts on what else I could be doing wrong? I'm still in Maya 4. Could that be the problem? Attached is my mel file. Maybe I did something wrong there, but it's just your code pasted in I think.

Thanks again.
-dann

kbrown 18-11-2003 06:43 PM

You're right about the sourcing. It just loads the script in to memory (and checks it for errors).

In the fireworks thing you need to point it to your procedure, not the mel file (the file could contain a number of other procedures). So in this case you should enter "myFireworksColors".

Dann 18-11-2003 06:51 PM

ohhhhhhhhhhhh...

You're my new hero. Thanks K!!!

kbrown 18-11-2003 07:22 PM

No problem :)

Learned myself something too in the process :)

ragecgi 18-11-2003 08:03 PM

I love it when you're messin with mel, and in my situation, dynamics in general, and youve been bangin your head against a wall for hours/days/weeks, when all of a sudden, CLICK!

...the lightbulb turns on, and a flood of excitement rushes over you as you are either:

-glad the hard-part of the project is over

or

-jumping to that next level of knowledge about our wonderfull industry:)

Happy, happy, joy, joy:)

kbrown 18-11-2003 08:09 PM

I totally agree with you Rage :)

After the CLICK you feel the adrenaline flowing and you could almost rule the world. You think to yourself "damn, i'm good!" :D

The next second you start looking around if someone noticed the wide grin on you face and you realize that they propably think you're nuts :D

ragecgi 19-11-2003 04:35 AM

LOL! no kidding:)

When that stuff happens to me, I jump up and shout:

"I am the smartest man alive!"

.. it's usualy then that my gf laughs at me, and tells me that I still suck... hehe..


All times are GMT. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018