Jump to content

Recommended Posts

Hi guys (and gals)!

How can I split the scattered points of a geometry into three groups, depending on the scattered points position to three different objects? I have tried with point clouds, with nearpoints and everything I could imagine, but I can't seem to figure it out! It either relies on radius, or doesn't sort correctly. I also tried with the sort node but it really messes with my sopsolver which is used for the infection down the stream..

To better explain the situation, lets say I have the geometry I want to split scattered with 10 points, and the point targets I want to use as refs have 2, 4, 4 points respectively. How can I "sort" the scattered points to either belong to group 1, 2, or 3 explicitly, depending on the distance from the point targets? Each point should belong to one group and one group only. And the sorting only has to happen in the beginning of the sim, after that pop forces take over.


If anybody has any idea, please, feel free to share!

Thank you for your time,


Share this post

Link to post
Share on other sites

Hmmm if all you care about is distance to the target geometry, you should be able to just assign an integer attribute called like "target" or something, and use nearpoint() and point() to get the closest one.

int pt_near = nearpoint(1, v@P);
i@target = point(1, "target", pt_near);

and do stuff to your particles from there. 

You could even make them into groups if you wanted

string groupname = sprintf("target_%d", i@target);
setpointgroup(0, groupname, i@ptnum, 1, "set");

Maybe I'm missing something?



  • Like 1

Share this post

Link to post
Share on other sites

Hello @jamesr!


Thank you for your reply and your example file! I as well had previously tried with nearpoints and target variables for the separation, but it is not what I want. Although it never occurred to me to use the ray node, so I learnt something today from you! :) 

The thing is that I want the exact number of points of lets say floating_object_1 separate and group the exact number of points in my geometry. The sum of the points of the 3 floating objects is the point count of the affected geometry (in your example of the pighead). So if floating_object_1 has 10 points, I want the 10 closest points to the pighead  (10 out of 43 lets say for our example - the rest 33 belong to floating_object_2  and floating_object_3) to group and belong to floating_object_1 only.

This is because after the grouping, I advect particles to "construct" the floating objects, point to point. Now because they are not sorted out correctly, but may be spread throughout the whole static geometry, points from the other side of the pighead  will fly out trying to reach floating_object_1 and create an optical mess - instead of being nice and neat and each going to the closest attractor.

Hope I helped explain the situation a little bit better - if not, I can try and make a clean example when I get the chance.


Thank you once again for the effort,


Share this post

Link to post
Share on other sites

Could you just ray the target points that are on each target onto your source starting geometry and call those the starting points? Then you have the target attribute/group already on the points, and already once they are minpos'd onto the source geo, they will always be as close as they can be to that target.

Edited by jamesr

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now