Jump to content

Kill particles by distance


hmihalis1

Recommended Posts

Hi all,

I'm trying to come up with some vex to use to kill particles in a sim when they have traveled a certain distance from their birth location. I have mother particles that last one frame and i'm using a pop replicate to spawn new splash particles from them. What i'd like to do is store the position of the mother particles and subtract it from the position of each replicated particle every frame to get the distance, then set them as dead once this has passed a given threshold.

Extremely limited VEX experience here, so if anyone could give me some kind of starting hint/snippet that would be amazing :)

Many thanks,

H

Link to comment
Share on other sites

Hi @Noobini

Thanks for your response! Right now I have this situation:

 

//Rounding my particle age up to get the frame number (no idea if this maths is right):

f@frameAge = ceil(f@age*24);

 

//if frameAge is 1 save the startPos:

if(@frame == 1){
    v@startPos = v@P;
}

//Then get vector length and kill if it exceeds threshold:

f@distance = (float)abs(v@startPos - v@P);

if(distance > ch("threshold")){
    @dead = 1;
}

 

Do you think this makes sense? Not confident i'm getting the vector length correctly. I'll check your solution now. Thanks so much!

 

 

Edited by hmihalis1
Link to comment
Share on other sites

Just now, hmihalis1 said:

Ok thanks :) it seems to work kind of but also deletes points i want to keep so i'll try your solution now

then you prolly just need to make sure you group 'mothers' and 'children' particles properly...then do whatever to certain groups.

Link to comment
Share on other sites

15 minutes ago, Noobini said:

then you prolly just need to make sure you group 'mothers' and 'children' particles properly...then do whatever to certain groups.

I combined your code and this seems to have the desired effect:

f@distance = (float)abs(length(v@startPos - v@P));

if(f@distance > ch("distance_threshold")){
    @dead = 1;
}

will make sure to set up the groups properly. still new to pops and getting my head around streams etc


 

Link to comment
Share on other sites

2 minutes ago, Noobini said:

why in popcolor it's using color instead of the obligatory Cd ?

because color is a variable, not the name of the attribute, it still creates v@Cd and f@Alpha

in different modes it uses variables like seed or ramp  

it's how VEXpressions are designed, they allow you to modify certain data that's used within the bigger VOP network, normally input parameters that flow into snippet VOP, and SESI tries to preserve the names of the parameters so that it's a bit intuitive

so color variable contains the color parameter value and you can either use or overwrite it within that VEXpression, the result will be written to v@Cd

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...