I have a problem with ligthing. In the picture below, the arms and legs of the robot are drawn with the same code as the center pole. But for some
reason, the lighting just works on the center pole. Does someone know whats going on??
[ATTACH=CONFIG]412[/ATTACH]
This is my display function******
def display():
global RobotSwingAngle
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT) #Clear the buffer that stores color information.
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glPushMatrix()
glPushMatrix()
#Scale the axis
glScalef(50,50,50)
#X is Red
#Y is Green
#Z is Blue
axis()
glScalef(.04,.04,.04)
glTranslated(0,28,30)
glRotated(-90,1,0,0)
glRotated(-90,0,1,0)
glColor3f(1,0,0) # the default color is red
global CubicSurfaceControlPointList
global StopFlagWaving
if StopFlagWaving == False:
#Make the flag wave
CubicSurfaceControlPointList[0][3] = 10*sin(FlagWaving)
CubicSurfaceControlPointList[1][3] = 10*sin(FlagWaving)
CubicSurfaceControlPointList[2][3] = 10*sin(FlagWaving)
CubicSurfaceControlPointList[3][3] = 10*sin(FlagWaving)
CubicSurfaceControlPointList[4][3] = 10*cos(FlagWaving)
CubicSurfaceControlPointList[5][3] = 10*cos(FlagWaving)
CubicSurfaceControlPointList[6][3] = 10*cos(FlagWaving)
CubicSurfaceControlPointList[7][3] = 10*cos(FlagWaving)
CubicSurfaceControlPointListCOPY = copy.deepcopy(CubicSurfaceControlPointList)
ComputeCubicSurfacePointList(CubicSurfaceControlPointList)
CubicSurfaceControlPointList = CubicSurfaceControlPointListCOPY
glBegin(GL_TRIANGLES)
for k in range(0,len(CubicSurfacePointList),1):
if CubicSurfacePointList[k][0] == 'f':
p = CubicSurfacePointList[k][1]
x0 = float(CubicSurfacePointList[int(p)-1][1])
y0 = float(CubicSurfacePointList[int(p)-1][2])
z0 = float(CubicSurfacePointList[int(p)-1][3])
p = CubicSurfacePointList[k][2]
x1 = float(CubicSurfacePointList[int(p)-1][1])
y1 = float(CubicSurfacePointList[int(p)-1][2])
z1 = float(CubicSurfacePointList[int(p)-1][3])
p = CubicSurfacePointList[k][3]
x2 = float(CubicSurfacePointList[int(p)-1][1])
y2 = float(CubicSurfacePointList[int(p)-1][2])
z2 = float(CubicSurfacePointList[int(p)-1][3])
drawFace(x2,y2,z2, x1,y1,z1, x0,y0,z0)
glEnd()
glPopMatrix()
DrawFloor(150.0,150.0)
#The pole is drawn in the z axis
glPushMatrix()
glColor(.5,.5,1)
glRotated(-90,1,0,0)
DrawCenterPole()
glPopMatrix()
#glCallList(1) => Paralellogram
#glCallList(2) => Cylinder
#glCallList(3) => Sphere
glRotated(RobotRotationAngle,0,1,0)
#glCallList(1)
#The robot will be draw to respect to its torso
glTranslated(100,40.0,0.0)
glPushMatrix()
#Scale the robot
glScalef(40,40,40)
#Draw Robot's Torso
glColor(.5,.5,.1)
glCallList(1)
#Draw Robot's Head
glPushMatrix()
glColor(0,0,1)
glTranslated(0.0,.8,0.0)
#glCallList(3)
glutSolidSphere(.3,20,20)
glPopMatrix()
#Draw Robot's Right Arm
glPushMatrix()
glColor(0,1.0,0)
glRotated(90,1,0,0)
#Make the arm swing
glTranslated(0.3,0,-.4)
glRotated(80*cos(RobotSwingAngle),1,0,0)
glCallList(2)
glPopMatrix()
#Draw Robot's Left Arm
glPushMatrix()
glColor(0,1,1)
glRotated(90,1,0,0)
#Make the arm swing
glTranslated(-0.3,0,-.4)
glRotated(-80*cos(RobotSwingAngle),1,0,0)
glCallList(2)
glPopMatrix()
#Draw Robot's Right leg
glPushMatrix()
glColor(1,0,0)
glRotated(90,1,0,0)
#Make the arm swing
glTranslated(0.3,0,.4)
glRotated(-80*cos(RobotSwingAngle),1,0,0)
glCallList(2)
glPopMatrix()
#Draw Robot's Left leg
glPushMatrix()
glColor(1,0,1)
glRotated(90,1,0,0)
#Make the arm swing
glTranslated(-0.3,0,.4)
glRotated(80*cos(RobotSwingAngle),1,0,0)
glCallList(2)
glPopMatrix()
glPopMatrix()
glPopMatrix()
DisplayCam()
glFlush() #Flush
#empties all of these buffers, causing all issued commands to
#be executed as quickly as they are accepted by the actual rendering engine
glutSwapBuffers() #Draw the frame in one of the buffers and calculate the
#the frame of the other buffer.
**This are the DrawCenterPole Function and Cylinder function
def DrawCenterPole():
quadric = gluNewQuadric();
gluQuadricTexture(quadric, True)
gluQuadricDrawStyle(quadric, GLU_FILL);
gluCylinder(quadric, 4, 4, 120, 20, 20);
def Cylinder(BaseRadius,TopRadius,Height):
glNewList(2,GL_COMPILE)
quadric = gluNewQuadric();
gluQuadricDrawStyle(quadric, GLU_FILL);
gluCylinder(quadric, BaseRadius, TopRadius, Height, 20, 20);
glEndList()