PDA

View Full Version : Winding Challenged



lobstah
07-26-2003, 12:12 PM
Hi,
From what I understand, when vertices of a triangle are supplied, opengl will use the order they are provided in to determine the winding (cw or ccw) of the triangle. How does opengl do this?
The difficulty I'm running into is: I would like to order the vertices of a triangle programmatically in CCW order before passing them to OGL so they won't get culled by OGL. I have triangles that are being culled and leaving triangular holes in my surface.

I've examined past posts and have not come across a similiar problem.

Thanks in advance.

lobstah

mikael_aronsson
07-26-2003, 10:04 PM
Hi !

You use glFrontFace() to select if clockwise or counterclockwise triangles should be front facing, that's all.

Mikael

lobstah
07-27-2003, 01:57 AM
Hi Mikael,

Thanks for taking the time to reply.

The ogl setting is not the solution, unless there's something I'm missing.

I have some triangles that are CW and the remaining are CCW. Those that are CW are being culled when I don't want them culled. So I figure the solution is to arrange the vertices in CCW order before passing to ogl.

My thought was to find out how ogl determines what's CW and CCW, based on vertex ordering, and from the result, say if CW, swap vertex 2 and 3 of the triangle to make it CCW.

mikael_aronsson
07-27-2003, 05:42 AM
Hi !

OpenGL will not rearrange the vertices for you, you have to do that yourself.

You can find the winding order if you have the vertices and the surface normal, if you then calculate the normal yourself it will point in the opposite direction if the winding order is incorrect.

If you don't have a normal for the triangle i don't think you can find the winding order because you don't know in what direction the triangles should be facing anyway, so the winding order will always be correct the triangle will just face the opposite direction then what you where expecting.

Mikael

lobstah
07-27-2003, 06:08 AM
Thank you.

lobstah

[This message has been edited by lobstah (edited 07-28-2003).]