Пример #1
0
def rdmb_povray_color(file_base,
                      time_point=2000,
                      width=800, height=600,
                      rotx=0, roty=0, rotz=0,
                      angle=14,
                      mode="C"):
    """Render and save RD results using Pov-Ray (color)

    Render and save RD results using Pov-Ray
    with color indicating parameter values

    Args:
        file_base:
        time_point:
        width, height:
        rotx, roty, rotz:
        angle:
        mode:
        
    """

    vs, ucs, As, Cs = load_rd_mb(file_base)
    
    file_png = file_base + "_color_{:05}.png".format(time_point)
    
    tempfile = file_png[:-4] + "__temp__" + ".pov"

    camera = Camera('location', [0, 0, -25],
                    'look_at', [0, 0, 0],
                    'angle', angle,
                    'right x*image_width/image_height')
    
    light = LightSource([-3, 2, -6],
                        'color', [1.0, 1.0, 1.0], 'parallel')
    light2 = LightSource([2, -2, -6],
                         'color', [0.2, 0.2, 0.2], 'parallel')
    background = Background('color', [1, 1, 1, 1])
    
    spheres = []
    spheres +=  sph(vs, ucs, As, Cs,
                    0, 0, 0,
                    rotx=rotx, roty=roty, rotz=rotz,
                    mode=mode)
    
    objects = [light, light2, background] + spheres
    
    scene = Scene(camera, objects=objects)
    
    scene.render(file_png,
                 width=width, height=height,
                 tempfile=tempfile,
                 output_alpha=True, antialiasing=0.001)

    return file_png
Пример #2
0
def main():
    lookfrom = (13 / 1.5, 2 / 1.5, -5 / 1.5)
    lookat = (0, 0, 0)
    # dist_to_focus = 10.0
    # aperture = 0.1
    step = 1
    # camera
    camera = Camera('location', lookfrom, 'look_at', lookat)

    # background
    light = LightSource((0, 20, 0), 'color', (1, 1, 1))
    bg = Background('color', (0.5, 0.7, 1.0))
    base = Sphere((0, -1000, 0), 1000,
                  Texture(Pigment('color', (0.5, 0.5, 0.5))))
    htlist = [bg, base, light]
    for a in range(-11, 11, step):
        for b in range(-11, 11, step):
            choose_mat = random.random()
            center = (a + 0.9 * random.random(),
                      0.2, b + 0.9 * random.random())
            if distance(center, (4, 0.2, 0)) < 0.9:
                continue
            if choose_mat < 0.8:
                # diffuse
                color = (random.random() * random.random(),
                         random.random() * random.random(),
                         random.random() * random.random())
                htlist.append(
                    Sphere(center, 0.2, Texture(Finish('diffuse', 1), Pigment('color', color))))
            elif choose_mat < 0.95:
                # metal
                color = (0.5 * (1 + random.random()),
                         0.5 * (1 + random.random()),
                         0.5 * (1 + random.random()))
                # p1 = 0.5 * random.random()
                htlist.append(
                    Sphere(center, 0.2, Texture(Finish('Metal'), Pigment('color', color))))
            else:
                # glass
                htlist.append(Sphere(center, 0.2, Material('M_Glass')))

    # main 3 sphere
    htlist.append(
        Sphere((0, 1, 0), 1.0, Material('M_Glass')))
    htlist.append(
        Sphere((-4, 1, 0), 1.0, Texture(Finish('diffuse', 1), Pigment('color', (0.4, 0.2, 0.2)))))
    htlist.append(Sphere((4, 1, 0), 1.0, Texture('Chrome_Texture')))
    scene = Scene(camera, objects=htlist, included=[
                  'metals.inc', 'glass.inc', 'textures.inc', 'colors.inc'])
    with open("where-next.pov", "w") as ofp:
        print(str(scene), file=ofp)
    scene.render('where-next.png', width=800, height=600,
                 antialiasing=0.1, quality=10)
Пример #3
0
def rdmb_povray_save(out_file,
                     vs,
                     ucs, vcs,
                     width=800, height=600,
                     rotx=0, roty=0, rotz=0,
                     angle=14):
    """Render and save RD results using Pov-Ray

    Render and save RD results using Pov-Ray

    Args:
        out_file: output file
        vs: vertices
        ucs, vcs: u/v conc.
        width, height: width and height of output image
        rotx, roty, rotz: rotation angle
        angle: camera angle

    """

    ucmax = 6.0
    ucs = ucs / ucmax
    ucs[ucs > 1.0] = 1.0
    # ucs = ucs / np.max(ucs)

    rot1 = [rotx, 0, 0]
    rot2 = [0, roty, 0]
    rot3 = [0, 0, rotz]

    camera = Camera('location', [0, 0, -25],
                    'look_at', [0, 0, 0],
                    'angle', angle,
                    'right x*image_width/image_height')

    light = LightSource([-3, 2, -6], 'color', [1.0, 1.0, 1.0], 'parallel')
    light2 = LightSource([2, -2, -6], 'color', [0.6, 0.6, 0.6], 'parallel')
    background = Background('color', [1, 1, 1, 1])

    spheres = [Sphere(v, 0.02,
                      Finish('ambient', 0.2, 'diffuse', 0.8, 'phong', 1.0),
                      Texture(Pigment('color',
                                      [0.3+uc*0.7, 0.2+uc*0.8, 0.2+uc*0.8])),
                      'rotate', rot1,
                      'rotate', rot2,
                      'rotate', rot3) for v, uc in zip(vs, ucs)]

    objects = [light, light2, background] + spheres

    scene = Scene(camera, objects=objects)
    scene.render(out_file, width=width, height=height,
                 output_alpha=True, antialiasing=0.001,
                 tempfile=out_file+"__temp__.pov")
Пример #4
0
def render_povray_mb(mbs, rotx=0, roty=0, rotz=0,
                     width=400, height=400, angle=14):
    """Render metaballs using Pov-Ray (Vapory)

    Render metaballs using Pov-Ray (Vapory)

    Args:
        mbs: Metaballs
        width, height:

    Returns:
        rendered_scene:

    """

    rot1 = [rotx, 0, 0]
    rot2 = [0, roty, 0]
    rot3 = [0, 0, rotz]

    camera = Camera('location', [0, 0, -25],
                    'look_at', [0, 0, 0],
                    'angle', angle,
                    'right x*image_width/image_height')

    light = LightSource([-3, 2, -6], 'color', [1.0, 1.0, 1.0], 'parallel')
    # light2 = LightSource([2, -2, -6], 'color', [0.6, 0.6, 0.6], 'parallel')
    background = Background('color', [1, 1, 1, 1])

    mbs_function = mbs.to_povray_func()

    isosurface = Isosurface(Function(mbs_function),
                            ContainedBy(Box(-5, 5)),
                            'max_gradient', 1.8,
                            Pigment('color', [1.0, 0.15, 0.3]),
                            Finish('phong', 0.7,
                                   'specular', 0.2,
                                   'diffuse', 0.9,
                                   'ambient', 0.1),
                            'rotate', rot1,
                            'rotate', rot2,
                            'rotate', rot3,
                            'translate', [0, 0, 0],
                            'no_shadow')

    objects = [light, background] + [isosurface]

    scene = Scene(camera, objects=objects)

    return scene.render('ipython', width=width, height=height)
Пример #5
0
def frame(step):
    """ """

    # Feedback to user in terminal about render status
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Calculates the total frames
    n_frames = eval(SETTINGS.NumberFrames)

    full_circle = 2 * pi  # One full circle equals exactly 2 times pi

    # obtain molecules from function
    create_molecules()

    # Creation of RNA molecule
    if step in range(0, n_frames // 5 * 2):
        GUANINE.move_to([10, 0, 0])
        ADENINE.move_to([-10, 0, 0])
        CYTOSINE.move_to([0, 10, 0])
        URACIL.move_to([0, -10, 0])

    # # Sphere covering the RNA molecule
    # if step in range(n_frames // 5 * 2, n_frames // 5 * 3):
    #
    # # RNA division
    # if step in range(n_frames // 5 * 3, n_frames // 5 * 4):
    #
    # # Sphere division
    # if step in range(n_frames // 5 * 4, n_frames):

    # Return the Scene object for rendering
    return Scene(models.floor_camera,
                 objects=[models.default_light] + GUANINE.povray_molecule)
Пример #6
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """
    # Show some information about how far we are with rendering
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Getting the total number of frames, see the configuration file
    nframes = eval(SETTINGS.NumberFrames)

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))

    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, style)
    sphere = Sphere([6, 2, -2], 3, style)
    leg = legend([-15, 0, 0], 5)
    radius = 25
    z_start = 0
    x_start = 0
    #werkt allbei
    # alpha = (-pi/2) + (step * 2 * pi / nframes)
    alpha = pi / (nframes / 2) * step + 1

    x_coord = radius * cos(alpha)
    z_coord = radius * sin(alpha)
    x = x_start + x_coord
    z = z_start - z_coord
    return Scene(
        Camera('location', [x, 8, z], 'look_at', [0, 0, 0]),
        objects=[
            models.checkered_ground, models.default_light, cylinder, sphere
        ] + leg)
Пример #7
0
def frame(step):
    """ Creates a Lightsource a default Camera and calls the Shape function and places this in a scene """
    lichtje = LightSource([2, 8, -5], 5.0)
    default_camera = Camera('location', [-5, 8, -20], 'look_at', [-5, 0, -5])
    shapes = legend([-15, 0, 0], 5)
    # Return the Scene object for rendering
    return Scene(default_camera, objects=[lichtje] + shapes)
Пример #8
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """

    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    nframes = eval(SETTINGS.NumberFrames)

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))

    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, style)
    sphere = Sphere([6, 2, -2], 3, style)
    leg = legend([-15, 0, 0], 5)
    radius = 25
    z_start = 0
    x_start = 0

    alpha = (-pi / 2) + (step * 2 * pi / nframes)
    # For each step, de difference in the x and z positions is equal to the radius time the sin and cos of alpha.
    x_coord = radius * cos(alpha)
    z_coord = radius * sin(alpha)
    # Adding or subtracting the difference of the position for each step from the original camera position.
    x = x_start + x_coord
    z = z_start - z_coord
    return Scene(
        Camera('location', [x, 8, z], 'look_at', [0, 0, 0]),
        objects=[
            models.checkered_ground, models.default_light, cylinder, sphere
        ] + leg)
Пример #9
0
def frame(step):
    """ Creates a frame of 4 cones, 4 boxes, 1 sphere and a legend """

    # Define textures for different models
    sphere_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0.5))
    box_model = Texture(Pigment('color', [0, 1, 1], ), Finish('reflection', 0))
    cone_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0))

    # Create objects
    sphere = Sphere([0, 0, 0], 3, sphere_model)

    box_1 = Box([-5, -5, -4], [-3, 5, 4], box_model)
    box_2 = Box([3, -5, -4], [5, 5, 4], box_model)
    box_3 = Box([-5, 4, -4], [5, 6, 4], box_model)
    box_4 = Box([-5, -5, -4], [5, -3, 4], box_model)

    cone_1 = Cone([0, 6, 0], 3, [0, 10, 0], 0, cone_model)
    cone_2 = Cone([0, -6, 0], 3, [0, -10, 0], 0, cone_model)
    cone_3 = Cone([-5, 0, 0], 3, [-9, 0, 0], 0, cone_model)
    cone_4 = Cone([5, 0, 0], 3, [9, 0, 0], 0, cone_model)

    light_1 = LightSource([0, 10, -25], 'color', [1, 1, 1])
    light_2 = LightSource([0, 8, -7], 'color', [1, 1, 1])

    xyz_legend = legend([-15, 0, 0], 5)

    camera = Camera('location', [0, 7, -30], 'look_at', [0, 2, 1])

    # Return the Scene object for rendering
    return Scene(camera,
                 objects=[sphere, box_1, box_2, box_3, box_4,
                          cone_1, cone_2, cone_3, cone_4, light_1, light_2] + xyz_legend)
