Let´s say, i have a grid.
I generate a point in the center of every primitive.
After that, i want to select a random PointA and imidiatly select another PointB wich is above PointA.
If there is no PointB above PointA then search for another random PointA and try again.
What i tried:
int pts[]; float seed; @rand; ///////////////////// pts = expandpointgroup(0, "*"); pos = point(0, "P", @ptnum); seed = ch("seed"); @rand = floor(rand(seed)*@numpt); ////////////////////// //s@pointName = "pointA"; @p0 = @ptnum; @p1 = @ptnum+1; @selected = 0; //////////////////////// // for loop for(int i=0; i <= len(pts); i++) { if(@p0 == @rand) { //setpointattrib(0, "selected", @rand, 1); i@selected = 1; s@pointName = "pointA"; } else if(@p1 == @rand) { i@selected = 1; s@pointName = "pointB"; } else { i@selected = 0; s@pointName = "none"; } } ////////////// // foreach // foreach(int pt; pts) { // if(@p0 == rand) { // @selected = 1; // s@pointName = "pointA"; // } else if(@p1 == rand) { // @selected = 1; // s@pointName = "pointB"; // } // } /////////////////// // if (first approach // if(@p0 == rand) { // @selected = 1; // }else { // @selected = 0; // } @pts = len(pts); ////////////////////// // out messages // printf("Length %d", len(pts)); // printf("Rand %d", rand); // printf("CurrentP %d", @p0); // printf("Test %d", rand);
All the things that are commented out where my first approaches, nothing of them worked.
My Wrangle Node runs over points, but letting it run over Detail didn´t work either.
I also tried to pts instead of @p0 into the foreach loopm but this does set teh @selected attribute to 1 on every point and not just in a single point.
I am very new to coding at all and i´m a bit stuck on this.
It seems that i misunderstand loops in Houdini in general.
If possible, please send me the longer way and easier to understand first so i can figure out what is happening, again, i am very new to coding and maybe i don´t understand everything at first, but i´ll try
Thanks a lot for every answer from you guys!!!