Jump to content
  • Advertisement
Sign in to follow this  
jcurru

Thick dashes lines

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

If you intended to correct an error in the post then please contact us.

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?
Please see attached an example.

Thanks in advance!!

Share this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!