Thick dashes lines

This topic is 2030 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello!

I've benn googling for months but I finally surrender.
Maybe someone here can help me.
I'm writing a GIS (Geographic Information System). Therefore, I have to render complicated maps.

One of the main challenges consists in drawing thick dashed lines (roads, e.g).
Imagine a highway which is being constructed. It depends on the country, company, etc, but very often it's drawn as a discontinuous (dashed) thick line (yellow with red borders).

Ok.

Drawing a thick line is relatively easy using triangle strips.
Applying red/yellow/red color to borders is also easy: you can draw the line twice, or you can use one-dimensional textures.

But I can't figure out how can I achieve the discontinuity. If I use a bi-dimensional texture (half of it with alpha zero) then the problem is assigning texture coordinates. And that's a huge problem.

Ah! I cannot use shaders (I don't even know what a shader is ;-)

Any idea?

Share on other sites
Could you use a texture that wraps in the direction of the road, with half opaque half transparent?

Share on other sites

I imagine you are simplifying things by drawing these lines as one continuous triangle-strip, in which case, if you use the actual points at the center of each joint, and use the distance between successive points, cumulatively, you can easily generate texture coordinates..

eg: current point position subtracted from next point's position, the length of that vector, scaled by how many dashes you want per unit of space, is the next coordinate along the opaque/transparent alternating axis of the texture, re-use that same coordinate when you begin to draw the next two triangles, and calculate the next coordinate by simply adding current-pos-subtracted-from-next-pos, scaled by an appropriate amount.

Share on other sites

Could you use a texture that wraps in the direction of the road, with half opaque half transparent?

Thanks for your answer, Waterlimon. As I said in my post, "But I can't figure out how can I achieve the discontinuity. If I use a bi-dimensional texture (half of it with alpha zero) then the problem is assigning texture coordinates. And that's a huge problem".

Share on other sites

I imagine you are simplifying things by drawing these lines as one continuous triangle-strip, in which case, if you use the actual points at the center of each joint, and use the distance between successive points, cumulatively, you can easily generate texture coordinates..

eg: current point position subtracted from next point's position, the length of that vector, scaled by how many dashes you want per unit of space, is the next coordinate along the opaque/transparent alternating axis of the texture, re-use that same coordinate when you begin to draw the next two triangles, and calculate the next coordinate by simply adding current-pos-subtracted-from-next-pos, scaled by an appropriate amount.

Yeah! Sounds great! So this is your proposal to solve what I called a "huge problem". It seems not so big now. So thank you very much!!

By the way: do you know where can I find the code to "trianglestrip" the line axis? I have my own function, but I don't like it.

Thanks again!

Share on other sites
I think you can just mke the texture coordinates be the distance from the start of the road and it should work.

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633735
• Total Posts
3013596
×