PDA

View Full Version : dynExpression variable problem


DavidJaramillo
04-09-2009, 01:56 PM
Hello,

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
lightningHermitePShape;

}//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

frilansspion
04-15-2009, 07:27 AM
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!

/matt

DavidJaramillo
04-15-2009, 12:28 PM
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!

DaveJ

frilansspion
04-16-2009, 12:29 PM
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?

DavidJaramillo
04-20-2009, 12:09 PM
No that part worked fine, I had some other things in the UI I had to figure out but I got em.

Thanks,

DaveJ

CGTalk Moderation
04-20-2009, 12:09 PM
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.