Having some problem with negative scale values and normals

For example. I have an object that is scaled {-1,0,0}. Mirrored on the x axis, basically.

The gl code would kinda look like:

glScale(-1,0,0)
glNormal3fv(x,y,z)
draw_face()
glNormal3fv(x,y,z)
draw_face()

(x,y,z) is the computed normal of the untranslated face.

Of course, this doesn’t work because all the normals are still reversed. Does the gl system not apply the current matrix to the glNormal call? Or maybe I just don’t know what I’m doing (more likely).

I’m going to need to handle gluTessNormal stuff too, I’m wondering if it does or does not translate the normals by the current matrix.

I guess my question boils down to: Should I be calculating the normal based on the translated or untranslated version of the face?

Thanks for any info!

I should add…

If I reverse the order in which I draw each face. It almost works. I can see the faces normally, but the lighting is reversed. It’s dark on the side I’m looking at (which is normally light) and light on the backside.

Ohwell, off to pound my head some more…

Originally posted by Super-K:

glScale(-1,0,0)

This should be glScale (-1, 1, 1) !!!

HTH

Jean-Marc

Here is a quote which might help you some:

"Any modelview scaling that occurs is likely to mess up OpenGL’s lighting equations. Remember, the lighting equations assume that normals have a length of 1.0. The symptom of incorrectly scaled normals is that the lit surfaces appear too dim or too bright depending on whether the normals enlarged or shrunk.

The simplest way to avoid this pitfall is by calling:

glEnable(GL_NORMALIZE);"

I took that from http://www.opengl.org/developers/code/features/KilgardTechniques/oglpitfall/oglpitfall.html

Hope it helps.
-lost hope

Thanks! That helped.

I had to go through everything by hand and make sure it was 100% correct. I was reversing the draw order (to invert the normals) but when I was calculating the draw normal I was inverting it again. It would then get inverted by the model matrix (negative scale) before being drawn. Ugh, or something like that, the lighting calculations had backwards normals.