Пример #10
0
def frame(step):
    """ Renders an Ethanol molecule centered in the scene """
    # Dit is een beetje dubbel maar zonder gaat er opnieuw iets mis met self.atom
    ETHANOL = pdb.PDBMolecule('{}/pdb/ethanol.pdb'.format(
        SETTINGS.AppLocation),
                              center=True)
    camera = Camera('location', [10, 0, 0], 'look_at', [0, 0, 0])
    nframes = eval(SETTINGS.NumberFrames)
    hele_rotatie = 2 * math.pi

    # When step is below or equal to 40, the ethanol molecule is devided into 2 parts.
    if step <= (nframes / 2):
        y_ass = (1 / (nframes / 2)) * step
        splitsing = ETHANOL.divide([7, 8], 'ethanol', offset=[0, y_ass, 0])

    else:
        # In the second half of the program, last 40 frames we rotate the molecules 360 degrees.
        y_ass = (1 / (nframes / 2)) * 40
        splitsing = ETHANOL.divide([7, 8], 'ethanol', offset=[0, y_ass, 0])
        step = step - 40
        rotatie_per_step = (hele_rotatie / nframes) * step
        ETHANOL.rotate([1, 0, 0], rotatie_per_step)
        splitsing.rotate([1, 0, 0], rotatie_per_step)

    # Return the Scene object for rendering.
    return Scene(camera,
                 objects=[models.default_light] + ETHANOL.povray_molecule +
                 splitsing.povray_molecule,
                 included=['colors.inc'])
Пример #11
0
def frame(step):

    camera = Camera('location', [0, 7, -30], 'look_at', [0, 2, 1])
    xyz_legend = legend([-15, 0, 0], 5)
    light = LightSource([0, 10, -25], 'color', [1, 1, 1])

    return Scene(camera, objects=[light] + xyz_legend)
Пример #12
0
def frame(step):
    """ Creates a frame of a given frame (step) number. """

    # Show some information about how far we are with rendering
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Getting the total number of frames, see the configuration file
    nframes = eval(SETTINGS.NumberFrames)

    # Calculates rotation positions
    angle_per_frame = math.pi * 2 / nframes  # Calculates how much the angle needs to move per frame
    angle = angle_per_frame * step # Calculates the angle of the frame

    # Gets locations
    x = math.cos(angle) * 20
    z = math.sin(angle) * 20

    # Create objects
    sphere = Sphere([6, 2, -2], 3, models.default_sphere_model)
    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, models.default_sphere_model)
    legend_1 = legend([-15, 0, 0], 5)
    camera = Camera('location', [x, 8, z], 'look_at', [0, 0, 0])

    # Return the Scene object containing all objects for rendering
    return Scene(camera,
                 objects=[sphere, models.default_light, models.checkered_ground, cylinder] + legend_1)
Пример #13
0
def s2_cell_zoom(step):
    """ This scene has the camera moving closer towards the cell and entering it """
    cell_sphere = Sphere([0, 0, 0], 25, models.cell_model)
    dpf = get_added_distance(TP_START[2], TP_DUR[2], [0, 0, 49.7], step)
    camera_scene2 = Camera('location', [0, 0, -75], 'look_at', [0, 0, 0],
                           'translate', [dpf[0], dpf[1], dpf[2]])
    return Scene(camera_scene2, objects=[cell_sphere] + models.lights_scene1)
Пример #14
0
def frame(step):
    """ Makes an image/frame """
    time_point = (step / TOTAL_FRAMES) * SETTINGS.Duration
    logger.info(" @Time: %.4fs, Step: %d", time_point, step)

    # Declaration of the end times of the scenes
    global TP_END
    TP_END = [4, 8, 11, 15, 18, 26, 32, 38, 44, 50, 58, 64]
    # scene   0  1  2   3   4   5   6   7   8   9   10, 11

    # Globals that change per frame
    global TP_START, TP_DUR, TWITCH1, TWITCH2
    TP_START, TP_DUR = get_time_point_data(TP_END)
    TWITCH1, TWITCH2 = make_random_int()

    if time_point < TP_END[0]:
        scene = s0_intro_text()
    elif time_point < TP_END[1]:
        scene = s1_cell_overview()
    elif time_point < TP_END[2]:
        scene = s2_cell_zoom(step)
    elif time_point < TP_END[3]:
        scene = s3_in_cell()
    elif time_point < TP_END[4]:
        scene = s4_zoom_to_mrna(step)
    elif time_point < TP_END[11]:
        scene = scenes_mrna(step, time_point)
    else:
        text = Text('ttf', '"timrom.ttf"', '"Uh-oh, this ain\'t right"', 0, 0,
                    'translate', [-4, 0, 0], 'scale', [2, 2, 0],
                    models.text_model)
        scene = Scene(models.default_camera,
                      objects=[models.default_light, text])
    return scene
