PDA

View Full Version : lighting



Fred F
08-16-2008, 12:54 PM
I am trying to write the following code so which is part of a robot that has a flashlight pointing forward. When I rotate the robot I want the flashlight to point in the direction the robot is facing. When I turn right it works great but when I turn left the light does not point forward.
Anyone have any suggestion on how I can fix this.


glPushMatrix();
glTranslatef(0.3f,1.0,-0.05f);
GLUquadricObj* Rarm=gluNewQuadric();
gluQuadricNormals(Rarm,GLU_SMOOTH);
gluCylinder(Rarm,0.1,0.1,0.8,20,20);
glTranslatef(0.0,-0.2,0.8);
float pos[4]={0.0,0.0,0.0,1.0};
glLightfv(GL_LIGHT1, GL_POSITION, pos);