Jump to content

Copy random fracture pieces over points via copy sop


cgartashish

Recommended Posts

Hi,

I had created a sphere and then fractured it, then I had selected few pieces so that I could copy them randomly onto few particles/points via the copy sop.

The problem is that, I want the copy sop to randomly pick up any one piece out of my selected pieces say from "piece0" to "piece8". But what actually happens is either only one piece is copied to each point/particles or all the eight pieces are cluttered together and copied over each point.

How can I set up a workflow where the copy sop randomly picks up any one piece from the provided pieces from the fractured geometry and instances it onto random points?

Thanks.

Link to comment
Share on other sites

This is possible, but I think it's a bit of work. Wouldn't be better to use stamp to vary the pieces instead (with a mountain sop or something)?

 

Anyway, if you really want to copy the fractured pieces you can pack it and then use the blast sop to delete everything but some fractured piece. Like this

 

fU79Pos.png

 

In the actual copy sop you can define the limits of the random to only the pieces you want (although I think it's easier to just delete the pieces you don't want the random to pick from) 

 

Edited by vtrvtr
  • Like 1
Link to comment
Share on other sites

7 hours ago, vtrvtr said:

This is possible, but I think it's a bit of work. Wouldn't be better to use stamp to vary the pieces instead (with a mountain sop or something)?

 

Anyway, if you really want to copy the fractured pieces you can pack it and then use the blast sop to delete everything but some fractured piece. Like this

 

fU79Pos.png

 

In the actual copy sop you can define the limits of the random to only the pieces you want (although I think it's easier to just delete the pieces you don't want the random to pick from) 

 

Hi, Thanks a lot for your help. It even works with the delete sop but I am really confused, because this expression works perfectly when I put it in group parameter of delete sop but when I put it in pattern parameter then the expression copies one single piece of geo onto every points. Why is that? How does it works in group parameter? Can you please explain?

Edited by cgartashish
Some more info to add
Link to comment
Share on other sites

Slight improvement to my version to account for part the centering of pieces, and got rid of some weirdness in VOP. Not sure if this is possible without a for-each (is it?).

Mine works by attributing one random piece to a group called "sel" and using that group to define the source group on the copy SOP. The seed for the random selection is based on the point number of the template point. This point number though is lost inside the for-each since it only brings in one point at a time, so it must be written to the "id" point attribute piror.

I then multiplied the random number generated (which is between 0-1) by the total number of packed primitives and converted it to an integer. Now I have a random integer that corresponds to a single packed primitive. I use this index number to assign the primitive to the group "sel"

So for this iteration I have one randomly selected packed primitive belonging to the group "sel" which I can use as the source group.

In practice I'd probably do it a little differently and instead delete all but the selected and transform to the point, orienting to normal if needed and skipping the copy sop entirely.

randomselection.hiplc

  • Like 1
Link to comment
Share on other sites

7 hours ago, shawn_kearney said:

Not sure if this is possible without a for-each (is it?).

Sure: randomselection_dv.hiplc

Option1 uses Primitive SOP to put the pieces on the points. I use a few nodes and expressions before that to make sure we have as many primitives as we have points - if we have to few, not all points are gonna get a primitive - and if we have to many, some primitives won't be moved.

Option2 uses Primitive SOP to put everything at the origin, and then just copystamp. 

I added some animation to the points so you can see the speed difference between the different methods. Increase the points on the scatter to like a thousand, and you can see option2 starting to become slower while option1 doesn't as much. The Primitive SOP might be quite limited in terms of control versus the Copy SOP, so what you use mostly depends on what you need. Also, a good alternative to the Prim SOP in option1 is to use Transform Pieces SOP.

  • Like 1
Link to comment
Share on other sites

@cgartashish

The pattern field in the delete sop doesn't work with vex variables (@name, in this case) groups do (I would think in all sops, but don't quote me on that) 

However, because of the nature of this particular issue, you can use the Pattern field too

RcOBaxH.png

 

This works because you can delete the packed primitives by their point number 

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, Skybar said:

Sure: randomselection_dv.hiplc

Option1 uses Primitive SOP to put the pieces on the points. I use a few nodes and expressions before that to make sure we have as many primitives as we have points - if we have to few, not all points are gonna get a primitive - and if we have to many, some primitives won't be moved.

Option2 uses Primitive SOP to put everything at the origin, and then just copystamp. 

I added some animation to the points so you can see the speed difference between the different methods. Increase the points on the scatter to like a thousand, and you can see option2 starting to become slower while option1 doesn't as much. The Primitive SOP might be quite limited in terms of control versus the Copy SOP, so what you use mostly depends on what you need. Also, a good alternative to the Prim SOP in option1 is to use Transform Pieces SOP.

 

I figured my method would be inefficient since I had to copy all the geometry for each iteration. I'll be sure to take a look at your hip later. :)

 

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