Hello all :
I am new to Houdini, and I am trying to do the following :
I want to spawn a random polygon on the scene.
But I don't know how to do it...
any idea? leads? thank you!
Random switch :
885 2 1- lostshun
- Member
- 1 posts
- Joined: 10月 2019
- Offline
- ajz3d
- Member
- 478 posts
- Joined: 8月 2014
- Offline
How random this polygon needs to be?
The code below, when pasted into a detail wrangle node will create a random polygon within a (-1, 1) range of XYZ. Point count and seed are regulated by spare parameters. They need to be created first (hit the plus button in the wrangle's UI).
The code below, when pasted into a detail wrangle node will create a random polygon within a (-1, 1) range of XYZ. Point count and seed are regulated by spare parameters. They need to be created first (hit the plus button in the wrangle's UI).
int point_count = chi("points") + npoints(0); int points[]; int seed = chi("seed"); for(int i = npoints(0); i < point_count; i++) { vector pos = set( fit(rand(seed + i - npoints(0)), 0, 1, -1, 1), fit(rand(seed + i + 1 - npoints(0)), 0, 1, -1, 1), fit(rand(seed + i + 2 - npoints(0)), 0, 1, -1, 1) ); addpoint(0, pos); push(points, i); } if(len(points) > 0) addprim(0, "poly", points);
Edited by ajz3d - 2023年7月4日 15:06:35
- Jikian
- Member
- 131 posts
- Joined: 8月 2012
- Online
-
- Quick Links