Pompey Liang
jujudebuguilu
About Me
Connect
LOCATION
Not Specified
WEBSITE
Houdini Skills
Availability
Not Specified
Recent Forum Posts
Find the corresponding point index of primitives' vectice Sept. 11, 2021, 6:14 p.m.
Hi guys, I am trying to use the average color of each vertex to recolor the primitives, I know use the attribute promote node can convert the point attribute to the primitive attribute. But I want to use VEX to achieve the same result, and I have some problem now.
My logic is as following:
1. First, use the primvertices to get linear vertex indices for each primitive.
2. Then, convert these vertex indices into point index by using vertexpoint.
3. Finally, access the "Cd" with the point index and calculate the average color for each primitive.
Here is my Vex code that run over primitive:
But my code does't work, can some one help me to check my code?
My logic is as following:
1. First, use the primvertices to get linear vertex indices for each primitive.
2. Then, convert these vertex indices into point index by using vertexpoint.
3. Finally, access the "Cd" with the point index and calculate the average color for each primitive.
Here is my Vex code that run over primitive:
int verticeIndex[] = primvertices(0, @ptnum); vector colorArray[] = array(); foreach(int vertexIndex; verticeIndex) { int posIndex = vertexpoint(1, vertexIndex); vector pointColor = point(1, "Cd", posIndex); append(colorArray, pointColor); } vector newcolor = sum(colorArray) / len(colorArray); setprimattrib(0, "Cd", @ptnum, newcolor);
But my code does't work, can some one help me to check my code?