Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

gimp

Tesselating an n--sided polygon

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

This is probably Graphics 101 but I''ll ask anyway. I''m loading a file and just noticed that most of the polygons that the editor writes are 4 sided. The file format spec says each polygon can have up to 1023 sides. My data is represented as an array of indicies to the vertex array. Fair enough. My storage for rendering only stores triangles. How do I step through the indice array to form a bunch of triangles? All i can think of is to start at indice 1 then count 2 more, call it a polygon, repeat.. For more that 4 sides this will look a little ugly but it''ll get the job done right? Many thanks Chris

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by andy maddison
Yeah, if you want to triangulate a convex polygon, just make a triangle with vertices 0,1,2 then 0,2,3 then 0,3,4 etc.



You mean - triangle fan.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi Gimp,

Sounds like you are trying to parse Lightwave objects. In Lightwave specs it''s said that polygons are always convex and indices are specified in CW order, which helps you great deal.

You can either do it in the way Serge and Andy said by using triangle fans, but this will cause same artifacts when lighting the polygon, where each triangle is like a "beam" starting from the first vertex.

Another way is to make triangle strip out of that polygon which would make the lighting more coherent. Triangle strip is also very easy to build by presenting new indices to the strip from opposite sides of the polygon. For instance if your polygon has indices from 0 to 7, you get strip: 0, 7, 1, 6, 2, 5, 3, 4. As you can see, even indices do increase starting from the first index and odd indices do decrease starting from the last.

Cheers, Altair

Share this post


Link to post
Share on other sites
Hi Gimp,

Sounds like you are trying to parse Lightwave objects. In Lightwave specs it''s said that polygons are always convex and indices are specified in CW order, which helps you great deal.

You can either do it in the way Serge and Andy said by using triangle fans, but this will cause same artifacts when lighting the polygon, where each triangle is like a "beam" starting from the first vertex.

Another way is to make triangle strip out of that polygon which would make the lighting more coherent. Triangle strip is also very easy to build by presenting new indices to the strip from opposite sides of the polygon. For instance if your polygon has indices from 0 to 7, you get strip: 0, 7, 1, 6, 2, 5, 3, 4. As you can see, even indices do increase starting from the first index and odd indices do decrease starting from the last.

Cheers, Altair


"Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." - Albert Einstein

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Just a quick question about Lightwave''s n-sided polygons.
I can''t find this in the file format docs:

Can I assume all the polygon''s vertices are on the same
plane (coplanar) ?

Share this post


Link to post
Share on other sites
Yep. I am writing a lightwave parser. I have most of it worked out though Texturing and especially UV mapping seems difficult.

I was going to just reduce the whole thing to triangles then later run a greedy insertion stripper on it.

Altair, would you be available offline for discussion on lightwave loading?

As a simple exercise I''m just writing a simple textured geometry loader. No envelope support. In fact I''m considering making it single surface as well (ie One texture, One bump map and thats about it). I can''t see much of a use for anything else in there.

I have some other problems I can''t understand like the "infinate precision surface ordering thing", in the spec example the surface is named \x80\x81... I really don''t get the naming \ ording of blocks (or understand if it''s something I need to learn about).

Many thanks

Chris

Share this post


Link to post
Share on other sites
Sorry, it''s only said in LightWave specs that: "the vertex list for each polygon should begin at a convex vertex and proceed clockwise as seen from the visible side of the polygon", so polygons can be complex as well, but I believe that writing loader to support only convex onces would suffice, or otherwise you should spank your gfx artist (:

It''s also said in the document that "LightWave polygons are single-sided (although double-sidedness is a possible to surface property) and the normal is defined as the cross product of the first and last edges", so if polygon has a normal, it means (IMO) that all vertices are co-plannar even though it''s not separately stated.

Gimp, I don''t have much knowledge of loading LightWave object files. I have just made some simple version which splits the geometry to triangle lists according to the materials, but this doesn''t handle materials yet.

Cheers, Altair


"Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." - Albert Einstein

Share this post


Link to post
Share on other sites

  • 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!