Inward-pointing Normal Vector?

Hi,

I know this is weird. I have some problem with the direction of the normal. I know it should be pointing outward; however, when I try to disply a 3D unit cube made of 6 polygons, for each polygon, I have to set the normal to point toward the inside of the cube to get the proper color. Otherwise, if I use the regular outward-pointing normals, everything is black. I am assuming the x-y-z coordinate is a right-hand coordinate system, with positive x point to the right hand side of the screen, positive y point upward and positive z pointing out the screen; also, I am specifying the vertices in a counter clockwise order if looking from the outside.

I am using JOGL. And here are what I did:

  1. Enable depth test;
  2. Enable lighting;
  3. Enable light0;
  4. Set light properties (ambient, etc);
  5. Set the material properties;
  6. Enable GL_NORMALIZE;

I didn’t touch either the projection matrix or the modalview matrix.

Any one has any idea how this could be?

Thank you,
wt

Could you post a test case?

Thank you for your help. I am attaching my code with this post (it’s very short, just enough code to display a unit cube). Look at the method drawUnitCube for 2 sets of quads method calls which have opposite normals. If you run the program, with the outward-pointing normal, the cube is rendered in black; while with the inward-pointing normal, the cube is displayed in the purple color that is set through the material properties.

  1. Try to comment GL_NORMALIZE
  2. Or try to move light in some different position.
  3. Don’t know :wink:

The problem is that you’re not initializing the modelview and projection matrices, which I believe both default to the identity matrices. In effect this means that the camera is inside the cube. I’ve attached a modified version of your test case (which works with the JOGL nightly build) which shows this. See the initialization code in init().

This code currently expects to find jogl-demos-util.jar on the CLASSPATH; if you run it with the -x option it controls the position of the camera with the ExaminerViewer from the gleem package (in the jogl-demos workspace) providing easy mouse interaction with the scene.

Ken,

I am not seeing your attachment. Could you post it again? Thanks.

Sorry, forgot the attachment the first time.

Works great for me! Thank you soooo much! :smiley: