Exemplo n.º 1
0
def flyAlong(path='flypath',upvector=[0.,1.,0.],sleeptime=None):
    """Fly through the scene along the flypath."""
    if type(path) is str:
        path = named(path)
    if not path:
        warning("You have to define a flypath first!")
        return
    if path.nplex() != 2:
        warning("The flypath should be a plex-2 Formex!")
        
    for eye,center in path:
        GD.debug("Eye: %s; Center: %s" % (eye,center))
        GD.canvas.camera.lookAt(eye,center,upvector)
        GD.canvas.display()
        GD.canvas.update()
        image.saveNext()
        if sleeptime is None:
            sleeptime = GD.cfg['draw/flywait']
        sleeptime = float(sleeptime)
        if sleeptime > 0.0:
            sleep(sleeptime)

    GD.canvas.camera.setCenter(*center)
    GD.canvas.camera.setDist(coords.length(center-eye))
    GD.canvas.update()
Exemplo n.º 2
0
def flyAlong(path="flypath", upvector=[0.0, 1.0, 0.0], sleeptime=None):
    """Fly through the current scene along the flypath.

    - `flypath`: a PolyLine or plex-2 Formex.
    """
    from plugins.curve import PolyLine

    if type(path) is str:
        path = named(path)
    if not path:
        warning("You have to define a flypath first!")
        return

    if isinstance(path, PolyLine):
        path = path.toFormex()
    if path.nplex() != 2:
        warning("The flypath should be a plex-2 Formex!")

    for eye, center in path:
        pf.debug("Eye: %s; Center: %s" % (eye, center))
        pf.canvas.camera.lookAt(eye, center, upvector)
        pf.canvas.display()
        pf.canvas.update()
        image.saveNext()
        if sleeptime is None:
            sleeptime = pf.cfg["draw/flywait"]
        sleeptime = float(sleeptime)
        if sleeptime > 0.0:
            sleep(sleeptime)

    pf.canvas.camera.setCenter(*center)
    pf.canvas.camera.setDist(coords.length(center - eye))
    pf.canvas.update()
Exemplo n.º 3
0
def flyAlong(path,upvector=[0.,1.,0.],sleeptime=None):
    """Fly through the current scene along the specified path.

    This function moves the camera through the subsequent points
    of a path, looing at the next point of the path, and keeping
    the upvector of the camera oriented along the specified direction.
    
    - `path`: a PolyLine or plex-2 Formex specifyin the camera path.
    - `upvector`: the direction of the vertical axis of the camera.
    - `sleeptime`: a delay between subsequent images, to slow down
      the camera movement.
    """
    from plugins.curve import PolyLine

    try:
        if not isinstance(path,Formex):
            path = path.toFormex() 
        if not path.nplex() in (2,3):
            raise ValueError
    except:
        raise ValueError,"The camera path should be (convertible to) a plex-2 or plex-3 Formex!"

    if sleeptime is None:
        sleeptime = pf.cfg['draw/flywait']
    saved = delay(sleeptime)
    saved1 = pf.GUI.actions['Continue'].isEnabled()
    pf.GUI.actions['Continue'].setEnabled(True)
    
    for eye,center in path:
        pf.debug("Eye: %s; Center: %s" % (eye,center))
        pf.canvas.camera.lookAt(eye,center,upvector)
        wait()
        pf.canvas.display()
        pf.canvas.update()
        image.saveNext()

    delay(saved)
    pf.GUI.actions['Continue'].setEnabled(saved1)
    pf.canvas.camera.setCenter(*center)
    pf.canvas.camera.setDist(coords.length(center-eye))
    pf.canvas.update()