Creating an area following a given path

I have a list of with the following elements:
(x, y, width, texPos)

The coordinates (x, y) form a path. I need to create an area of width following the path. It also has to be texture mapped with texPos as the texture u coordinate.

(Let’s declare here that vector v = (x{n}, y{n}) -> (x{n+1}, y{n+1}))

Currently I’m doing this by calculating an orthogonal unit vector for every v and multiplying its length by 0.5 * width and then reversing it to get the opposite side coordinate, and using the calculated coordinates to create a triangle strip.

This approach has a major problem, though: when the magnitude of v is smaller than width and the angle between two consecutive v vectors is large enough, the generated orthogonal segments will intersect and result in overlapping polygons.

I’ve been thinking about using GLU tesselators to fix this, but do they work with such complex shapes? Also, is there a better approach to this problem?

you should calculate the lateral vector as an
average of two consecutive path segments.

Originally posted by RigidBody:
you should calculate the lateral vector as an
average of two consecutive path segments.

Thanks,

I tried it and it definitely looks much better now, but the problem isn’t completely gone: there are still some overlapping polygons (the magnitude of v is typically about 1/10 or 1/15 of width, so the angle between (now averaged) consecutive segments doesn’t have to be very large for the laterals to intersect).

Would weighting the averages help, and if so, what would be a good way to set the weight?