View Full Version : Lighting

07-28-2001, 08:36 AM
I got a problem with lighting - i wanna move the light around the z axis. I got the translation and in the VC++ Debugger everything looks ok - then i update the position by calling glLight* and nothing happens the light anyway comes from the original direction and location.

i got the light at X: 450, Y 750 and z -750 and the rotation is okay, but no result is seen.
do i have to disable lighting to move it ? or is it the 0.0f in the last param ??

i enclose my draw function part..

// rotate the light along the z axis

GLfloat lightx = -450.0f;
GLfloat lighty = -750.0f;
GLfloat lightz = 750.0f;

LightPosition[0] = (lightx*cos(clock*PII))-(lighty*sin(clock*PII));
LightPosition[1] = (lightx*sin(clock*PII))+(lighty*cos(clock*PII));
LightPosition[2] = lightz;
LightPosition[3] = 0.0f;
glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);

thanks for help.

07-28-2001, 09:00 AM
When you use 0 for the w component of a light's position, that makes the light a non-positional light. The "position" then just describes the direction the light comes from a point light source that is infinitely far away. However given the numbers you've used, I'm surprised you don't see any changes at all. Then again, the changes seen would depend upon the geometry being lit, and the properties of the light. For example, perhaps your ambient term is swamping the diffuse term. Also check your clock and PII values to see that they are correct. Also ensure that you have GL_LIGHT1 enabled in addition to GL_LIGHTING.

07-28-2001, 09:15 AM
The rotated x, y values are correct - i just update the position
clock got a float and i add every frame 1.0f to it
and PII ist defines to be 3.141592 / 180.0f

i change my lightsource to a positional one moment - and it did not made anything different...

07-28-2001, 09:18 AM
GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat LightDiffuse[]= { 0.9f, 0.9f, 0.9f, 1.0f };

is something wrong with this.

my geometry got verctor normals...

07-28-2001, 10:03 AM
Try also set the light direction.
Or try divide lightx,lighty and lighty
by 100.

[This message has been edited by FoxDie (edited 07-28-2001).]

07-28-2001, 10:08 AM
My normals was the problem - they where not correctly imported... good to learn from misstakes :-)

thanky you!