Jump to content
  • Advertisement
Sign in to follow this  
HAM

Generate Triangle List

This topic is 4840 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

Trying not to re-invent the wheel, could someone point me towards an algorithm/function to generate a triangle list (or strip) from a series of points. The points are in series and all points are co-planar (2d). They form the outline of polygon (convex or nonconvex but do not contain 'holes'). Currently I am using Direct3D but would like a generic implementation, and would like to stay away from Direct3D meshes. A web resource would be good. Something outside of any library. Really just looking for an algorithm. Any help would be aprreciated.

Share this post


Link to post
Share on other sites
Advertisement
Anyway basically, just start looping the points (asuming that they represent triangles and are in order) :



int vertex = 0

for i < numtris
// a corner
trianglelist.index[0] = vertex;
vertex++;

// b corner
trianglelist.index[1] = vertex;
vertex++;

// c corner
trianglelist.index[2] = vertex;
vertex++;
end



Now the vertices must be in triangle order, like 0, 1, 2 - vertices creates the first triangle and so on. Anyway that is the basic code.. :)

Share this post


Link to post
Share on other sites
Arex's method works only with convex polygons. If you want more general solution, here (PDF warning) is a paper describing an algorithm that works with arbitrary shaped polygons. Also, try googling for "polygon triangulation".

EDIT: Fixx0red link.

Share this post


Link to post
Share on other sites
From the time I posted this I ended up going with the whole ear clipping idea.

Whcih pretty much looks like what you guys pointed to, so I suppose I'm on the right track.

Thanks for the resources.

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!