Jump to content
  • Advertisement
Sign in to follow this  
Delli

Create polyline with triangles

This topic is 1134 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 need to create polyline using Triangles. I got points which lead through center of polyline. I need to generate vertexes and uv's for it. I'v got many problems with proper uvs on curves. Is there any algorithm available online for it?

 

 

sorry for my poor english.

 

Share this post


Link to post
Share on other sites
Advertisement

I'm confused. Per my understanding, a polyline is a series of connected line segments—a polygonal chain. It can exist in 3D space, but it does not intrinsically define any surface, let alone volume. To want to make one out of triangles them strikes me as impossible, nonsensical (in the literal, non-disparaging sense). I'm sure this is a communication breakdown, so can you elaborate some more on what exactly you are trying to say?

Share this post


Link to post
Share on other sites

Hello.

 it is possibly that i write it incorrect and you can't understand me. Here I created image showing what i trying to do:

polyline.jpg

 

I got red dots as polyline points. It is easy to create line through this dots. But i need to create polyline with width so I need to create it using triangles.But when i directly create it using only right vector i got errors on curves. Is there any algoritmic way to find vertex points for green triangles?

Share this post


Link to post
Share on other sites

Look e.g. VASE. You can also find it in the source code of any open (S)VG renderer like NanoVG or ShivaVG, although extracting the needed bits of code requires a bit of digging.

Edited by haegarr

Share this post


Link to post
Share on other sites

Hello.

 it is possibly that i write it incorrect and you can't understand me. Here I created image showing what i trying to do:

polyline.jpg

 

I got red dots as polyline points. It is easy to create line through this dots. But i need to create polyline with width so I need to create it using triangles.But when i directly create it using only right vector i got errors on curves. Is there any algoritmic way to find vertex points for green triangles?

 

Ah, I see what you mean. Is this a 2D strip or a full 3D "tube"? I'll tackle the 2D solution now, and then we can extrapolate to 3D as necessary.

 

The key is that the red points define a line through the center of your strip, and that at each joint the red point is the center of a cross-cutting line whose adjacent angle is precisely half the deflection between the segments. So, starting from the left of your diagram and numbering the red points p1, p2, p3 and p4:

  • at p1 there is no previous segment, so our strip's ends are perpendicular to the vector <p2 - p1>;
  • at p2 the cross section is at an angle relative to <p2 - p1> that is precisely half the angle between <p2 - p1> and <p2 - p3>;
  • at p3 we have no next segment, so our strip's ends are again perpendicular to the vector, this tome <p3 - p2>.

Remember that perpendicular lines have slopes that are the negatives of each other.

 

Using the above, you should be able to generate the points in your strip. Be careful in your algorithm to maintain the correct vertex order. I'll check back in a couple of days to see how you made out.

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!