Results 1 to 6 of 6

Thread: light: Lighting moves with camera

  1. #1
    Member 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,978

    Re: light: Lighting moves with camera

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

  3. #3
    Member 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,978

    Re: light: Lighting moves with camera

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

  5. #5
    Senior 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
    Member 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).

Similar Threads

  1. Camera moves in wrong direction?
    By Midnightas in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-13-2018, 01:46 PM
  2. Replies: 0
    Last Post: 05-01-2018, 05:53 AM
  3. Positioned light moves when using quads
    By azess in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-18-2011, 10:10 AM
  4. Math is correct, but camera moves away!
    By hmb104 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-31-2011, 09:22 AM
  5. Why does a line slant when the camera moves
    By geohoffman49431 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-12-2004, 11:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean