Avoid gradient color on a segments array

Hello! I have a Graphic3d_ArrayOfPrimitives array created using indexes, and I like to indicate a specific color per segment, not per vertex. What is the recommended solution? If I cycle using myPArray->SetVertexColor() the segments are colored in gradient like in the picture attached, which is not what I want.

Thank you!!!

Attachments: 
gkv311 n's picture

Graphic libraries (e.g. OpenGL) have no built-in concept of per-segment or per-triangle attributes. You may either duplicate nodes (e.g. split polyline into segments) or go into lower level and define done custom GLSL program with special color VBO.

bioan m's picture

Thank you very much for your response!
My array is now setup as Graphic3d_TOPA_SEGMENTS and I already duplicate nodes as working tests and it works (I'm using for tests Draw scripting)
I'm trying to create this mutable Graphic3d_ArrayOfPrimitives using indexes and wonder if it is possible to have per segment color result using bounds.
Also, there are few different type of Graphic3d_TOPA_SEGMENTS / Graphic3d_TOPA_POLYLINES / Graphic3d_TOPA_LINES_ADJACENCY and Graphic3d_TOPA_LINE_STRIP_ADJACENCY. I'm not sure which type is best suitable for displaying and simulation of a toolpath segments.

gkv311 n's picture

'bounds' is a legacy interface in primitive arrays. It could be optimized, but for the moment it is extremely suboptimal - drawer will loop over ranges and will draw them one by one. It would be fine for a small set of large ranges, but will hurt performance in case of large number of small ranges.

bioan m's picture

Thank you for your fast response!!!
So, the most accessible method remains to duplicate the nodes!
All the best!