1
\$\begingroup\$

Part of my game takes SVG polylines (which are just basically a set of x,y coordinates that define a multi-segment line) and converts them into 3D 'paths' (ie. a line created as a set of faces all pointing 'up').

I was wondering if there was a standard algorithm I should consider for how to smooth the corners of the lines when there is a change of direction. I don't want to turn the whole path into a smooth curve - I just want to smooth out the corners where the line turns sharply.

Example

What I'd love is an algorithm that - given two vectors (V1 & V2) and a line thickness (T) - returns the best two 2d coordinates to use as the corner vertices so that the I don't have to add any additional polygons to the line, and that both of the incoming lines keep their thickness.

Is this wishful thinking, or is there something like this out there?

Thanks.

\$\endgroup\$
  • \$\begingroup\$ Yes, that's feasible, lemme find it again. You do need to worry about the case of very acute angles, which would generate huge spikes if you don't detect them and clip them off with an additional triangle. \$\endgroup\$ – Quentin Jul 12 '17 at 8:25
  • 1
    \$\begingroup\$ Well, I can't find the wonderful article I was thinking about... But looking around for "opengl line joins" and "opengl thick lines" produces some relevants results. \$\endgroup\$ – Quentin Jul 12 '17 at 8:40
  • \$\begingroup\$ paul.houx has an outstanding explanation here - forum.libcinder.org/topic/… - that I wouldn't have found without the idea of adding OpenGL to the search. Thanks. \$\endgroup\$ – Steve Harding Jul 13 '17 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.