Three way switch expression

   2325   3   1
User Avatar
Member
9 posts
Joined: Sept. 2018
Offline
Hey there

Currently, I have this for each loop set up with a switch. This is taking the pieces from a voronoi fracture and breaking a random selection of them again, bu running them though a second voronoi.

This is the expression I am currently using on the switch

rand(detail(“../foreach_begin1_metadata1/”,“iteration”,0)) > 0.6

As I understand it this is going to affect %60 of the pieces.

What I want to do is to have a third input on the switch that is coming from another voronoi fracture. My goal is to end up with three different sizes of fractured pieces.

So I am trying to find an expression that will allow me to control how many pieces go though each input, in a similar way to the one above.

Attachments:
forEachLoop.PNG (37.6 KB)

User Avatar
Member
2451 posts
Joined: June 2008
Offline
What about something like this. Pre-calculate the switch index in a wrangle and only fetch the attribute in the switch.

Attachments:
Untitled-1.jpg (198.0 KB)
ap_3-way_random_switch.hiplc (127.4 KB)

Using Houdini Indie 19.5.
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
9 posts
Joined: Sept. 2018
Offline
Oh, thank you!

This is great, I did not realize how you could involve a wrangle in the situation.
Would there be a way to control the likely hood of each of the inputs?
User Avatar
Member
2451 posts
Joined: June 2008
Offline
Sure, just add weights to your random switch index result.
if (i@switch_index==1 && rand(@ptnum+801)>0.5){i@switch_index=2;}
Make up any logic you like that produces a final integer output value of 0,1, or 2.

// Always first switch for the first two seconds.
if (@Frame<48){i@switch_index = 0;}
Edited by Enivob - Oct. 8, 2020 09:36:45
Using Houdini Indie 19.5.
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
  • Quick Links