Пример #15
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    nframes = eval(SETTINGS.NumberFrames)
    n_frames_loop = nframes / 5  # 16 frames per wave

    stylebox = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                       Finish('phong', 0.6, 'reflection', 0.4))

    x_start = -10
    x_end = 10
    x_distance = x_end - x_start
    distance_per_frame = x_distance / nframes

    y_start = 0
    y_end = 4
    y_distance = y_end - y_start
    y_distance_per_frame = y_distance / n_frames_loop
    iteratie = step // n_frames_loop

    x_coord = x_start + step * distance_per_frame
    correctie = iteratie * n_frames_loop
    print(iteratie)
    step = step - correctie
    if step <= (n_frames_loop / 2):
        y_coord = y_start + step * y_distance_per_frame
    else:
        y_coord = y_end - step * y_distance_per_frame

    box = Box([x_coord, y_coord, 0], [x_coord + 2, y_coord + 2, 2], stylebox)

    return Scene(models.default_camera,
                 objects=[box, models.default_ground, models.default_light])
def frame(step):
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    nframes = eval(SETTINGS.NumberFrames)

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))

    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, style)
    sphere = Sphere([6, 2, -2], 3, style)
    leg = legend([-15, 0, 0], 5)

    radius = 25
    z_start = -25
    x_start = 0
    alpha = (-pi / 2) + (step * 2 * pi / nframes)
    x_coord = radius * cos(alpha)
    z_coord = radius * sin(alpha)
    x = x_start + x_coord
    z = z_start - z_coord

    camera_x = 0
    camera_z = -25

    # x gaat links en rechts en z verder de diepte in en terug -25?
    camera = Camera('location', [camera_x, 8, camera_z], 'look_at', [0, 0, 0])

    return Scene(
        camera,
        objects=[
            cylinder, sphere, models.default_light, models.checkered_ground
        ] + shapes,
        included=['colors.inc'])
Пример #17
0
def scene(step):
    ''' Returns the scene at step number (1 step per frame) '''
    A = np.array([-10, 8, 0])
    B = np.array([5, 2, -20])
    
    # Find a point with distance 3 from A
    BA = B-A # Vector B->A
    d = math.sqrt(sum(np.power(BA, 2))) # distance
    BA = BA / d # Normalize by its length; BA / ||BA||
    scale = 4
    N = A + scale * BA # Scale and add to A
    l = Cylinder(A, B, 0.05, Pigment('color', [0, 1, 0]))
    s1 = Sphere(N, 0.5, Texture(Pigment('color', [0.9, 0.05, 0.05])))
    
    scale = 15
    N = A + scale * BA # Scale and add to A
    s2 = Sphere(N, 0.5, Texture(Pigment('color', [0.9, 0.05, 0.05])))
    
    scale = 24
    N = A + scale * BA # Scale and add to A
    s3 = Sphere(N, 0.5, Texture(Pigment('color', [0.9, 0.05, 0.05])))
    
    return Scene(povray.floor_camera,
                 objects=[povray.default_light, povray.checkered_ground, 
                 l, s1, s2, s3],
                 included=['colors.inc'])
Пример #18
0
def frame(step):
    """ Creates a sphere and 4 boxes, places this in a scene """
    lichtje = LightSource([2, 8, -5], 5.0)
    default_camera = Camera('location', [0, 4, -40], 'look_at', [0, 2, -5])

    stylebox = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                       Finish('phong', 0.6, 'reflection', 0.4))
    boxright = Box([3, -2, -3], [5, 6, 4], stylebox)
    boxleft = Box([-5, -2, -3], [-3, 6, 4], stylebox)
    boxupper = Box([-5, 6, -3], [5, 8, 4], stylebox)
    boxbottom = Box([-5, -4, -3], [5, -2, 4], stylebox)

    styleball = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7))
    centerball = Sphere([0, 2, 0], 3, styleball)

    conetop = Cone([0, 8, 0], 3, [0, 12, 0], 0, stylebox)
    conebottom = Cone([0, -4, 0], 3, [0, -8, 0], 0, stylebox)
    coneleft = Cone([-5, 2, 0], 3, [-11, 2, 0], 0, stylebox)
    coneright = Cone([5, 2, 0], 3, [11, 2, 0], 0, stylebox)

    # Return the Scene object for rendering
    return Scene(default_camera,
                 objects=[
                     lichtje, centerball, boxright, boxleft, boxupper,
                     boxbottom, conetop, conebottom, coneleft, coneright
                 ])
