thanks, however I still have the problem: depending on the eye position surface is lighter or darker, this is the effect I don’t understand.
I render object so:
gl.glPushMatrix();
gl.glTranslatef(sc.x, sc.y, sc.z);
gl.glRotatef(sc.yaw, 0, 0, 1);
gl.glScalef(sc.dx, sc.dy, sc.dz);
gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, ambiSC);
gl.glCallList(box);
gl.glPopMatrix();
box is a display list, with a unit box(I wonder if normals are transformed appropriately), and lights are:
gl.glEnable(GL.GL_NORMALIZE);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glShadeModel(GL.GL_FLAT);
gl.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, FloatBuffer.wrap(new float[] {.6f, .6f, .6f, .6f}));
gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, FloatBuffer.wrap(new float[] { 1f, 1f, 1f, 0f}));
gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, FloatBuffer.wrap(new float[] { 1f, 1f, 1f, 0f}));
gl.glEnable(GL.GL_LIGHTING);
gl.glEnable(GL.GL_LIGHT1);
I set location of eye so:
Point3d center = mouseBehaviour.getCenter();
Point3d location = mouseBehaviour.getLocation();
Vector3d up = mouseBehaviour.calculateUpVector(location, center);
glu.gluLookAt(location.x, location.y, location.z, center.x, center.y, center.z, up.x, up.y, up.z);