View Full Version : GoalPP and expressions
WhiteRabbitObj 10-24-2003, 02:37 AM Heyas, I'm trying to write an expression on GoalPP for a particleshape that lets me specify whether or not a particle chooses from an age ramp or just 0 depending on the time. Specifically in this case, I need the particles created in the first 100 frames to use a PP ramp so that at frame 100 they target an object, but then I want any particles after this to have no goal so that they just float like normal and the other particles float with their goal. Can anyone help with this? Here is where I'm at right now:
GoalPP is linked to a ramp with the V attribute mapped to GoalVPP. GoalVPP has the following creation expression
if(time<100){
goalVPP = age;
}
else {
goalVPP = 0;
}
-----------
this is obviously not right since goalVPP being linked to age is gonna shoot off the ramp I want to use immediately. But I'm kind of stuck at the moment, and while I think more I thought I'd see if anyone knows a way to do what I'm asking. If anyone is confused, lemme know and I'll try to explain better. Thanks much!
|
|
misterdi
10-24-2003, 03:42 AM
Hmmm, let me see.
Since you want all particles emitted before frame 100, reach their goal at frame 100, I think you need to calculate first their birth time. Do a linstep from this point to frame 100 for goalPP.
You don't need to worry about the age by then, it's a matter when the particle born and definitely it will have goalPP set as 1.0 at frame 100.
But you need to watch out for particle that was born near frame 100, they will jump very fast to their goal as the goalPP will change drastically from 0.0 to 1.0.
Best regards,
WhiteRabbitObj
10-24-2003, 04:29 AM
Thanks, but that's actually what I'm trying to avoid! I have a ramp setup currently for their goalPP so that when the goal becomes active at frame 100, they move over there at a fairly fluid rate. But I want only the particles born before frame 100 to have this action, and the rest to act as if there is no goal. I know this can be done with some more expressions, I just have to look at it more, some friends are bothering me right now :) Thanks for the suggestions though.
rhankins
10-24-2003, 06:29 AM
create a custom PP attribute...call it something like goalActive.
in the creation expression set,
if(time<100)
goalActive = 1;
else
goalActive = 0;
Then in the runtime expression,
if(goalActive)
goalV = age;
else
goalV = 0;
WhiteRabbitObj
10-24-2003, 06:52 AM
Yeah I tried something along those lines and the problem is that I need the particles who get a goal to retain that goal until they die. The goal active is a per object attribute and I don't believe there is a goal active PP. If there is, and I will check on that for sure tomorrow, then it would solve all my problems! :) Let me explain a little further what I'm trying to do.
I'm trying to have smoke come out of a source, wisp its way up a bit and then some of it floats off to form a letter. This is an effect similar to the hookah smoking caterpillar in Alice in Wonderland (I'm workin on this in response to another post on this board). I can get it to wisp its way up then form the letter, but then it just keeps going to that letter and that's no good! So I'm trying to figure this out and tomorrow I'll see what I can come up with. Thanks for the suggestion anyhoo.
misterdi
10-24-2003, 07:45 AM
Oh, OK I see what you are trying to achieve.
OK this is a different approach, set your particle lifetime into some constant value (let say put this to 10 sec), then instead of using age as in your script, use normalizedAge instead.
Since normalizedAge will be normalize from birth to death, do a linstep from 0 to 0.4 or any value appropriate.
if(birthTime<4.0) // birthTime is in second
{
goalVPP = linstep(0, 0.4, ageNormalized);
}
else {
goalVPP = 0;
}
But ageNormalized is only available when you have connect an array mapper to a ramp.
rhankins
10-24-2003, 03:57 PM
goalActive is a custom attribute. you create the attribute and then each particle that is born before time 100 gets a value of 1 and all particles born after get a value of 0. Then you tell the particles;
if you have goalActive =1 then move toward the goal object. otherwise keep doing what your doing.
WhiteRabbitObj
10-24-2003, 08:02 PM
Thanks a ton for the help guys. This came out really cool and I got it workin. I ended up using the script that misterdi posted because I wasn't having luck with the script rhankins posted. I understand now what you were talking about tho rhankins, and I like that too, especially because I should be able to use a random lifespan with that, but when I tried to create the runtime part it was giving me an error I couldn't solve right now. If you guys want to check out the results, I will be posting them shortly in the "how to make smoke form into text " thread. Many thanks, and if I experiment with this any more, which I would like to, I'll post the results.
rendermaniac
10-25-2003, 12:36 AM
I may be completely off track but is there some reason you can't do:
goalPPV = age % 100;
I am fairly new to expressions but this seems a simple way of doing it.
PS editted as I got it wrong the first time!
Simon
WhiteRabbitObj
10-25-2003, 12:43 AM
Well I can't use "goalVPP = age" of any sort because age climbs too quickly and goalVPP needs to return a 0 to 1 number. The linstep function suggested earlier worked because it returns a proportional number between 0 and 1.
rendermaniac
10-25-2003, 12:56 AM
Yeah sorry - bit braindead there. How about using linstep with:
goalVPP = linstep(0, 0.4, (age %100)/100);
rendermaniac
10-25-2003, 01:38 AM
Actually this would just cycle so not good if your particles live beyond 100 frames (I guess you them to hang around if it is smoke). Oh well - I still have quite a lot to learn! ;)
BigSky
11-01-2003, 11:57 PM
I realize that this is probably redundant, but;
Including a "selection" though particleId is handy for 'sifting' out the particles which are destined for the goal:
the modulus operator % calculates the remainder of a division (in this case, 2, and then the expression condition AND (&& ) compares it with 0, if the particle ID is odd the remainder is != 0, so the if statement is not true, and so half the particles don't go to their goal:
if((particleShape1.birthTime<2.0) && ((particleShape1.particleId % 2) == 0)) // birthTime is in second
{
particleShape1.goalVPP = linstep(0,1,particleShape1.ageNormalized);
}
else {
particleShape1.goalVPP = 0;
WhiteRabbitObj
11-02-2003, 03:38 AM
BigSky, that's a really cool idea, I will absolutely keep that in mind if I continue this or other effects in the future.
CGTalk Moderation
01-16-2006, 11:00 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.