dynExpression variable problem

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  04 April 2009
dynExpression variable problem


I'm working on a scene where I've used the Hermite function to create some lightning effects....

I'm building a UI to control the wavelength, frequency, speed, and radius of the particles and am having trouble while passing variables from my procedures in the script editor to the PP values in the expressions on the particles. The code for the UI is pretty straightforward with floatSliderGrp's for the inputs, so I'll just post an example of the procedures here:

global proc getSpeed(){

global float $inSpeed=0;
$inSpeed = `floatSliderGrp -q -value "speedSldr"`;
setSpeed $inSpeed;

}//end getSpeed

global proc setSpeed(float $inSpeed){

dynExpression -s "lightningHermitePShape.lifespanPP = $inSpeed;" -c

}//end setSpeed

This code puts the string "$inSpeed", not the value contained in $inSpeed, into the value for lifeSpanPP which is what I am trying to fill with the input from the UI slider. I made the variable $inSpeed global because I was getting "variable $inSpeed is undeclared" errors when it was not global since it was not declared in the expression.

(As a side note)
As of now I'm using a button to insert the values (or incorrect strings in my case so far) into the expressions, but would like them to be inserted dynamically as the simulation is running. So I could scrub through the sliders to see the changes in real time. I'm not sure of how to do this though.

Any help and ideas would be greatly appreciated. I thank you in advance for any help you can offer.

Take Care,

Dave Jaramillo
  04 April 2009
if you want to edit the expression with the value of your variable you have to add it to the string first. ("lightningHermitePShape.lifespanPP = "+$inSpeed+";") otherwise the variable will just turn up as part of the string for the expression, where it may not exist or have the correct updated value. is this what you mean??

to update a value and be able to scrub through the simulation I dont know man...I think it might be difficult as far as I know. maybe you can elaborate on what youre trying to do? lifespanPP based on speed...I dont get it? changing attributes during interactive playback should be doable, have expressions depend on some value... but in that case you should just have the expression look up that other attribute or value, instead of editing the expression every time theres a change. I think. any reason for not doing that?
good luck!

__________________________________________________ _______________
"inbreeding was common in sweden until the bicycle came." - my dad

Last edited by frilansspion : 04 April 2009 at 07:37 AM. Reason: added thoughts
  04 April 2009

Hey Thanks for your help Matt . Yeah I ended up figuring out the problems but now of course I'm onto the new ones. I'll explain the lifespanPP thing. I used the hermite function which basically tells particles where to start, where to end, and how to act in between. So their lifespan, being from A -> B, makes them move faster if it is decreased since they will have X less time to travel from A -> B. (Then slower if increased....)

The dynamic update problem was just a flag that I hadn't found yet: -dragCommand
"Command string executed repeatedly during a drag of the slider."

So if I wanted to change my slider value for the floatSliderGrp in the UI, it would automatically update the values in the expression editor so I can see the changes in real time as the sim plays. The same way you could see changes in turbulence magnitude or something like that.

Thanks Again! Good Luck!

  04 April 2009
oh, so it all worked out?? thats good.

or what is the problem now you mean? you can drag the slider now but the results is not what you want?
__________________________________________________ _______________
"inbreeding was common in sweden until the bicycle came." - my dad
  04 April 2009
No that part worked fine, I had some other things in the UI I had to figure out but I got em.


  04 April 2009
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 06:30 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.