Jump to content

Procedural grouping (grouping leafs of a tree)


Recommended Posts

Hello,

I have this crude tree, and I want to group all ‘leaves’. The leafs are not connected to the tree, they just float around, and all of them are just these two prim squares. I can't find a way to make the grouping. I guess an expression or primitive wrangle could help, but I am a novice in these things.

tree.JPG

Link to comment
Share on other sites

a primitive wrangle would be the solution with the pretty much the best performance yeah

I guess something like this could work (typing this from the top of my head, could have typo's/errors):

////

int connectedVertCount, i, pts[];

connectedVertCount = 0;
pts = primpoints(0, @primnum);

for(i = 0; i < @numvtx; i++)
{                 
	connectedVertCount += len( pointvertices(0, pts[i]));
}

@group_leaves = (connectedVertCount == 5); 

 

  • Like 1
Link to comment
Share on other sites

If the vertex count is the same/similar, you can do something like this inside a Primitive Wrangle node:

if ( primvertexcount ( 0, @primnum ) == 8 )

    i@group_leaves = 1;

EDIT: Thought it was a single polygon, disregard this answer :P

Edited by pusat
Link to comment
Share on other sites

or you can use combination of Assemble SOP and Measure SOP. Assemble will make a name attribute for each polygon island which you can loop over. in the For each loop use Measure SOP and measure area of each polygon island. since all leaves will have the same area you can group them by area attribute. this is a slower method than wrangle but i'd say it will give better result in this particular case.

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