Created
May 23, 2020 03:09
-
-
Save sortofsleepy/b50f2879a318ea38981fec175d234260 to your computer and use it in GitHub Desktop.
Example of how to copy geometry with a VEX node in Houdini.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int numVerts = nvertices(1); | |
int numPoints = npoints(1); | |
int numPrim = nprimitives(1); | |
int ptTally = 0; | |
// copy all the primitives,vertex data, and indices. | |
for(int p = 0; p < numPrim; ++p){ | |
int prim = addprim(0,"poly"); | |
// get vertices for primitive | |
int primverts[] = primvertices(1,p); | |
for(int a = 0; a < len(primverts);++a){ | |
int pt = vertexpoint(1,primverts[a]); | |
addpoint(0,pt); | |
addvertex(0,prim,pt); | |
ptTally += 1; | |
} | |
} | |
// the last process will create a glut of points that we need to trim. | |
// we will also need to give those points value. | |
for(int i = ptTally; i > numPoints - 1; --i){ | |
removepoint(0,i); | |
} | |
// re-value the point positions on the output | |
for(int i = 0; i < npoints(1); ++i){ | |
vector pos = point(1,"P",i); | |
setpointattrib(0,"P",i,pos); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am learning Houdini and I was trying to think of how to copy a piece of geometry completely in VEX. This is probably not something done often if at all but the problem bugged me enough that I spent far too much time working on it.
This assumes your node is set to
Detail
for theRun Over
setting and that the geometry you want to copy is wired to input 1 with input 0 being free.Hopefully this is helpful to someone.