Growing AND Drawing polylines progressively?

Hi there,
within my trip to polylines, I’d need:

  • to grow them progressively (adding vertices progressively)
  • to draw them progressively (being able to draw it progressively)

I think the best bet could be to have 2 polylines:

  • one precalculated (with all dots already calculated at the init)
  • another one for which I add the vertices from the precalculated one.

I can draw the second one at each time and as vertices are added progressively too, that one will seem to grow.

Does it makes sense to you ?

Maybe create a specific class like livingPolyline (living for growable etc) and even not having 2 polylines, but just one and an array with precalculated dots?

Basically, it would be useful to be able to draw a polyline from a vertices to another using percent for drawing too.

Then I’ll be able to create livingPolyline of livingPolylines (branching…)

i would create 1 polyline at the beginning with everything and then put it’s vertices in an ofVbo, with ofVbo you can draw a range of the vertices in it but all happens in the gpu and you don’t need to reallocate everytime you add a new vertex:

//setup
// add all the vertices to the polyline

vbo.setVertexData(polyline,getVertices().data(), polyline.size(), GL_STATIC_DRAW);

// draw
vbo.draw(GL_LINE_STRIP, start, count);

where start is the first vertex in the polyline you want to draw and count is the number of vertices to draw

1 Like

@arturo, thanks (again) for your answer.
I implemented it.
Works exactly the same BUT optimized a lot for the next steps of my stuff (creating A LOT of polyline systems).

Digging/Testing again the other part with branching. Still didn’t get how to create new branches (as children of branches…)