PDA

View Full Version : CameraPosition and Lighting ??



SebastianB
02-02-2003, 12:22 AM
hi!

i have a problem that seems to have sth to do with
my camera direction or lighting. my normals are all set
correctly, but when i move my camera direction up, my
polygons get brighter, when moving it down, they darken.

here are my lighting settings:
* * * * * * * * * * * * * * * * * *
float material_ambient[] = {1.0, 1.0, 1.0, 0.0};
float material_diffuse[] = {1.0, 1.0, 1.0, 0.0};
float material_specular[] = {1.0, 1.0, 0.0, 0.0};
float material_emission[] = {0.0, 0.0, 0.0, 0.0};

float ambient_light[] = {0.2, 0.2, 0.2, 0.0};

float light_ambient[] = {0.0, 0.0, 0.0, 0.0};
float light_diffuse[] = {1.0, 1.0, 1.0, 0.0};
float light_specular[] = {0.0, 0.0, 0.0, 0.0};

float light_pos[] = {0.0, 900.0, 0.0, 0.0};
float light_dir[] = {0.0, 100.0, 0.0, 0.0};

glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
glMaterialfv(GL_FRONT, GL_EMISSION, material_emission );
glMaterialfv(GL_FRONT, GL_AMBIENT, material_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, material_specular);
glEnable(GL_COLOR_MATERIAL);

glLightModelfv ( GL_LIGHT_MODEL_AMBIENT, ambient_light );
glLightfv ( GL_LIGHT0, GL_POSITION, light_pos );
glLightfv ( GL_LIGHT0, GL_SPOT_DIRECTION , light_dir );
glLightfv ( GL_LIGHT0, GL_AMBIENT, light_ambient );
glLightfv ( GL_LIGHT0, GL_DIFFUSE, light_diffuse );
glLightfv ( GL_LIGHT0, GL_SPECULAR, light_specular );
glEnable (GL_LIGHT0);
glEnable (GL_LIGHTING);
* * * * * * * * * * * * * * * * * *

and this is how i position my camera:
* * * * * * * * * * * * * * * * * *
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gluLookAt(cam.position.x,
cam.position.y,
cam.position.z,
cam.position.x + cam.direction.x,
cam.position.y + cam.direction.y,
cam.position.z + cam.direction.z,
cam.upVector.x,
cam.upVector.y,
cam.upVector.z);
* * * * * * * * * * * * * * * * * *


does anybody have a clue why the camera-angle affects
the brightness of my polygons? any advice would be very
welcome http://www.opengl.org/discussion_boards/ubb/smile.gif

cheers!
sebastian

bjartej
02-02-2003, 01:28 AM
Try to update the lightposisition after updating the camera

SebastianB
02-02-2003, 01:32 AM
this works. THANK YOU!!

(i updated it BEFORE repositioning the camera, this seems to have been the cause)

http://www.opengl.org/discussion_boards/ubb/smile.gif
seb