Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: light: Lighting moves with camera

  1. #1
    Intern Contributor
    Join Date
    Nov 2002
    Posts
    96

    light: Lighting moves with camera

    In my scene the light keeps moving with the camera. I don't really want this (rather useless really) and I'd like my lighting to be on a fixed position in the scene. How can I accomplish this?

    I set the light properties in the init of the scene and use GLUlookat to set my camera view.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,982

    Re: light: Lighting moves with camera

    You have to set the light position after you have set the viewpoint transform.

  3. #3
    Intern Contributor
    Join Date
    Nov 2002
    Posts
    96

    Re: light: Lighting moves with camera

    Originally posted by Bob:
    You have to set the light position after you have set the viewpoint transform.
    TY

    I called glLightFv after the glulookat now in the render function and it seems to work
    But what I'm wondering about is WHY it works... isn't the light position affected by the rotation of the axis system?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,982

    Re: light: Lighting moves with camera

    Yes, the light position is transformed by the modelview matrix.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    King George, Virginia
    Posts
    132

    Re: light: Lighting moves with camera

    i believe all matrix operations happen in the reverse order that you specify, or something like that...

    Code :
    glRotatef(90, 1, 0, 0);
    glTranslatef(10, 0, 0);
    i think the translate will get matrixed (is this a word?!?) in first, then the call to rotate. i'm kinda sketchy on the details but i know i've seen this discussed here before.

    jebus

    [This message has been edited by jebus (edited 11-25-2002).]

  6. #6
    Intern Contributor
    Join Date
    Nov 2002
    Posts
    96

    Re: light: Lighting moves with camera

    I'm 99.9% sure it works now... I had a bit of a blurry moment so I thought that the light SHOULD be affected by the glulookat in another way (monday, morning, hangover, you know the effects).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •