Advertisement

Lighting

Started by October 26, 2000 03:42 AM
8 comments, last by Pete Bassett 24 years ago
Hi... I have a plane and a gluSphere resting on that plain. There is lighting in the scene care of NeHe tutorial 7. However, when I rotate the scene I would like the light (LIGHT_1) to be rotated as well. At the moment the light always come from behind the viewer (Comes from the screen). Any Idea how I could make this little mod? Thanks Pete
reposition the light everytime after u position the camera

http://members.xoom.com/myBollux

Edited by - zedzeek on October 26, 2000 6:05:43 AM
Advertisement
Hi. Thanks for posting.

YEah but how do I do that. glRotate doesn''t affect the lights as afr as I can tell. Do I have to just call

glLightfv(GL_LIGHT1, GL_POSITION, LightPosition * Rotation);

Or what? Help.

Pete
i think you have to change the light position array and call GLlight again?
Well, never tried to use glPushMatrix()?
/asm0
Hi again.

I know its a pain but someone is gogin to have to talk me through this.

RealityMonster : Will just positioning the light again do it?

asm0 : Ok, glPushMatrix stores the current matrix for use later. How does this helps me.

What I need is for the light in my scene to be rotated with the scene so the objects are always lit from the original side. I want to be able to move around and look at all sides of my textured, lit sphere.

Thanks again.

Advertisement
why dont you try it out
not too much work rite? and if it works pls post a reply coz im curious
changing the array worked for changing the material properties. i think one of the colored books red/blue explains lighting quite well. get the links from nehe''s main page
I haven''t played with light, but here is my educated guess.

I assume you have the coordinates from your ''camera'' ( I hesitate to use the word) that you are moving about. Why can''t you just use those same coordinates to reposition the camera in the ''Draw'' function (at the start) every time? Same way you''re using cos, sin, to move your person about use them to move the camera about.

Just my guess.
can tu just rotate the object instead of moving the camera? that way the area you want to see will always be lit if you put a light behind the viewpoint or something
educated guess
gluLookAt( cameraPOS[0],cameraPOS[1],cameraPOS[2],
cameraPOS[0]+cameraDIR[0],cameraPOS[1]+cameraDIR[1],cameraPOS[2]+cameraDIR[2],
0,1,0);
float lightpos[] = {1,1,0,1);
glLightfv(GL_LIGHT0,GL_POSITION,lightpos);

this will simulate a stationary direction light (eg the sun) so no matter where u position the camera the same sides of the building will recieve the sun.
theres no need to rotate anything

http://members.xoom.com/myBollux

This topic is closed to new replies.

Advertisement