Determining front-facing vertex order

Okay, I’m working on a modeling program and everything is working great. It will be just for creating CEL-shaded models.

The modeler doesn’t really have to determine front-facing polygons inside of it, because I just render both sides (CW & CCW). However, anyone who has done CEL-shading knows it is very important when rendering. So I need a way of determining what vertex order to make facets that a user is creating. Any ideas or good web sites?

The best idea I had was to make a “skeleton” of vertices that every facet is facing away from. And then when a facet is created, it is just attached to a “bone”. But that is giving me some added problems.

Hope this makes sense!
Thanks in advance…

Jeff

Imagine this:

|\B/|
|-B-|

where B denotes the bone axis.
(ok, imagine it a little less crude, might be a cowboy’s hat or something)

It may be perfectly valid for a user to create triangles where in a solid model the direction facing toward the bone is still the frontface. You should just force the job of selecting the correct winding on the user. All el-cheapo-for-free modelers do this - haven’t seen any pro modelers.

Alternatively, you could start with a face that has the ‘right’ winding (user input still required here) and recursively adjust the winding on all faces that share an edge with this one.

If you have two triangles A and B and they share an edge, triangle B should ‘run down’ the edge in the opposite direction of triangle A.

If the user screws up the winding on the reference face, you should
a)include an option to render with backface culling
b)include an option to reverse the winding on all faces

PS: excuse my ignorance, but what is CEL-shading?

Originally posted by zeckensack:
PS: excuse my ignorance, but what is CEL-shading? [/b]

CEL-shading is a method of rendering in OpenGL that makes a model look like a cartoon. Take a look at NeHe’s OpenGL tutorials (#36 I think) – there is a decent one on CEL-shading.

The polygon facing is important to render “outlines” of the model using glPolygonMode(GL_LINE) on back facing polygons only.

Jeff