I want to randomize the “orientation” of the L-shape block for each patch of a grid surface. The rand() function is used inside a foreach node to decide randomly which of the four corners of a polygon is used as pivot point for the transform node based on the surface ID of a given polygon.
However, I can't get the random form as expected.
Can you kindly advise?
Thanks!
rand() doesn't work inside foreach node
3535 3 1-
- oat
- Member
- 479 posts
- Joined: 12月 2009
- オフライン
-
- Doodlez
- Member
- 25 posts
- Joined: 10月 2012
- オフライン
-
- oat
- Member
- 479 posts
- Joined: 12月 2009
- オフライン
Thanks, Doodlez!
I updated my method, too. So, we have two ways to do it via the hscript in the “ctl1” node to drive randomness:
1.
int(rand(prim(“../each1”, 0, “id”, 0)+$F)*10)%4
… which gives you a random integer between 0 and 3 for each frame.
or
2.
int(rand(stamp(“..”,“FORVALUE”,0)+$F)*10)%4
Pls kindly advise if there are other efficient way to do this.
Thanks, again!
I updated my method, too. So, we have two ways to do it via the hscript in the “ctl1” node to drive randomness:
1.
int(rand(prim(“../each1”, 0, “id”, 0)+$F)*10)%4
… which gives you a random integer between 0 and 3 for each frame.
or
2.
int(rand(stamp(“..”,“FORVALUE”,0)+$F)*10)%4
Pls kindly advise if there are other efficient way to do this.
Thanks, again!
-
- Doodlez
- Member
- 25 posts
- Joined: 10月 2012
- オフライン
I'm not sure which is more efficient but if that is important you should look at getting rid of the cookie nodes unless you are going to use them to create more varied shapes then just L blocks.
Maybe it is intended but with your current expression you have a bias towards the first two possibilities.
Maybe it is intended but with your current expression you have a bias towards the first two possibilities.
-
- Quick Links

