i know in order for lighting to work accuratly and look like something that u have to tell opengl were the light is what color and what type of light. gllightf does that. glnormal3f is suppose to determine the direction the light reflects off the object. if i have an object at 0,0,0 and the light is at 0,0,-20. all the surfaces have the light reflecting away from the object. why are all sides eluminated???
if u want i will post the code but its 30 pages.
Either the object's normal are wrongly defined or you're modifying some ogl state before displaying it.
Notice that at the insane of -20, the light is behind the object so the viewer only see it lightened by the ambient one.
well even thou i do admit to the insanity of the -20. i think that was another program i had thought about. but after checking its 10.
im not sure what u ment about 1. all the surface has a glnormal3f that reflects light away from the objet so over all the back side of the object reflects light down the negative z axis. the front face reflects light along the positive z axis and i do understand that the glnormal3f uses vectors.
I'm not sure to get what you mean when you say that all faces are illuminated, are they like all white without any kind of shading ?
Maybe you should post the part where you display the object & the one where you create the light source (+ the relevant datas).
go to
hometown.aol.com\bloodycyborge\opengl.exe (http://hometown.aol.com\bloodycyborge\opengl.exe)
I still don't see the problem, what do you want to achieve exactly or what are you expecting ?
for the mopst part that if i create a light at 0,0,-10 for the back side of the object to be illuminated not all sides as i walk around the object
(edit)
LightPosition(0) = 0
LightPosition(1) = 0
LightPosition(2) = 10
LightPosition(3) = 0
LightDiffuse(0) = 1
LightDiffuse(1) = 1
LightDiffuse(2) = 1
LightDiffuse(3) = 0
glLightfv GL_LIGHT0, GL_POSITION, LightPosition(0)
glLightfv GL_LIGHT0, GL_DIFFUSE, LightDiffuse(0)
glEnable GL_LIGHT0
This is what i see when i run your program, so if you're light is positioned at 0,0,10 this is perfectly normal.
(http://perso.wanadoo.fr/franck.charlet/test.JPG)
Unless you're trying to tell me that you would like the light to rotate with the object ?
i dont want the light to move with u. i want the light to stay stationary with the object
If you want the light to rotate with the object just set the GL_POSITION after you rotate the matrix, like for example:
invoke glTranslatef, CFLT(0.0), CFLT(0.0), CFLT(-4.0)
invoke glRotatef, RotX, CFLT(0.0), CFLT(1.0), CFLT(0.0)
invoke glRotatef, RotY, CFLT(1.0), CFLT(0.0), CFLT(0.0)
invoke glRotatef, RotZ, CFLT(0.0), CFLT(0.0), CFLT(1.0)
invoke glLightfv, GL_LIGHT0, GL_POSITION, addr Light_Position
This will rotate the light too.
how about if im not using the glrotate functions
im using the gllookat functions
It should be the same as gluLookAt is glMulMatrixf + glTranslated so it operates on the modelview matrix aswell.