Introduction to Maya - Modeling Fundamentals Vol 2
This course will look in the fundamentals of modeling in Maya with an emphasis on creating good topology. It's aimed at people that have some modeling experience in Maya but are having trouble with complex objects.
# 1 25-07-2004 , 02:23 AM
Registered User
Join Date: Jul 2003
Location: Australia
Posts: 50

basic MEL help please

Hi there.

I want to create the effect of sheet lightning, by randomising the intensity of a point light.

I can get this to happen, but i need it so that i can vary the time between flashes, like i need an avg random 30 frames between changes.

i came up with this, having not much programming or MEL experience,


//setup values
int $mycount;
$mycount = rand(20,30);
int $i;

//loop for 380 frames
for ($i=1; $i <380; $i++) {

//check random value against frame value
if (frame == $mycount) {

//change light intensity
pointLightShape1.intensity = rand(0,1);

//increase random value to progress
$mycount += $mycount;
}
}


and now I'm stuck. can anyone point out where i went wrong?
it only changes the intensity once. and then not even everytime i play it through.
or perhaps a less round about way of doing it?
thanks!!

Adam.

# 2 25-07-2004 , 05:24 PM
Emo's Avatar
Subscriber
Join Date: Jul 2002
Location: MELville
Posts: 1,100
wait.. let me first try to figure out what youre trying to do..... as the animation plays, you want random flashes every 30 frames?

-Emo

# 3 26-07-2004 , 02:05 AM
Registered User
Join Date: Jul 2003
Location: Australia
Posts: 50
a random vaule for the illumination yes.

and approximately every 30 frames. I wanted to randomise the time between flashes. so approx 30 frames, say a random interval between 10 and 40.

# 4 26-07-2004 , 08:52 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
this would be easier as an expression:

right click the intensity in the channel box and add this:

if(frame % 30 == 0)
{
pointLightShape1.intensity = rand(0,5);
}

What you are doing is using the modulus function (%) to check if the frame divides equally by thirty and then setting the intensity by expression.

Simple user added image

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 5 26-07-2004 , 11:18 AM
Registered User
Join Date: Jul 2003
Location: Australia
Posts: 50
thanks Alan!
i was at a bit of a loss how to do the time delay properly.
that would only make it exactly 30 frames though?
i want it to be more random than that.

like lightning
a couple of quick flashes, a pause, flash, pause, some more quick, or whatever.

# 6 26-07-2004 , 12:37 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
well if you want it that specific then you may have to key it. You can use a random number instead of the frame number:

int $frameChange = rand(10, 40);
if(frame % $frameChange == 0)
{
pointLightShape1.intensity = rand(0,5);
}

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 7 27-07-2004 , 12:21 AM
Registered User
Join Date: Jul 2003
Location: Australia
Posts: 50
no no, not specific, random is what i want.
that random function should work a treat,

thanks for that Alan.
I really appreciate the effort you make helping out me and other newbies.

this is what i ended up with, if anyone was interested in how it ended up working.


//setup values

int $mynumber;
int $i;

//loop for 380 frames

for ($i=1; $i <380; $i++) {

$mynumber = rand(50,80);

if (frame % $mynumber == 0) {
pointLightShape1.intensity = rand(0,1);

//increase random value to progress

$mynumber += $mynumber;
}
}


Last edited by Binabik; 27-07-2004 at 12:38 AM.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads