Created
February 9, 2015 10:56
-
-
Save NSDesign/983bb7df6d6a154e9a19 to your computer and use it in GitHub Desktop.
VEX : get a polygon primitive's points
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
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