Richard Cudd
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Calling the glLight function to re-position the lights every time the
'camera' moves (i.e. after you call gluLookAt) works for me. I'm pretty
new to OpenGL so I don't know if this is the best solution. I'd be
grateful if anyone could add anything to this.
Tim Rennie
Try this:
gluLookAt(camera.elements[0], camera.elements[1], camera.elements[2],
0,0,0, 0,1,0); // look at the origin
glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition); // position light
Calling glLight*() afterwards will correctly reposition the light in the
scene. I had this problem, too, when starting out...
-Mike
--
---- Michael J. Sherman --- Sonalysts, Inc. --- Software developer ----
--- mshe...@sonalysts.com --- http://members.tripod.com/~msherman/ ---
> I'm using gluLookAt to move around a scene I've created. The problem is that
> the lights in my scene seem to move as I move my position with gluLookAt. I
> thought that lights would be transformed in the same way as objects but none
> of the objects in the scene are changing position, it's just the lights. Any
> ideas ? Cheers,
>
> Richard Cudd
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Hi
Just a wild guess. I think you may have specified the lights relative to
the model view matrix. If you want the light to fixed with respect to
the screen, you have to specify it after you specify the model view
matrix.
hope this helps
ram
--
Ramanath Padmanabhan
Phone (Office) : 874-8245
(Res ) : 779-4146
Sorry. There was a error in what I said. What I meant was
if u specify the light source with respect to model view matrix,
then the light moves when u zoom,pane,rotate etc.
So normally, light sources are specified immediately after
projection matrix. Sorry I typed the response wrong in the
previous post.
ram
rc...@my-dejanews.com wrote:
>
> I'm using gluLookAt to move around a scene I've created. The problem is that
> the lights in my scene seem to move as I move my position with gluLookAt. I
> thought that lights would be transformed in the same way as objects but none
> of the objects in the scene are changing position, it's just the lights. Any
> ideas ? Cheers,
>
> Richard Cudd
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
"My light moves" or "my light doesn't move" are both kind of ambiguous
statements. It's best to think of the light's position as staying fixed with
respect to the camera, or staying fixed with respect to the scene. To
further complicate things, you can also have lights that move with respect
to both the camera and the scene.
To fix a light's position with respect to the camera, you normally specify
the light position with an identity modelview matrix.
To fix a light's position with respect to the scene, the modelview matrix
should contain the same transforms as used to position the scene elements;
then specify the light position.
To make a light move relative to both the camera and the scene, the light
needs its own unique transform loaded into the modelview matrix.
It is a lot easier to think of the light position as if you were rendering a
point primitive, and the light position parameters are as if you were
calling glVertex4f to specify the point position.
I hope this helps.
-Paul Martz
Hewlett Packard Workstation Systems Lab
To reply, remove "DONTSPAM" from email address.
Ramanath Padmanabhan wrote in message <364B9D65...@krdl.org.sg>...