Sign in to follow this  
hksduhksdu

How to draw Irregular form?

Recommended Posts

Hello, I have an irregular form, according to glDrawElements(), I don't know how to make up the index list. I cannot show a diagram here but in many cases, a loft object will have irregular form that I cannot divide them into normal triangle like a square, then how do I divide them? How do I arrange the indices so I can draw it with glDrawElements()? Andy

Share this post


Link to post
Share on other sites
Sorry about the confusion.

I am writing an AliasWaveFront .obj loader, which contains a list of vertices and faces. I load from the file without a problem but then I don't know how to use the faces to render the triangles. For example, I created an irregular shape with 8 vertices, in the face reference it shows me only the 8 vertices but it doesn't tell me the order of triangles. So is there any formula to triangulate a shape without even knowing what shape is it?

Thanks in advance,

Andy

Share this post


Link to post
Share on other sites
the order of the triangles doesn't matter unless you are using fans or tri-strips. to figure out the ordering for fans or tri-strips you'll want to do an offline conversion of the .obj format into a custom format that gives you ordering information. you'll then procedurally convert every .obj model into your custom format during which time you'll figure out which triangles can be concatenaded into fans or strips. but for starters just draw the tris in the order you get them from the .obj file.

-me

Share this post


Link to post
Share on other sites
The order does matter, especially for back/front face culling.
I suggest you reading Maya's docs, to see the correct order (you might be lucky and render them in the order they are in the file).
[edit]
A face should have ONLY 3 vertices. if it has 8, then something is very wrong, and there is no way t fix that.
But, IIRC, the obj format has only 3 vertices/face.

Share this post


Link to post
Share on other sites
the order of the triangles certainly does not matter which is what i said. the order of the vertices does matter, however, in that you are correct :). i'd just go with the order it is in the file. if you have back-face culling turned on and you got the order backwards, then you'll see the inside of the back facing triangles. in that case just reverse the winding and you're good to go.

-me

Share this post


Link to post
Share on other sites
Thank you for your replies. I appreciate that.

A face contains 8 vertices is before my friend uses Maya to draw a cube first, then add points on edges on one face, modify the points and make it an irregular shape face. In the game engine Irrlicht, his source code seems like that he's using draw3DLine to connect all points on one face in order, fill that as a polygon. But this way is very inefficient.

All I know are too solutions:

1. Tell the modeling guy to make them all real mesh, that will make them all squres on faces, so I can divide them easily.

2. Connect all points on one face in sequence the .obj provides and fill it as a polygon.

Is there any other way? Thank you very much.

PS: I found that Irrlicht engine is still using glDrawElements to draw all triangles by using the indices. That means he's just using normal way to draw the polygons. Then how does he know the way that 8 vertices form?

Andy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this