vex question

   1470   1   0
User Avatar
Member
90 posts
Joined: March 2013
Offline
Hello, I'm working on the lakehouse tutorial and a part of the code she uses has me a bit confused.
int pts[] = primpoints(0, @primnum);
vector normal = point(0, "N", pts[0]);

She then goes on to write if and else statements with the “normal” variable. Like “if (normal.y > 0)” and “else if (normal.y<0)”. These if else statement figure out the values of the normal.y across the mesh. How is this possible, if the vector normal is only looking at
 pts[0]
and not the full array? To me it would seem like the code is looking only at one pt. What am I not understanding?
Edited by tadian - Aug. 3, 2017 23:12:24
User Avatar
Member
10 posts
Joined: Nov. 2015
Offline
Hi, I haven't seen the tutorial but from the Code it seems she's looking up a different point each time depending on @primnum.

pts is not always looking at the first point of the mesh, instead it looks at the first entry in the pts array created one line above that contains the points of the current primitive (@primnum). Probably this code is contained in a wrangle-SOP, what these do is to iterate through an entity (primitives in this case) and execute the code for each primitive / point / whatever. So pts contains different points each time the code is executed, thus iterating through the whole mesh.

The code itself if you would execute it only once does indeed look at a single point only.
  • Quick Links