Unable to set a headlight (flashlight)

Hello, I’m having trouble when trying to set a light from the camera’s point of view. I set the light only once at the initialization of the window, after the OpenGL rendering context is set with these parameters:

float ambient={ 0.1, 0.1, 0.1, 1.0};
float difusse={ 1.0, 1.0, 1.0, 1.0};
float shininess={ 1.0, 1.0, 1.0, 1.0};
float position={ 0.0, 0.0, 1.0, 0.0}; /w==0 direction/

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

glLightfv(GL_LIGHT0,GL_AMBIENT,ambient);
glLightfv(GL_LIGHT0,GL_DIFFUSE,difusse);
glLightfv(GL_LIGHT0,GL_SHININESS,shininess);

glLightfv(GL_LIGHT0,GL_POSITION,position);

After that, I change the point of view with

gluLookAt(1000,1000,-1000,0,0,0,0,1,0);

Then I draw an horizontal plane and, after, an starship. The final render is:

Note that all the polygons are shaded with the same color, although they have different normal vectors. Changing the direction to

float position={ 0.0, 0.0, -1.0, 0.0};

leads to a weird representation where only exists a color:

If I set instead the light direction to

float position={ 1.0, 0.0, 0.0, 0.0};

the scene is correctly rendered, with the light coming from the right (positive X axis):

It also works correctly with the Y axis. I don’t know why it just doesn’t work with the Z axis, can anynone tell me?

Thanks in advance for your replies.

[This message has been edited by Azdo (edited 09-29-2002).]

Well, I updated the image links so they work now.

How have you setup your normals?

Also your matrial settings?

Originally posted by Azdo:
Well, I updated the image links so they work now.

Originally posted by nexusone:
[b]How have you setup your normals?

Also your matrial settings?

[/b]

I think he normals and the materials are fine as shown in the last picture, when the light comes from the right. It’s the light direction what matters.

Anyway, I’m setting the normals per-polygon (using the normal vector to the polygon). When I get home, I’ll post the material initialization code.

Azdo

[This message has been edited by Azdo (edited 10-02-2002).]