Jump to content

Looping Through Particle Groups


lisux

Recommended Posts

Hi everybody.

Has anyone any idea about how to loop over a particle group in POPs using only expressions.

I need to make an expression that loop over all the points in a group created by the Proximity POP, to check some attributes in all the particles that are into a radius of influence of a particle.

Is this possible using only expressions?

First of all how can I get the list of points in a group in POP, there are functions for SOPs but I haven't found anything in POP, and later once I know this list how can I loop over this list?

Thanks.

Link to comment
Share on other sites

Hey Lisux--

You'll probably want to make a multi-line expression in Houdini. The function you're looking for is haspoint() - which returns 1 if the specified SOP has the current point in the specified group, else it returns 0.

So your multi-line expression (or whatever it is really called, someone correct me), would look something like this:

{

float i = 0;

# We'll loop through *all* the points first

for (; i < $NPT; i++)

{

# Now let's check to see if the current point we're itterating over is

# in the specified particle group. If it isn't, then we skip it (continue)

if ( haspoint("myGroup", "/obj/geo1/popnet1", i ) == 0 )

continue;

# All particles analyzed from here on should be in the specified group

# So do your crazy math/functions here!

}

return 0;

}

That make sense? If not, let me know and I can elaborate a bit more.

Oh, one tricky point: the haspoint() expression requires a SOP path, POP paths will *always* return 0.

Good luck!

Link to comment
Share on other sites

I'm not quite sure I understand. All POPs already inherently loop over the particles. To restrict which particles are modified, you give it a particular group. If you want to modify the positions, use the Position POP, or manipulate arbitrary attributes using the Attribute POP.

Link to comment
Share on other sites

I'm not quite sure I understand. All POPs already inherently loop over the particles. To restrict which particles are modified, you give it a particular group. If you want to modify the positions, use the Position POP, or manipulate arbitrary attributes using the Attribute POP.

First off Edward, I love your Hitchhiker's Guide to the Galaxy reference.

Secondly, you're absolutely correct in everything you said. POPs do loop over all the particles. However, there are times when absolute control over certain groups is necessary. As a trivial example: If you had two groups, A and B - and you wanted an attribute for every particle in group A that was its nearest neighbor's distance from the closest particle in group B (excluding other members from group A) you would need this control.

Make sense?

Link to comment
Share on other sites

Ah, it wasn't clear to me that lisux wanted to do a per-particle loop of all other particles.

Yes edward bwalters is correct.

I need to make a per particle loop, now I am already using a lot of groups stuff like you suggested, but thid time I need more control, because I want to make a per particle loop over the particles contained in a group, a group created using the proximity POP, I think it makes a lot of sense, this feature of the Proximity POP seems to be designed to be used for per particle loops, but ... then you find the great problem, there aren any expression fucntion in POP like the haspoint or pointlist, the good solution will be to have a list of all the aprticles in a group, and then loop over this list, this is possible in SOP but in POPs?

Link to comment
Share on other sites

One option could be to use an expression to modify the group that affect and operator, so every particle use a different group in an operator, to apply the same operation to every particle group.

The origin of this idea is to use the groups created by the Proximity POP.

It creates many groups with the same prefix, only xhange the suffix, thi is the ID of every particle.

To use of this group I have made a test using several expressions in the Source Groups Parameter of a Color POP, I want to apply a random color to every group so I have tried these expressions:

`strcat(proxgroup, $ID)`
`strcat(proxgroup, "$ID")`
`strcat(proxgroup, ftoa($ID))`
`evals("strcat(proxgroup, $ID)")`

But all the time I get an error telling that proxgroup0 doesn't exists.

So every time I use the variable $ID it is returning 0.

The ftoa function don't return the string version of $ID, or because $ID is returning 0 I get always 0.

There is any way to automate the source group per particle, so for every particle I can apply and operation for a group of particles?

Or another strategies to use all the groups created by the Proximity Group?

Thanks

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