Jump to content

Wrangle: Reset Particle Age when the particle enters a group


Recommended Posts

I have particles from one stream being grouped based on proximity and I'd like to deleted these particles after a certain time.

 

So my question is: How would I reset the particle age when they enter the new group?

 

Call it old habits but I like the option to reset the age every time a particle enters a new set of rules

I'm trying to assign a popkill based on age / nage, and this is what I have so far:

 

if (@nage > 0.1)
{
    dead = 1;
}
    else
{
    dead = 0;
}

 

This deletes the particles based their normalized age but it's not what I'm after, I'd like to delete them based on the time after they where grouped.

 

 

Then my second question is how would I add a smooth transition or add a bit of randomness so they dont all disappear at once?

Link to comment
Share on other sites

i'd do it with a countdown kind of thing.

 

if (ingroup("newGroup",ptnum))    // particle is in the new group

{

    if (i@particleInitialized==0)         // only re-init "new" particles

    {

        i@particleInitialized = 1;

        f@alive = hscript_rand(ptnum*3.45698) * X + Y;    // X = variation of life time, Y = min life.  result is particle lasts between X and X+Y seconds

    }

 

    f@alive = f@alive - TimeInc;

 

    if (f@alive <= 0)

       dead  = 1;

}

Link to comment
Share on other sites

Great thanks, but when I plug this VEX snippet into a popkill I get an error: Call to undefined function 'ingroup'

 

I've change the group from "newGroup" to "Active"

 

Am I missing something?

 

In a Vex expression inside these kind of nodes the ingroup() function doesn't work. You have to use the "group_GroupName" expression. In your example above, the line of code would be:

 

if (group_Active == 1)

{

 .....

}

 

To put an element inside or outside a group, you assign "1" or "0" to the group expression, ie: group_Active = 1 // group_Active = 0

Link to comment
Share on other sites

Still no luck.

 

Now I'm getting another error which is saying "unexpected end of file"

 

Maybe there's another approach to this, all I'm trying to do is have particles be deleted over 1 second as they enter a new group, perhaps someone has a simpler approach?

 

 

post-10402-0-18611300-1409264173_thumb.j

Wrangle_PopKill.hip

Edited by Nicholas Yiallouris
Link to comment
Share on other sites

Yes Indeed they where mismatched, thanks but the original problem persists:

It looks like the VEXpression inside the popkill is not picking up the function "group_GroupName" or "ingroup()" .

 

Is there another function I should be using?

 

post-10402-0-09053100-1409329262_thumb.j

Wrangle_PopKill.hip

Edited by Nicholas Yiallouris
Link to comment
Share on other sites

here is the fixed file

2 popnets inside

one using group as you have in your file

second using stream, which is essentially the same thing, but visually cleaner as you can tell straight away which nodes are applied for which stream

 

to do what you want you can just create popwrangle only for your group (or in desired stream) with this code:

f@activeage += @Timeinc;

then popkill (alsoo only on your group or in desired stream):

dead = f@activeage>1;

that's it

 

activeage is completely custom name (you can create any nonexistent attribute for this purpose), it's just an attribute which will start counting only when particle is in the group/steam 

Wrangle_PopKill_fix.hip

  • Like 1
Link to comment
Share on other sites

Yes Indeed they where mismatched, thanks but the original problem persists:

It looks like the VEXpression inside the popkill is not picking up the function "group_GroupName" or "ingroup()" .

 

Is there another function I should be using?

 

Sorry, my bad. The right expression is "@group_GroupName" (I missed the "@" in front)

Link to comment
Share on other sites

here is the fixed file

2 popnets inside

one using group as you have in your file

second using stream, which is essentially the same thing, but visually cleaner as you can tell straight away which nodes are applied for which stream

 

to do what you want you can just create popwrangle only for your group (or in desired stream) with this code:

f@activeage += @Timeinc;

then popkill (alsoo only on your group or in desired stream):

dead = f@activeage>1;

that's it

 

activeage is completely custom name (you can create any nonexistent attribute for this purpose), it's just an attribute which will start counting only when particle is in the group/steam 

 

 

Thank You Tomas !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...