Пример #19
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """
    # Show some information about how far we are with rendering
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Getting the total number of frames, see the configuration file
    nframes = eval(SETTINGS.NumberFrames)

    # Start- and end-points
    x_start = -10
    x_end = 10
    distance = x_end - x_start

    # Calculate distance to move at each step
    distance_per_frame = (distance / nframes) * 2

    # Calculate new x-coordinate
    if step < (nframes / 2):
        # Move from left to right (starting at x = -10)
        x_coord = x_start + step * distance_per_frame
    else:
        # Move from right to left (starting at x = 10)
        x_coord = x_end - (step - (nframes / 2)) * distance_per_frame

    # Create sphere at calculated x-coordinate using default model
    sphere = Sphere([x_coord, 0, 0], 2, models.default_sphere_model)

    # Return the Scene object containing all objects for rendering
    return Scene(models.default_camera,
                 objects=[sphere, models.default_ground, models.default_light])
def frame(step):
    ''' Renders an molecule centered in the scene '''
    camera = Camera('location', [10, 0, 0], 'look_at', [0, 0, 0])

    # Return the Scene object for rendering
    return Scene(camera,
                 objects=[models.default_light] +
                 Molecule_name.povray_molecule,
                 included=['colors.inc'])
Пример #21
0
def s0_intro_text():
    """ This show the title of the animation with our names """
    title = Text('ttf', '"timrom.ttf"', '"RNA Splicing"', 0, 0, 'translate',
                 [-2.85, 0.9, -0], 'scale', [5, 5, 1], models.text_model)
    names = Text('ttf', '"timrom.ttf"', '"Reindert Visser and Vincent Talen"',
                 0, 0, 'translate', [-7.2, -0.5, -0], 'scale', [3, 3, 1],
                 models.text_model)
    return Scene(models.camera_scene0,
                 objects=[title, names] + models.lights_scene1)
Пример #22
0
def render_povray(vs, rotx=0, roty=0, rotz=0,
                  width=400, height=400, angle=14, antialiasing=0.001):
    """Render vertices using Pov-Ray (Vapory)

    Render vertices using Pov-Ray (Vapory)

    Args:
        vs: vertices
        rotx, roty, rotz: rotation angle
        width, height:
        angle: camera angle

    Returns:
        rendered_scene:

    """

    rot1 = [rotx, 0, 0]
    rot2 = [0, roty, 0]
    rot3 = [0, 0, rotz]

    camera = Camera('location', [0, 0, -25],
                    'look_at', [0, 0, 0],
                    'angle', angle,
                    'right x*image_width/image_height')

    light = LightSource([-3, 2, -6], 'color', [1.0, 1.0, 1.0], 'parallel')
    light2 = LightSource([2, -2, -6], 'color', [0.6, 0.6, 0.6], 'parallel')
    background = Background('color', [1, 1, 1])

    spheres = [Sphere(v, 0.05,
                      Finish('ambient', 0.2, 'diffuse', 0.8, 'phong', 1.0),
                      Texture(Pigment('color', [1.0, 1.0, 1.0])),
                      'rotate', rot1,
                      'rotate', rot2,
                      'rotate', rot3) for v in vs]

    objects = [light, light2, background] + spheres

    scene = Scene(camera, objects=objects)

    return scene.render('ipython',
                        width=width, height=height,
                        antialiasing=antialiasing)
Пример #23
0
def frame(step):
    """ Returns a scene at a step number in which a sphere is visualised. """
    # Feedback to user in terminal about render status
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Calculates the total frames
    n_frames = eval(SETTINGS.NumberFrames)

    # Calculate the frames per wave
    repeats = 5
    n_frames_wave = n_frames / repeats  # amount of frames per wave

    # Calculates starting coordinates of the sphere
    increase = 4  # amount of increase per wave
    x_start = -10
    x_end = x_start + increase
    y_start = -4
    y_end = 4

    # Calculates total distance and distance per frame
    x_distance = x_end - x_start
    y_distance = y_end - y_start
    x_distance_per_frame = (x_distance / (n_frames_wave / 2))
    y_distance_per_frame = (y_distance / (n_frames_wave / 2))

    # Determine in which wave this step is
    if step // n_frames_wave == 0:
        wave = 0
    else:
        wave = step // n_frames_wave

    # Step has to reset for every wave, so subtract frames of previous wave(s)
    frame_in_wave = step - (wave * n_frames_wave)

    # If it is in the first part of the wave
    if frame_in_wave <= (n_frames_wave / 2):
        x_coord = x_start + (
            wave * increase
        ) + frame_in_wave * x_distance_per_frame  # Increases linear
        y_coord = y_start + frame_in_wave * y_distance_per_frame  # Increases linear
    # Second part of the wave
    else:
        x_coord = x_end + (wave * increase
                           )  # Stays constant and increases 4 for every wave
        y_coord = y_end - (
            frame_in_wave -
            (n_frames_wave / 2)) * y_distance_per_frame  # Decreases linear

    # Makes a sphere at given x- and Y-coordinates with the default style
    sphere = Sphere([x_coord, y_coord, 0], 0.5, models.default_sphere_model)

    # Returns the objects of the scene using the default camera settings
    return Scene(models.default_camera,
                 objects=[sphere, models.default_ground, models.default_light])
Пример #24
0
    def save_frame_image(self, path):
        meshes = [Background("color", [self.bk_r, self.bk_g, self.bk_b])]
        tex = Texture(Pigment('color', [self.cc_r, self.cc_g, self.cc_b]),
                      Finish('specular', self.specular))
        texo = Texture(Pigment('color', [self.cco_r, self.cco_g, self.cco_b]),
                       Finish('specular', self.specularo))
        for i in xrange(-1, self.expert.nr_obstacles_c()):
            vss, nss, iss = self.save_frame_mesh(i)
            meshes += [ClothMesh(vss, iss, nss, tex if i == -1 else texo)]

        #render
        scene = Scene(Camera('location', [self.cx, self.cy, self.cz], 'sky',
                             [self.ux, self.uy, self.uz], 'look_at',
                             [self.fx, self.fy, self.fz], 'right', [1, 0, 0],
                             'up', [0, -1, 0], 'angle', self.fovy),
                      objects=self.lights + meshes)
        scene.render(path,
                     width=self.w,
                     height=self.h,
                     antialiasing=self.aa if hasattr(self, "aa") else 0.0)
Пример #25
0
def scene(step):
    ''' Returns the scene at step number (1 step per frame) '''
    ATP.rotate([0, 1, 0], [0, RAD_PER_SCENE, 0])
    ATP.show_label(camera=povray.floor_camera, name=True)

    # Return a 'Scene' object containing -all- objects to render, i.e. the camera,
    # lights and in this case, a molecule with its labels.
    return Scene(
        povray.floor_camera,
        objects=[povray.default_light, FRONT_LIGHT, povray.checkered_ground] +
        ATP.povray_molecule,
        included=['colors.inc'])
Пример #26
0
def s4_zoom_to_mrna(step):
    """ In this scene the camera moves into the nucleus
        to further illustrate that the splicing takes place in the nucleus """
    dpf_cam = get_added_distance(TP_START[4], TP_DUR[4], [0, 0, 22.5], step)
    camera_scene4 = Camera('location', [0, 0, -40], 'look_at', [0, 0, 0],
                           'translate', [dpf_cam[0], dpf_cam[1], dpf_cam[2]])

    dpf_nuc = get_added_distance(TP_START[4], TP_DUR[4], [-20, -7.5, -9.9],
                                 step)
    nucleus = Sphere([20, 7.5, 0], 7.5, models.nucleus_model, 'translate',
                     [dpf_nuc[0], dpf_nuc[1], dpf_nuc[2]])
    return Scene(camera_scene4, objects=[nucleus] + models.spot_lights)
def frame(step):
    """ Creates the objects and places this in a scene """
    # Creates the lines in each directions
    x_cylinder = Cylinder([-15, 0, 0], [-10, 0, 0], 0.1, Texture(Pigment('color', [1, 0, 0]), Finish('reflection', 1)))
    y_cylinder = Cylinder([-15, 0, 0], [-15, 5, 0], 0.1, Texture(Pigment('color', [0, 0, 1]), Finish('reflection', 1)))
    z_cylinder = Cylinder([-15, 0, 0], [-15, 0, 5], 0.1, Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1)))
    # Creates the arrows of each directions
    x_cone = Cone([-10, 0, 0], 0.3, [-9, 0, 0], 0, Texture(Pigment('color', [1, 0, 0]), Finish('reflection', 1)))
    y_cone = Cone([-15, 5, 0], 0.3, [-15, 6, 0], 0, Texture(Pigment('color', [0, 0, 1]), Finish('reflection', 1)))
    z_cone = Cone([-15, 0, 5], 0.3, [-15, 0, 6], 0, Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1)))
    # Return the Scene object for rendering
    return Scene(models.default_camera,
                 objects=[LightSource([2, 8, -20], 2), x_cylinder, y_cylinder, z_cylinder, x_cone, y_cone, z_cone])
Пример #28
0
    def render_frame(self, step, outn):

        particles = []
        for i in range(self.sm.NUM_PARTICLES):
            clr = speed2color(speed=self.speeds[step][i],
                              speed_limit=self.maxspeed,
                              alpha=False)
            p = Sphere(
                [
                    self.r_vecs[step][i][1], self.r_vecs[step][i][2],
                    self.r_vecs[step][i][0]
                ],
                self.sm.RADIUS_PARTICLE,
                Texture(Pigment("color", clr)),
            )
            particles.append(p)

        self.scene = Scene(self.camera, objects=self.objects + particles)

        self.scene.render(f"{self.sm.png_path}/img{outn:06}.png",
                          width=600,
                          height=400)
Пример #29
0
def s1_cell_overview():
    """ This scene is a single cell centered without any movement """
    cell_sphere = Sphere([0, 0, 0], 25, models.cell_model)

    text = Text('ttf', '"timrom.ttf"',
                '"To begin you first need to know that"', 0, 0, 'translate',
                [-14.5, -5, -30], 'scale', [2.5, 2.5, 1], models.text_model)
    text2 = Text('ttf', '"timrom.ttf"',
                 '"RNA Splicing takes place in the cell"', 0, 0, 'translate',
                 [-14.5, -6.25, -30], 'scale', [2.5, 2.5, 1],
                 models.text_model)
    return Scene(models.camera_scene1,
                 objects=[cell_sphere, text, text2] + models.lights_scene1)
Пример #30
0
def frame(step):
    """Berekeent de posities van alle elementen van de animatie. En simuleert de animatie.
    Args: step: het nummer van het frame.
    Return: een Scene"""
    global aminomoddel_list

    # juiste triplet pakken key en aminozuur bij maken en key verplaatsen
    key_nmbr = step // key_cycle  # key_nmbr = het nummer van de momentele key cyclus
    triplet = triplet_list[key_nmbr]  # welk triplet de key moet mee nemen
    amino = amino_maker(triplet)

    pos = move_key(step, key_cycle, key)
    amino.move_to([pos[0], pos[1] + AMINO_AFSTAND, pos[2]])

    camera = Camera('location', [0, 8, -140], 'look_at', [0, 0, 0])
    light = LightSource([0, 40, -100], 2)
    objects = [light]
    move_aminozuren(step, key_cycle, key_nmbr,
                    False)  # zet de aminozuren op de juiste positie
    move_nucleotides(step, key_cycle, key_nmbr,
                     False)  # zet de nucleotide op de juiste positie

    if pos[0] > 0:
        if key_nmbr > 0:
            # voegt alle amino modellen toe uit de aminomoddel_list
            # tot aan het molecuul wat de key momenteel mee neemt
            for i in range(key_nmbr):
                objects += aminomoddel_list[i].povray_molecule
        objects += key.povray_molecule + amino.povray_molecule

    elif pos[0] == 0:
        # voegt alle amino modellen toe uit de aminomoddel_list
        # tot en met aan het molecuul wat de key momenteel mee neemt
        for i in range(key_nmbr + 1):
            objects += aminomoddel_list[i].povray_molecule
        objects += key.povray_molecule

    elif pos[0] < 0:
        # voegt alle amino modellen toe uit de aminomoddel_list
        # tot en met aan het molecuul wat de key momenteel mee neemt
        # en verplaatst de nucleotiden en aminozuren
        move_aminozuren(step, key_cycle, key_nmbr)
        move_nucleotides(step, key_cycle, key_nmbr)
        for i in range(key_nmbr + 1):
            objects += aminomoddel_list[i].povray_molecule
        objects += key.povray_molecule

    for element in nucleomoddel_list:
        objects += element.povray_molecule

    return Scene(camera, objects)