Light positioning

Light positioning

Post by Gernot Frisc » Sat, 28 Jun 2003 17:53:13



Hi,

I'm doing a gluLookAt and then:

PushMatrix
   PrepareMatrix
   DrawObject
PopMatrix

Now, how can I position & rotate a light, so that it behaves like
"DrawObject"?
I tried PrepareMatrix before the ligh calls, but the light position is
always somewhat relaitve to the camera poisition...

Thank you,
-Gernot

In order to reply, revert my forename.

------------------------------
DiNGS Game Basic + ClipChap
http://www.Dream-D-Sign.de

 
 
 

1. Problem with lighting and light position

Hi,

I've my code that seems like that:

void renderScene()
{
    GLfloat lightPosition[] = { 10.0f, 15.0f, 10.0f, 1.0f };

    ...

    glPushMatrix();

    glTranslatef(0.0f, 0.0f, -zoom);

    glLightfv(GL_LIGHT1, GL_LIGHT_POSITON, lighPosition);

    glRotatef( rotX, 1.0f, 0.0f, 0.0f );
    glRotatef( rotY, 0.0f, 1.0f, 0.0f );

    DrawObjects(...);

    glPopMatrix();

    ...

My problem is when zoom is lower than lightPosition[2], (when the "camera"
is placed nearer to the object than the light),
it seems as if the light is suddenly setting on the opposite of its actual
position. It lights my objects from the bottom-rear-left instead
of upper-front-right. This change seems to occur only when  zoom is lower to
lightPosition[2].

I think i may have misunderstood the way openGL is positionning light.

I've tried to reproduce this effect in the Nate's Robin Tutors programs but
with no results.

Normals seems to be correct and lighting is enabled ;)

Thanks for help

Cdric,
France

2. Tricky!

3. Light Position & OpenGL

4. Wanted: Technical Pro Who Wants to Grow

5. Skytracer will not accept light position.

6. THE BEST 3DSMAX SITE!!!!!!!!!!!!!!!

7. Fixing light position

8. need linux/unix tool for 3d vis

9. lighting positioning

10. Light Position Problem

11. Light positioning...

12. newbie: light position and rotation

13. Light positioning question