Selecting Fractured Pieces by Painting

   4346   5   0
User Avatar
Member
9 posts
Joined: 4月 2009
Offline
Dear friends,
Would like your suggestions and help for a method to select voronoi fractured pieces by painting some points of the chosen pieces.

In the example file attached, I have fractured a box, then coloured it all black, painted some points of my chosen pieces with red, then promoted the Cd point attribute to primitives. This helps to spread the color to other points of the pieces but doesn't reach all of the connected primitives of the piece. The deletion at the end to just to isolate the chosen pieces but you will see I will not get the entire piece unless I paint every point of the piece.

I did try to use a foreach loop with attribute wrangle to go though each piece but can't seem to get the right code. Maybe I am heading the wrong direction cos there could be a simpler method.

Appreciate your suggestions.

MiKE

Attachments:
selectPiecesByPainting.hipnc (157.1 KB)

User Avatar
Member
7871 posts
Joined: 7月 2005
Offline
Sorry, no time to open .hip files anymore these days. What you describe sounds like what I would first try as well. I forget now but is there a primitive attribute for the connected pieces? If not, you always append a Connectivity SOP to generate the primitive id for each connected piece. So now use an Attribute Wrangle in Detail mode to loop through all the primitives in the VEX code. When it finds a red primitive, it records the connected piece id and breaks out of the loop. Now it does another loop and sets all the primitives with the same piece id to red.
User Avatar
Member
8785 posts
Joined: 7月 2007
Offline
just create primitive Wrangle
if (nametoprim(1, s@name) == -1 ) removeprim(0, @primnum, 1);
connect voronoifracture1 as a first input
and delete1 as second

it basically looks at the second input geo, tries to find a prim with the same name attrib as current prim, and if none exists it will delete current prim

essentially it will keep the whole piece if there is at least one prim from that piece in the second input geo
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
9 posts
Joined: 4月 2009
Offline
Hi edward
Thanks for the suggestion, I'm kinda lost in the VEX wrangling/coding world. I tried putting this code in the attribute wrangle after a connectivity node that gives me the ‘class’ attribute for each piece. But alas not getting the results. Some more advice please…

Run Over : Details(once only)
VEXpression:
if(@Cd[1]>0) i@redpiece=primattrib(0,“class”, @primnum,i@success);
if(@class==@redpiece) @Cd=set(0,1,0); //change to green to see better difference

Many thanks
MiKE
Edited by michaelngeb - 2017年3月31日 01:32:46
User Avatar
Member
9 posts
Joined: 4月 2009
Offline
Many thanks Tomas.
It works beautifully although it took me some time to make sense of the code.

Here is the working file with the solution and notes added for future reference and search.

MiKE

Attachments:
selectPiecesByPaintingSuccess.hipnc (160.2 KB)

User Avatar
Member
1 posts
Joined: 12月 2016
Offline
I attempted the method and it works great, but I realized that some of the primitives from the selected pieces are missing. Is there any way to solve this?

Yes Mr. Michael this is your student

Attachments:
problem.jpg (40.7 KB)

Hilmi Halim
Visual Effects Student @ Nanyang Polytechnic, Singapore
  • Quick Links