Skip to content

Instantly share code, notes, and snippets.

@NSDesign
Created February 9, 2015 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NSDesign/983bb7df6d6a154e9a19 to your computer and use it in GitHub Desktop.
Save NSDesign/983bb7df6d6a154e9a19 to your computer and use it in GitHub Desktop.
VEX : get a polygon primitive's points
i@prim;
v@uv;
float dist = xyzdist(1, @P, @prim, @uv);
//Above gets the prim(n) and prim(uv) for a given point position
//Also the distance between the given point and the prim returned
//Although all we really need is the primitive number
//--
//Create array to store the primitive's point numbers
int primpoints[];
v@primpoints;//This vector is used to store the 3 points instead of using an array, due to a limit with array attributes.
NOTE:
Basically if you want to access the array in another wrangle further down the chain, you need to use a data type other than an array instead, a vector or matrix can be used to store array like data structures.
//Get the number of vertex for a given prim
int nvtx = primvertexcount(1, @prim);
//Loop over the vertercies to find their associated points
for (int i = 0; i < nvtx; i++){
//Get the linear vertex numbers for the prim(n)
int linearvertex = vertexindex(1, @prim, i);
//Get the point number from the linear vertex number
int vertexpoint = vertexpoint(1, linearvertex);
//Put point numbers into the points array
primpoints[i] = vertexpoint;
@primpoints[i] = vertexpoint;
}
//Display primitive's point numbers
//printf("%g \n", points);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment