def __init__(self, **keywords): cvisual.display_kernel.__init__(self) self._window_initialized = False self.N = -1 self.material = materials.diffuse # If visible is set before width (say), can get error "can't change window". # So deal with visible attribute separately. vis = None if 'visible' in keywords: visible = keywords['visible'] del keywords['visible'] keys = list(keywords.keys()) keys.sort() for kw in keys: setattr(self, kw, keywords[kw]) if vis is not None: setattr(self, 'visible', vis) if 'ambient' not in keywords: self.ambient = (0.2,0.2,0.2) self._leftdown = self._rightdown = 0 self._cursorx = 0 self._cursory = 0 self._spinning = False cvisual.display_kernel.set_selected(self) if 'lights' not in keywords: distant_light( direction=(0.22, 0.44, 0.88), color=(0.8,0.8,0.8) ) distant_light( direction=(-0.88, -0.22, -.44), color=(0.3,0.3,0.3) )
def _set_lights(self, n_lights): old_lights = self._get_lights() for lt in old_lights: lt.visible = False if (type(n_lights) is not list) and (type(n_lights) is not tuple): n_lights = [n_lights] # handles case of scene.lights = single light for lt in n_lights: if isinstance( lt, cvisual.light ): #< TODO: should this be allowed? lt.display = self lt.visible = True else: lum = cvisual.vector(lt).mag distant_light( direction=cvisual.vector(lt).norm(), color=(lum,lum,lum), display=self )