Example #1
0
 def __init__(self, start=(0,0,0), end=(0,0,-1), np=2):
     if np < 2:
         raise AttributeError("The minimum value of np is 2 (one segment)")
     start = vector(start)
     end = vector(end)
     vline = (end-start)/(np-1)
     self.pos = []
     for i in range(np):
         self.pos.append(start + i*vline)
     self.up = (0,1,0)
Example #2
0
def convert(pos=(0,0,0), up=(0,1,0), points=None, closed=True):
        pos = vector(pos)
        up = norm(vector(up))
        up0 = vector(0,1,0)
        angle = acos(up.dot(up0))
        reorient = (angle > 0.0)
        axis = up0.cross(up)
        pts = []
        for pt in points:
            newpt = vector(pt[0],0,-pt[1])
            if reorient: newpt = newpt.rotate(angle=angle, axis=axis)
            pts.append(pos+newpt)
        if closed and (pts[-1] != pts[0]): pts.append(pts[0])
        return pts
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 )