def set_light(self): glLightfv(GL_LIGHT0, GL_POSITION, vec(*self.position)) if self.specular != None: glLightfv(GL_LIGHT0, GL_SPECULAR, vec(*self.specular)) if self.ambient != None: glLightfv(GL_LIGHT0, GL_AMBIENT, vec(*self.ambient)) if self.diffuse != None: glLightfv(GL_LIGHT0, GL_DIFFUSE, vec(*self.diffuse))
def set_material(self): if self.diffuse !=None: glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,vec(*self.diffuse)) if self.specular !=None: glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR, vec(*self.specular)) if self.emissive != None: glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION,vec(*self.emissive)) if self.shininess !=None: glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS, self.shininess)
def set_state(self): glEnable(GL_DEPTH_TEST) glEnable(GL_CULL_FACE) #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) glLineWidth(3.) glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) glEnable(GL_LIGHT1) #Define a simple function to create ctypes arrays of floats: glLightfv(GL_LIGHT0, GL_POSITION, vec(.0, .0, 1, 1)) glLightfv(GL_LIGHT0, GL_SPECULAR, vec(.5, .5, 1, 1)) glLightfv(GL_LIGHT0, GL_DIFFUSE, vec(1, 1, 1, 1)) glLightfv(GL_LIGHT1, GL_POSITION, vec(1, 0, .5, 0)) glLightfv(GL_LIGHT1, GL_DIFFUSE, vec(.5, .0, 0, 1)) glLightfv(GL_LIGHT1, GL_SPECULAR, vec(1, 0, 0, 1)) glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,vec(0.9, 0, 0.3, 1.)) glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR, vec(1, 1, 1, 1.)) glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS, 50)