Search - User list
Full Version: Question : for each primitive in vex
Root » Technical Discussion » Question : for each primitive in vex
A-kun
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
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
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
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_
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;

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB