Jump to content

Pairing Particles from 2 Different Groups with a NearPT attrib and an Add SOP


Biohazard9012

Recommended Posts

Hi Everyone,

I made some good progress with my scene, and everything was working perfectly in my test scene, but now that I've started moving everything over to an actual scene I'm having problems. 

Basically i have a group of points "group 1" and for each point in the group i want to find the closest point in a different group of points "group 2". I then create an attribute for it called "nearPT" and use the Add SOP to create a line by attribute through nearPT. However the number of points will vary randomly between each group so sometimes it works right and sometimes it does not. I've attached a few pictures to help explain what I mean.

 

I really only want there to be only one "pair" for each of them, as in 1 line going from 1 green to 1 red (the colors are for testing/visualization purposes, but won't be in the final version). It's frustrating because in Image 1, there's only 1 pair, with 2 extra green points. In Image 2, they all match up correctly. In Image 3, it starts screwing up because one of the pairs has an extra line going to a second red point, and finally in Image 4 it's completely messed up with only 1 green and 3 reds, yet they're all connecting with 1 long line.

 

I've been doing most of the work while alternating between a wrangle node and a VOP, however essentially performing the same action by using the NearPoint function. So my wrangle node would be "i@nearPT = nearpoint("op:path_to_merged_points", "group 2", @P, 10). I hope I was clear enough in my description.

 

Thanks!

temp1.JPG

temp2.JPG

temp3.JPG

temp4.JPG

Link to comment
Share on other sites

I think you need to run it in a for loop since if everything runs in parallel points will not be aware of simultaneous connections being made.

I'm not sure if I got the behavior right from your description, but I think most variations of it can be achieved like this

 

pair_logic_001.hipnc

Edited by dchow1992
Link to comment
Share on other sites

7 hours ago, dchow1992 said:

I think you need to run it in a for loop since if everything runs in parallel points will not be aware of simultaneous connections being made.

I'm not sure if I got the behavior right from your description, but I think most variations of it can be achieved like this

 

pair_logic_001.hipnc

Thanks for the reply, i went ahead and looked over your example file. I'm not sure if it seems to be working right, as it doesn't actually appear to be grabbing the closest points to each other (see attached image, where blue is a connection and yellow is what probably should be the closest correct connection). I've gone ahead and attached a quick example file to show what my setup is like, with the wrangle node as well. As I said, the number of points in each group is always changing because they're coming out of separate POPnets.

I've tried a few different versions of trying to use ForEach loops and vops as well, but just couldn't seem to get the logic down correctly

temp.JPG

connectingPoints_Ex.hipnc

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