Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 25-07-2004, 03:23 AM   #1
Binabik
Registered User
 
Join Date: Jul 2003
Location: Australia
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Binabik is offline   Reply With Quote
Old 25-07-2004, 06:24 PM   #2
Emo
Subscriber
 
Emo's Avatar
 
Join Date: Jul 2002
Location: MELville
Posts: 1,100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Emo is offline   Reply With Quote
Old 26-07-2004, 03:05 AM   #3
Binabik
Registered User
 
Join Date: Jul 2003
Location: Australia
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Binabik is offline   Reply With Quote
Old 26-07-2004, 09:52 AM   #4
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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

Alan
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 26-07-2004, 12:18 PM   #5
Binabik
Registered User
 
Join Date: Jul 2003
Location: Australia
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Binabik is offline   Reply With Quote
Old 26-07-2004, 01:37 PM   #6
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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
Alan is offline   Reply With Quote
Old 27-07-2004, 01:21 AM   #7
Binabik
Registered User
 
Join Date: Jul 2003
Location: Australia
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 01:38 AM.
Binabik is offline   Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
MEL headache! happymat27 Members Lounge 5 05-12-2010 09:43 AM
MEL headache!! happymat27 Mel Scripts & Programming 1 03-12-2010 04:41 PM

Thread Tools





A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.