Example #1
0
 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.
     v = 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 v is not None: setattr(self, 'visible', v)
     if 'ambient' not in keywords:
         self.ambient = (0.2,0.2,0.2)
     self._leftdown = self._rightdown = 0
     self._cursorx = self._cursory = 0
     self._spinning = False
     
     self.select()
     
     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) )
Example #2
0
    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 )
Example #3
0
    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 )
Example #4
0
    def __init__(self, **keywords):
        cvisual.display_kernel.__init__(self)
        self._window_initialized = False
        self.window = None
        self.menus = False
        self.N = -1
        self._lastx = self._lasty = None  # previous mouse position
        self.standard = True  # assume canvas fills the window

        self.material = materials.diffuse
        # If visible is set before width (say), can get error "can't change window".
        # So deal with visible attribute separately.
        v = 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 v is not None: setattr(self, 'visible', v)
        if 'ambient' not in keywords:
            self.ambient = (0.2, 0.2, 0.2)
        if self.window is not None:
            self.standard = False
            self.win = self.window.win
            self.panel = self.window.panel

        self._mt = _mouseTracker()
        self._captured = 0
        self._cursorx = self._cursory = 0

        self.select()

        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))

        self._bindings = {}
        self._waiting = []
        self.keyboard = eventInfo()
        self.kb = kb()

        if self.window is not None:
            self._activate(True)
Example #5
0
    def __init__(self, **keywords):
        cvisual.display_kernel.__init__(self)
        self._window_initialized = False
        self.window = None
        self.menus = False
        self.N = -1
        self._lastx = self._lasty = None # previous mouse position
        self.standard = True # assume canvas fills the window
        
        self.material = materials.diffuse
        # If visible is set before width (say), can get error "can't change window".
        # So deal with visible attribute separately.
        v = 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 v is not None: setattr(self, 'visible', v)
        if 'ambient' not in keywords:
            self.ambient = (0.2,0.2,0.2)
        if self.window is not None:
            self.standard = False
            self.win = self.window.win
            self.panel = self.window.panel
            
        self._mt = _mouseTracker()
        self._captured = 0
        self._cursorx = self._cursory = 0

        self.select()
        
        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) )
            
        self._bindings = {}
        self._waiting = []
        self.keyboard = eventInfo()
        self.kb = kb()

        if self.window is not None:
            self._activate(True)