damn lights

hi everybody,
i have a little problem with openGL lights: I am working on a flight simulator, and i wanted to add lights to my project. So i set up lights, enabled lighting, carculated normals but…
But when i move the camera fwd and bkw or i rotate on myself, the lighting on many surfaces suddendly changes from lit to unlit. How can i correct that? I am almost sure that i always put the light in the same position, so no coord transformation happens from a frame to another. I hope i was able to explain the problem, any help will be very appreciated… (i may even thank u on my graduation thesis ). Bye to all The Gunslinger

You’ll probably have to give more info. Show some code.

ok here is some code:

this is in my main:

void display ()
{

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();



//******* Update pilot view ******

g_Camera.hdg=plane.heading;
g_Camera.pitch=plane.pitch;
g_Camera.roll=plane.roll;

setposition ();

g_Camera.PositionCamera(plane.xpos,plane.altitude,plane.zpos);

glPushMatrix();
glLoadIdentity();
GLfloat light_position[4]={0.3,-1.0,-0.3,0.0};
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
glPopMatrix();

if (opt_mappa)
	g_World.Update(plane.xpos,plane.zpos);

//************ Frustum Calculation *******

g_Frustum.CalculateFrustum();

//************ Terrain Drawing ********

glPushMatrix();
RenderScenery();
glPopMatrix();

g_World.RenderLand();	

plane.radarAltitude=g_World.ReturnAltitude(plane.xpos,plane.altitude,plane.zpos);

//************ 3D aircraft display (only in ext camera mode) ********

	setOrthographicProjection();
glPushMatrix();
glLoadIdentity();
renderTextHUD(plane.speed,plane.altitude,plane.radarAltitude,g_Camera.azimuth,g_Camera.tilt,g_Camera.zoom,g_Camera.cameraView);
renderHUDLines(plane.heading,plane.pitch,plane.roll);
glPopMatrix();
resetPerspectiveProjection();

glutSwapBuffers();
glutPostRedisplay();

}

here is my light setup:
//************* Light Setup *******************
GLfloat light_ambient[4]={0.5,0.5,0.5,1.0};
GLfloat light_diffuse[4]={0.3,0.3,0.3,1.0};
// GLfloat light_specular[4]={1.0,1.0,1.0,1.0};
GLfloat light_position[4]={0.3,-1.0,-0.3,0.0};

glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);

// glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
// glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_FALSE);

glEnable(GL_LIGHTING);

glEnable(GL_LIGHT0);

glClearColor (0.2f,0.7f,1.0f,1.0f);

and this is the hangar with the lights changing with the camera orientation:

void RenderHangar()
{
CVector3 normal;

glColor3f(0.6,0.6,0.6);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_concrete);

normal=NormalV(0,0,0, 75,0,0, 75,15,20);

glBegin(GL_QUADS);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,0,0);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (75,0,0);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (75,15,20);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,15,20);
glEnd();


normal.x=-1;
normal.y=0;
normal.z=0;
glBegin(GL_QUADS);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,0,0);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,15,20);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,15,80);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,0,100);
glEnd();  


normal=NormalV(0,0,100, 0,15,80, 75,15,80);

// glColor3f(0.6,0.6,0.6);
glBegin(GL_QUADS);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (0,0,100);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (0,15,80);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (75,15,80);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (75,0,100);
glEnd();

// normal=NormalV(75,0,100, 75,15,80, 75,15,20);
normal.x=-1;
normal.y=0;
normal.z=0;
glBegin(GL_QUADS);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (75,0,100);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (75,15,80);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (75,15,20);
glNormal3f(normal.x,normal.y,normal.z);
glVertex3f (75,0,0);
glEnd();

// glColor3f(0.8,0.8,0.8);

normal=NormalV(0,15,20, 75,15,20, 75,15,80);
glBegin(GL_QUADS);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,15,20);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (75,15,20);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (75,15,80);
	glNormal3f(normal.x,normal.y,normal.z);
	glVertex3f (0,15,80);
glEnd();
glColor3f(1.0,1.0,1.0);	

}

that’s all. i hope it is clearer. bye, the Gunslinger

If it is the hangar you are having problems with, it is probably the lack of vertices. OpenGL calculates lighting per vertex and interpolates between the vertices. However, if the light does not hit a vertex then the lighting will not be calculated. To correct this you should make your large quad out of several smaller quads.

ok i will try that way. Thanks for the advice, the Gunslinger

Also, try adding

glMateriali( GL_FRONT, GL_SHININESS, 128 );