A-kun
May 5, 2024 18:44:10
Hi, I'm currently learning houdini vex, but I can't understand how to write ForeachLoop in vex. i simply want to run " i@get = @ptnum" in each primitive but don't want to use foreach node just for the simple line. Would be nice if some one tell me how to do this in ves. thanks!
jsmack
May 5, 2024 19:38:09
I'm not sure what you're after, but you don't need a for each loop block in sops just to enumerate primitives in VEX. On the wrangle, change the run over to primitive, and @primnum will be the number of the current primitive. The for each loop block is only needed for isolating parts of the geometry and running a set of nodes over each isolated part.
A-kun
May 5, 2024 20:03:41
Hi I simply want to have the same pointNumber between distant primitives. so I used foreach node to run the wrangle to get the same numver between them but I feel this is not smart way so would like to do the same thing just in vex.
tamte
May 5, 2024 20:21:10
if your primitives are all separate you can do this in Point Wrangle
i@get = vertexprimindex(0, @vtxnum);
if any of the points is shared among multiple primitives it will get the vertex index value from first connected primitive
animatrix_
May 6, 2024 00:19:26
A-kun
Hi I simply want to have the same pointNumber between distant primitives. so I used foreach node to run the wrangle to get the same numver between them but I feel this is not smart way so would like to do the same thing just in vex.
If you mean to get the same point indices between different prims, you can just create a new points array for each prim like so:
int indices [ ] = array ( );
int pts [ ] = primpoints ( 0, @primnum );
foreach ( int index; int pt; pts )
append ( indices, index );
i[]@indices = indices;