I am trying to use primitive line strip to show individual poly lines in a mesh as follows:
mesh.setMode(OF_PRIMITIVE_LINE_STRIP);
int count = 0;
for(int i = 0; i<hatch.size(); i++){
vector<glm::vec3> points = hatch[i].getVertices();
for(int j = 0; j<points.size(); j++){
mesh.addVertex(points[j]); // mesh index = x + y*width
mesh.addColor(ofFloatColor(255));
count ++;
mesh.addIndex(count);
}}
But, when I call mesh.draw(), it draws the poly lines with each joined to the last; i.e. a continuous line with no break. Is it possible to do what I am after?
Hey @Sam_McElhinney_io , after thinking a bit I’m not sure there is a way to do this with 1 ofMesh. You could put each polyline into its own ofMesh and store them in a std::vector or other container.
Also, you could use multiple of3dPrimitive. They have an ofMesh in them and are derived from ofNode, so there is a way for them to move together if this is a consideration.
thanks Tim. I think I was probably misunderstanding how OF_PRIMITIVE_LINE_STRIP works. In the end I just used OF_PRIMITIVE_LINES and it achieved more or less what I wanted; not the most efficient but hey
Hi,
when using OF_PRIMITIVE_LINE_STRIP you will get a line rendered passing through all the vertices you pass to the mesh.
While OF_PRIMITIVE_LINES creates line segments between each pair of vertices you pass to it. so if you want to create a single line from the polyline you will need to pass each vertex twice (or use indexing is a better way).
Thus, it is easier to make one mesh per polyline