For Each Loop with Voronoi? (copy random pieces onto scattered points)

   4115   4   0
User Avatar
Member
14 posts
Joined: March 2016
Online
Hello everyone,

newbie here I hope you can help me out! I'm trying to copy a different, random piece from a voronoi onto scattered points

I tried following the for each copy tutorial (http://www.sidefx.com/docs/houdini/copy/tutorial_stamping.html) but it doesn't quite apply to what I am trying to do. it says the for each loop is set up to deal with pieces so I figured what I am trying to do should work since voronoi is generating pieces too?

I hit somewhat of a wall, hope someone here can guide me in the right direction.

what I think I should do / need to do is:

1) generate the pieces (using voronoi)
2) generate points to copy pieces to (using a scatter)
3) set up a copy to copy a random piece, not the whole thing (not sure how)
4) every piece needs a number so I can randomly draw one of those numbers to copy the piece (create point or primitive attribute? is that built into the voronoi group outputs? does houdini already do this for me?)


have a good day everyone, I attached the scene file, hope someone can help.

Attachments:
forEachFrenchFries.hip (163.4 KB)

User Avatar
Member
177 posts
Joined: Nov. 2015
Offline
I'm sure there is a better way to do this. I just can't remember all my VEX at the moment.
I did figure out a way to make it work though.

Hope this helps you.

Jim

Attachments:
forEachFrenchFries_JIM.hip (207.8 KB)

Reel Inpsirations
Houdini Work in Progress [vimeo.com]
User Avatar
Member
14 posts
Joined: March 2016
Online
wow thanks a lot Jim!

If you don't mind can you explain further the expression you used here?

fit01(rand(detail(“../meta”,“iteration”,0)),0,12)

is fit01 used to fit to a range?

what is the importance of fetching the # of iterations from the other loop? the number isn't directly used to calculate the random number between 0 and 12, right? That's what the 0,12) part at the end is for?
so is that part used for telling houdini to repeat the copy every time the other for each loop goes through one iteration?
Edited by quack_ - March 7, 2018 10:57:34
User Avatar
Member
177 posts
Joined: Nov. 2015
Offline
Sure, what I'm doing there is creating a random number from 0 to 12. The ‘seed’ value changes with every ‘iteration’ of the for each loop as it loops through the points on your french fry. The fit01 takes the number returned from the rand() function and makes it a number from 0 to 12. The rand function will return a value from 0 to 1 in decimal.

If you don't use a different ‘seed’ value for the rand function, you'll end up with the same number (I think.)
Reel Inpsirations
Houdini Work in Progress [vimeo.com]
User Avatar
Member
14 posts
Joined: March 2016
Online
something clicked, thanks a lot!
  • Quick Links