Jump to content

For Each node for vex


Tyfx567

Recommended Posts

I know we all want this but has anyone actually found a way to be able to do this over points/ primitives?

Bad example but work with me:

Say I have a sphere and I want to: for every face delete point "0". This will make a weird triangle shape. for every face

 

In vex I can say something like this:

int primnumarray[] = array(@primnum);

foreach( int primnum; primnumarray) {
int listpoints[] = primpoints(0, primnum);
printf(sprintf("%s", listpoints) );



if(listpoints[0] == 0) {removepoint(0, @ptnum); 
}

}

The problem if you look at the print, it doesn't set for each face point numbers: 0,1,2,3. Instead it looks at the sphere as a whole and determines the point numbers from that even though I am telling it to iterate over the faces. How can I tell houdini to "isolate" each face just like the foreach node?

 

btw, I know my last bit of the code is wrong I don't know what to do for the last bit. 

 

Thanks guys for any help!

Link to comment
Share on other sites

Are you running it once as Detail? Or for each Primitives?

 

Let's assume that your sphere has unique points. So each polygon has 4 unique points.

What you want to do could be accomplished with this simple code, run it in Primitive Wrangle (Attribute wrangle run over primitives):

int geo = geoself();
removepoint(geo, vertexpoint(geo,vertexindex(geo, @primnum, 0)));

Function vertexindex() will generate linearvertex number for first vertex (index 0) of each polygon (primitive). Function vertexpoint() then convert this linearvertex number to actual point index.

Link to comment
Share on other sites

or if you want it to work on geometry with shared points (fused)

then you can recreate each prim without first vertex and delete original prim

int pts[] = primpoints(0, @primnum);
int newprim = addprim(0, "poly");
for(int i=1;i<len(pts);i++) addvertex(0, newprim, pts[i]);
removeprim(0, @primnum, 1);

if however you want original prim attrib values back the fastest would be to copy them from original geo afterwards

Edited by anim
Link to comment
Share on other sites

Wow that was fast responses! Thanks so much guys! So unique points in this situation is like where it is isolating the points per primitive? prim 1 = 0,1,2 prim 2 = 0,1,2? Just trying to understand

Edited by Tyfx567
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...