this is my first post on the forum. I’m currently trying to do a 3D viewing software and I’m new to OpenGL.
I’m currently trying to render Maya|Wavefront objects. Their face orentation vary from one object to another from clockwise to counter-clockwise and it also seems that some have their normal inverted relative to the face orientation (I mean for example that the polygons are ccw oriented but the normal point toward the cw face - this is I think because they come from MAC). Anyway, setting glFrontFace accordingly to the polygon orientation isn’t enough : some objects render correctly others are black (showing their back face) and for some others I see the faces from the inside (inverted normals).
So, what is the way to determine the orientation order of my polygons knowing their normal vector ? And what should I set in the OpenGL engine (glFrontFace or else) to fix this ?
I might have not been clear enough has it was a long explanation, should it be best if I post pictures ?
Thank in advance
There’s two ways to solve your problem. One is quick and dirty but may be acceptable as you’re working on an object viewer and probably don’t have to maintain 70+ FPS. Switch off backface culling. A single call to glDisable(GL_CULL_FACE) will render any face regardless of the orientation.
The other way is to recalculate the winding and normal vectors but I know too little about the mathematical operations involved with this to give you a good answer here. I’m sure there are people online here that know much more than me about this.
[This message has been edited by magichand (edited 01-11-2004).]
A lot modeler apps are too lame to get a consistent winding, especially while exporting meshes.
Maya itself is one of the nicest apps, but who knows on what the .obj files were based upon. I think CAD apps are the worst offenders, e.g. mirrored halves of models inverted etc.
What you need is a mesh cleaning algorithm which starts with a correct face and uses the connecting information to flip winding and normals to the correct order and face.
[This message has been edited by Relic (edited 01-12-2004).]
I think the problem comes from me, not from the mesh objects.
As for the vextexes normal assume they have been created with a left handed coordinate system then there direction is the opposite of my viewer’s one.
What I need to know is how to detect such inverted objects. A real nightmare. I spent the whole morhing on this.