PDA

View Full Version : Light and Translate



vomtung
05-13-2011, 08:40 PM
hello everyone,
when I draw a solidsphere at (1,0,0) and shading it as below

GLfloat lightIntensity[]={0.7f, 0.7f, 0.7f, 1.0f};
GLfloat light_position[]={0.1, 0, 0.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightIntensity);
....
glPushMatrix();
glTranslated(1,0, 0.0); // sphere at (1, 0, 0.0)
glutSolidSphere(0.3, 10, 8);
glPopMatrix();

in this case we have:

origin --> light source(0.1,0,0) --> solidsphere (1,0,0)

i think the left side of solidsphere is lighted, but when i run the program , the right side of solidsphere is lighted

)I think this problem because OpenGL draw solidsphere at (0,0,0) and tranlate in to (1,0,0))
can I solve this problem??

vomtung
05-13-2011, 11:29 PM
ok!. I have just solved this problem. very simple!^^