コード例 #1
0
ファイル: assignment2b.py プロジェクト: wouterzeevat/thema2
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)
コード例 #2
0
ファイル: vapory.py プロジェクト: tpvasconcelos/mdsea
    def initialize(self):
        # Set up camera
        camera_location = [
            2 * self.sm.LEN_BOX, 1.25 * self.sm.LEN_BOX, -0.5 * self.sm.LEN_BOX
        ]

        self.camera = Camera(
            "location", camera_location, "look_at",
            [self.sm.LEN_BOX / 2, self.sm.LEN_BOX / 2.5, self.sm.LEN_BOX / 2])

        # Set up background
        self.background = Background("color", self.clr_background)

        # Set up lighting
        self.lights = [
            LightSource(camera_location, "color", [1, 1, 1]),
            LightSource([
                100 * self.sm.LEN_BOX, 100 * self.sm.LEN_BOX,
                -100 * self.sm.LEN_BOX
            ], "color", self.clr_sun),
        ]

        # Global Settings
        # self.radiosity = Radiosity()

        # Goup Objects
        self.objects = [self.background, *self.lights]
コード例 #3
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
コード例 #4
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")
コード例 #5
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)
コード例 #6
0
ファイル: legend.py プロジェクト: wouterzeevat/thema2
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)
コード例 #7
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
                 ])
コード例 #8
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def insulin_bonded_to_ectodomain(frame):
    """
    Showing the complete ectodomain of the insulin receptor in complex with one insulin molecule
    """
    light = LightSource([0, 0, -100], 'color', [1, 1, 1])
    INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_PDB, center=False)
    INSULIN_RECEPTOR.move_to([0,0,0])
    
    return INSULIN_RECEPTOR, light
コード例 #9
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)
コード例 #10
0
ファイル: where-next.py プロジェクト: wtnb75/rtow1
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)
コード例 #11
0
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])
コード例 #12
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def bind_insuline_complete_ectodomain(frame):
    """
    Animating the insuline binding to the insulin receptor ectodomain part
    """
    light = LightSource([0, 0, -100], 'color', [1, 1, 1])
    INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_PDB, center=False) #create a the insulin receptor molecule from the pdb-file
    INSULIN_RECEPTOR.move_to([0,0,0]) #move the insulin receptor to the middle of the simulation
   
    insulin = INSULIN_RECEPTOR.divide(INSULIN_ATOM, 'insulin') #create the insulin molecule by dividing the insulin receptor
    y = 120 - ( 2 * (frame - 180) ) #setting a y-coordinate for insulin so it moves to the receptor
    insulin.move_offset([0, y, 0]) #move the insulin from its original pos to one with the y-coordinate
    
    return INSULIN_RECEPTOR, insulin, light
コード例 #13
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)
コード例 #14
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)
コード例 #15
0
def scene_objects():
    ''' Creates molecule objects and any other pre-calculated data '''
    # Store in the global namespace so the scene() method has access
    global ATP, RAD_PER_SCENE, FRONT_LIGHT

    FRONT_LIGHT = LightSource([0, 5, -29], 'color', [1, 1, 1], 'fade_distance',
                              15, 'fade_power', 2, 'area_light', 3, 3, 12, 12,
                              'circular orient adaptive', 0)

    # Calculate the radians per scene
    RAD_PER_SCENE = (math.pi / 180) * 3

    # Read in a PDB file and construct a molecule
    ATP = pdb.PDBMolecule('pdb/ATP_ideal.pdb', center=False)
    # Move to the center, and raise a little
    ATP.move_to([0, 6, 0])
    # Rotate so that the N-tail points downwards a bit
    ATP.rotate([0, 1, 1], [0, 1, -1.5])
コード例 #16
0
def frame(step):
    """ Creates the objects and places this in a scene """
    # Creates a sphere
    sphere = make_sphere(0, 0, 0, 1, 0, 1)
    # Creates the rectangles
    rectangle_right = make_box(3, -6, -4, 5, 6, 2)
    rectangle_top = make_box(3, 6, -4, -3, 4, 2)
    rectangle_left = make_box(-3, -6, -4, -5, 6, 2)
    rectangle_bottom = make_box(-3, -4, -4, 3, -6, 2)
    # Creates the cones
    cone_top = make_cone(0, 6, 0, 0, 10, 0)
    cone_left = make_cone(-5, 0, 0, -9, 0, 0)
    cone_right = make_cone(5, 0, 0, 9, 0, 0)
    cone_bottom = make_cone(0, -6, 0, 0, -10, 0)
    # Return the Scene object for rendering
    xyz_legend = legend([-15, 0, 0], 5)
    return Scene(Camera('location', [0, 10, -35], 'look_at', [0, 2, -2]),
                 objects=[LightSource([2, 8, -20], 2), sphere, rectangle_right, rectangle_top, rectangle_left,
                          rectangle_bottom, cone_top, cone_left, cone_right, cone_bottom] + xyz_legend)
コード例 #17
0
ファイル: molecule.py プロジェクト: wouterzeevat/thema2
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)

    # Create molecule
    atp = pdb.PDBMolecule('{}/pdb/ATP_ideal.pdb'.format(SETTINGS.AppLocation),
                          center=True)
    atp.move_to([0, 5, 0])

    # Creates phospate sliced molecule
    phosphate = atp.divide([0, 1, 2, 3, 7, 31, 32], 'phosphate')

    # Creates other objects
    camera = Camera('location', [25, 5, 10], 'look_at', [0, 5, 0])
    light = LightSource([25, 5, 10], 'color', [1, 1, 1])

    # Splicing the molecules animation
    if step <= 20 and step > 5:
        y = (0 - 4 / 15) * (step - 5)  # Moves for 15 frames, -4x in total
        phosphate.move_offset([0, y, 0])

    # Keeping the phospate in it's position after it moved
    elif step > 5:
        y = (0 - 4 / 15) * (
            20 - 5)  # Moves it like the 20th frame to keep it's position
        phosphate.move_offset([0, y, 0])

        # Rotating the molecules
        if step >= 30 and step < 70:
            phosphate.rotate([1, 0, 0], np.pi * 2 / 40 *
                             (step - 30))  # Rotates it for 40 frames, 1 - 2pi
            atp.rotate([0, 1, 0], np.pi * 2 / 40 * (step - 30))

    # Return the Scene object containing all objects for rendering
    return Scene(
        camera,
        objects=[models.checkered_ground, models.default_light, light] +
        atp.povray_molecule + phosphate.povray_molecule)
コード例 #18
0
def frame(step):
    """ Returns a scene at a step number while camera is moving """
    # 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)

    # Calculates coordinates for the camera position
    radius = 25
    degrees = pi / (n_frames / 2) * (step + 1)
    x_coord = radius * sin(degrees)
    z_coord = radius * cos(degrees)

    # Returns the objects of the scene using the default camera settings
    return Scene(
        Camera('location', [x_coord, 8, z_coord], 'look_at', [0, 0, 0]),
        objects=[LightSource([2, 8, -20], 2), models.checkered_ground] +
        SPHERE + CYLINDER + LEGEND)
コード例 #19
0
def frame(step):
    """ Creates the objects and places this in a scene """
    # Creates a sphere
    sphere = make_sphere(0, 0, 0)
    # Creates the rectangles
    rectangle_right = make_box(3, -6, -4, 5, 6, 2)
    rectangle_top = make_box(3, 6, -4, -3, 4, 2)
    rectangle_left = make_box(-3, -6, -4, -5, 6, 2)
    rectangle_bottom = make_box(-3, -4, -4, 3, -6, 2)
    # Creates the cones
    cone_top = make_cone(0, 6, 0, 0, 10, 0)
    cone_left = make_cone(-5, 0, 0, -9, 0, 0)
    cone_right = make_cone(5, 0, 0, 9, 0, 0)
    cone_bottom = make_cone(0, -6, 0, 0, -10, 0)
    # Return the Scene object for rendering
    return Scene(models.default_camera,
                 objects=[
                     LightSource([2, 8, -20], 2), sphere, rectangle_right,
                     rectangle_top, rectangle_left, rectangle_bottom, cone_top,
                     cone_left, cone_right, cone_bottom
                 ])
コード例 #20
0
def scene_objects():
    """ Creates molecule objects and any other pre-calculated data """
    global ETHANOL, VIAGRA, BENZENE, RAD_PER_SCENE, FRONT_LIGHT

    FRONT_LIGHT = LightSource([0, 14, -28], 'color', [1, 0.8, 0.4],
                              'fade_distance', 6, 'fade_power', 2,
                              'area_light', 3, 3, 12, 12,
                              'circular orient adaptive', 0)

    # Calculate the radians per scene
    RAD_PER_SCENE = (math.pi / 180) * 3

    # Read in a PDB file and construct a molecule
    ETHANOL = pdb.PDBMolecule('pdb/ethanol.pdb',
                              center=False,
                              offset=[-10, 8, -5])
    VIAGRA = pdb.PDBMolecule('pdb/viagra.pdb',
                             center=False,
                             offset=[3, -3, -7])
    BENZENE = pdb.PDBMolecule('pdb/benzene.pdb',
                              center=False,
                              offset=[0, 8, -5])
コード例 #21
0
def frame(step):
    lichtje = LightSource([2, 8, -5], 5.0)
    default_camera = Camera('location', [-5, 8, -20], 'look_at', [-5, 0, -5])
    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                       Finish('phong', 0.6, 'reflection', 0.4))

    linex = Cylinder([-15, 0, 0], [-10, 0, 0.5],0.1, style)
    liney = Cylinder([-15, 0, 0], [-15, 5, 0.2],0.1, style)
    linez = Cylinder([-15, 0, 0], [-15, 0.2, 5],0.1, style)


    conex = Cone([-10, 0, 0.5], 0.5,
                [-9, 0, 0.5], 0,
                style)
    coney = Cone([-15, 5, 0], 0.5,
                 [-15, 6, 0], 0,
                 style)
    conez = Cone([-15, 0, 5], 0.5,
                 [-15, 0, 6], 0,
                 style)

    # Return the Scene object for rendering
    return Scene(default_camera,
                 objects=[lichtje,linex,liney,linez,conex,coney,conez])
コード例 #22
0
def frame(step):
    """ Returns a scene at a step number while camera is moving. """
    # 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)

    # Calculates coordinates for the camera position
    radius = 25
    degrees = pi / (n_frames / 2) * (step + 1)
    x_coord = radius * sin(degrees)
    z_coord = radius * cos(degrees)

    # Makes objects at given coordinates
    sphere = Sphere([6, 2, -2], 3, models.default_sphere_model)
    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, models.default_sphere_model)
    xyz_legend = legend([-15, 0, 0], 5)

    # Returns the objects of the scene using the default camera settings
    return Scene(Camera('location', [x_coord, 8, z_coord], 'look_at', [0, 0, 0]),
                 objects=[LightSource([2, 8, -20], 2),
                          models.checkered_ground, sphere, cylinder] + xyz_legend)
コード例 #23
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def frame(step):
    """ Returns the scene at step number (1 step per frame) """

    camera = Camera('location', [0, 7, -200], 'look_at', [0, 0, 0])
    lights = [LightSource([0, -10, -60], 0.5),
              LightSource([0, -50, -60], 0.5),
              ]

    receptor = make_receptor([0, 0, -2], 5)
    membrane = make_membrane([0, 0, 0], 10, 5)
    tyrine = make_tyrine([0, 0, -2], 5)
    alphact_stage_one_sliced, alphact_stage_two_sliced = slice_alphact()

    seconds = step / 30
    if seconds < 1:  # Frame 0 -> 30
        return Scene(camera,
                objects=[models.default_light] + tyrine + membrane + receptor + tyrine + lights)

    elif seconds < 4:  # Frame 30 -> 120
        insuline_schematic = bind_schematic(step, 5)
        return Scene(camera,
                 objects=[models.default_light] + tyrine + membrane + receptor + tyrine + lights + insuline_schematic)

    elif seconds < 6:  # Frame 120 -> 180
        insuline_schematic = bind_schematic(step, 5)
        camera = move_camera(step, 60, [0, 7, -200], [-20, 20, 3], 120)
        return Scene(camera,
                 objects=[models.default_light] + tyrine + membrane + receptor + tyrine + lights + insuline_schematic)

    elif seconds < 8:  # Frame 180 -> 240
        camera = Camera('location', [0, 0, -300], 'look_at', [0, 0, 0])
        INSULIN_RECEPTOR, insulin, light = bind_insuline_complete_ectodomain(step)
        return Scene(camera,
                 objects=[light] + INSULIN_RECEPTOR.povray_molecule + insulin.povray_molecule)

    elif seconds < 9: # Frame 240 -> 270
        camera = Camera('location', [0, 0, -300], 'look_at', [0, 0, 0])
        INSULIN_RECEPTOR, light = insulin_bonded_to_ectodomain(step)
        return Scene(camera,
                 objects=[light] + INSULIN_RECEPTOR.povray_molecule)
    
    elif seconds < 11: #Frame 270 -> 330
        camera = Camera('location', [0, 0, -300], 'look_at', [0, 0, 0])
        light = LightSource([0, 0, -100], 'color', [1, 1, 1])
        alphact_stage_one_sliced_mol, insulin_alpha = alphact_conformational_change(step, alphact_stage_one_sliced, alphact_stage_two_sliced)
        return Scene(camera,
                 objects=[light] + alphact_stage_one_sliced_mol.povray_molecule + insulin_alpha.povray_molecule )

    elif seconds < 13: #Frame 330 -> 390
        camera = Camera('location', [0, 0, -300], 'look_at', [0, 0, 0])
        light = LightSource([0, 0, -100], 'color', [1, 1, 1])
        alphact_stage_two_sliced_mol, insulin_alpha = alphains_binding_alphact(step, alphact_stage_two_sliced)
        return Scene(camera,
                 objects=[light] + alphact_stage_two_sliced_mol.povray_molecule + insulin_alpha.povray_molecule )
  
    elif seconds < 14: #Frame 390 -> 420
        camera = Camera('location', [0, 0, -300], 'look_at', [0, 0, 0])
        light = LightSource([0, 0, -100], 'color', [1, 1, 1])
        alphact_complex_insulinalpha_mol = alphains_bonded_to_alphact(step, alphact_stage_two_sliced)
        return Scene(camera,
                 objects=[light] + alphact_complex_insulinalpha_mol.povray_molecule )

    elif seconds < 16: #Frame 420 -> 480
        if seconds < 14.7: #Frame 420 -> 441
            camera = move_camera(step, 21, [0, 0, -300], [0, 0, 3], 420)
            light = LightSource([0, 0, -100], 'color', [1, 1, 1])
            alphact_complex_insulinalpha_mol = alphains_bonded_to_alphact(step, alphact_stage_two_sliced)
            return Scene(camera,
                 objects=[light] + alphact_complex_insulinalpha_mol.povray_molecule)
        else: #Frame 441 -> 480
            camera = move_camera(step, 39, [0, 0, 3], [0, 7, -200], 441)
            insuline_schematic = bind_schematic(step, 5)
            return Scene(camera,
                 objects=[models.default_light] + tyrine + membrane + receptor + tyrine + lights + insuline_schematic)
    
    elif seconds < 19:   #Frame 480 -> 570
            insuline_schematic = bind_schematic(step, 5)
            phosphorus = bind_phosphorus(step, 5)
            return Scene(camera,
                 objects=[models.default_light] + tyrine + membrane + receptor + tyrine + lights + insuline_schematic + phosphorus)
    
    elif seconds < 21:   #Frame 570 -> 630
        insuline_schematic = bind_schematic(step, 5)
        phosphorus = bind_phosphorus(step, 5)
        IRS = bind_IRS(step, 5)
        return Scene(camera,
            objects=[models.default_light] + tyrine + membrane + receptor + tyrine + lights + insuline_schematic + phosphorus + IRS)

    insuline_schematic = bind_schematic(step, 5)
    phosphorus = bind_phosphorus(step, 5)
    IRS = bind_IRS(step, 5)
    return Scene(camera,
        objects=[models.default_light] + tyrine + membrane + receptor + tyrine + lights + insuline_schematic + phosphorus + IRS)
コード例 #24
0
def frame(step):
    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)
コード例 #25
0
def make_frame(step):
    """
    meke_frame(step)

    arguments:
    - step: int

    Create the scene that coresponds to the step.
    """
    global MOLECULES

    # Basic objects for the scene
    cam = Camera("location", [0, 0, 100], "look_at", [0, 0, 0])
    light = LightSource([0, 0, 100], 1)
    render_list = [light]

    print(
        "frame:{}----------------------------------------------------------------"
        .format(step))

    sorted_animation_objects = sort_molecules(ANIMATION_OBJECTS)

    # Is there another None molecule that needs to be created.
    for obj in sorted_animation_objects:
        molecule_data = ANIMATION_OBJECTS[obj]["molecule"]
        keyframe_frames_data = ANIMATION_OBJECTS[obj]["keyframe_endpos_frames"]
        if MOLECULES[obj] is None and step >= keyframe_frames_data[0]:
            mother_name = ANIMATION_OBJECTS[molecule_data[2]]["name"]

            # Set the mother molecule on the start position of split.
            move_objects(mother_name, keyframe_frames_data[0], True)

            # Set the mother molecule on the start rotation of split.
            if try_dict_keys(ANIMATION_OBJECTS[mother_name], "keyframe_rotation_frames") and\
               try_dict_keys(ANIMATION_OBJECTS[mother_name], "keyframe_rotation"):
                rotate_objects(mother_name, step)
            print(obj)
            # Call make molecules to split the molecule
            split_molecule = MOLECULES[molecule_data[2]]["molecule"].divide(
                molecule_data[3], obj, offset=[0, 0, 0])

            MOLECULES[obj] = {
                "molecule": split_molecule,
                "start": split_molecule.center.copy(),
                "reset": split_molecule.atoms,
                "text": None
            }

            # Set the mother molecule on the start rotation back before the split.
            if try_dict_keys(ANIMATION_OBJECTS[mother_name], "keyframe_rotation_frames") and\
               try_dict_keys(ANIMATION_OBJECTS[mother_name], "keyframe_rotation"):
                rotate_objects(mother_name, step, True)

    # Move, Rotate and join objects
    for obj in ANIMATION_OBJECTS:
        molecule_data = ANIMATION_OBJECTS[obj]["molecule"]

        if not MOLECULES[obj] is None:
            # Put the different objects in the render list
            if try_dict_keys(ANIMATION_OBJECTS[obj], "keyframe_shown_frames") and\
               try_dict_keys(ANIMATION_OBJECTS[obj], "keyframe_shown"):

                # Move, rotate the objects and put them in the render_list
                render_list = shown_objects(obj, step, render_list)
            else:
                # Move object to the correct posision based on the step
                move_objects(obj, step)

                # Rotate object when possible
                if try_dict_keys(ANIMATION_OBJECTS[obj], "keyframe_rotation_frames") and\
                   try_dict_keys(ANIMATION_OBJECTS[obj], "keyframe_rotation"):
                    rotate_objects(obj, step)

                #Put object in render_list
                render_list = put_object_in_render_list(obj, render_list)

            if obj == "camera":
                cam = Camera("location", MOLECULES[obj]["molecule"][0],
                             "look_at", MOLECULES[obj]["molecule"][1])
    return Scene(cam, objects=render_list)
コード例 #26
0
def frame(step):
    """ Creates the objects and places this in a scene """
    # Creates a sphere
    xyz_legend = legend([-15, 0, 0], 5)
    return Scene(models.default_camera,
                 objects=[LightSource([2, 8, -20], 2)] + xyz_legend)
コード例 #27
0
 def __init__(self):
     #load lib
     self.expert = ct.cdll.LoadLibrary("./libarcsim_expert.so")
     #register simulation functions
     self.expert.create_sheet_example_c.argtypes =   \
         [ct.c_double,ct.c_int,ct.c_double,ct.c_int,ct.c_char_p,
          ct.POINTER(ct.c_double),ct.POINTER(ct.c_double),
          ct.POINTER(ct.c_double),ct.POINTER(ct.c_double),
          ct.POINTER(ct.c_double),ct.c_int,
          ct.c_bool,ct.c_bool]
     self.expert.setup_begin_c.argtypes = [ct.c_char_p]
     self.expert.setup_end_c.argtypes = []
     self.expert.set_obs_motion_c.argtypes = [
         ct.c_int, ct.POINTER(ct.c_double), ct.c_int
     ]
     self.expert.set_handle_c.argtypes = [ct.POINTER(ct.c_double), ct.c_int]
     self.expert.save_frame_vtk_c.argtypes = [ct.c_char_p, ct.c_int]
     self.expert.get_meshv_c.argtypes = [ct.POINTER(ct.c_int), ct.c_int]
     self.expert.get_meshv_c.restype = ct.POINTER(ct.c_double)
     self.expert.get_meshn_c.argtypes = [ct.POINTER(ct.c_int), ct.c_int]
     self.expert.get_meshn_c.restype = ct.POINTER(ct.c_double)
     self.expert.get_meshi_c.argtypes = [ct.POINTER(ct.c_int), ct.c_int]
     self.expert.get_meshi_c.restype = ct.POINTER(ct.c_int)
     self.expert.advance_c.argtypes = []
     self.expert.illustrate_c.argtypes = [ct.c_char_p, ct.c_int]
     #genDepth(GLdouble eye[3],GLdouble ctr[3],GLdouble up[3],
     #         GLdouble fovy,GLdouble aspect,GLdouble zNear,GLdouble zFar,
     #         int w,int h,const char* path,const char* pathDepth)
     self.expert.gen_depth_c.argtypes = [
         ct.POINTER(ct.c_double),
         ct.POINTER(ct.c_double),
         ct.POINTER(ct.c_double), ct.c_double, ct.c_double, ct.c_int,
         ct.c_int, ct.c_char_p, ct.c_char_p
     ]
     #register expert functions
     self.expert.expert_flat_close_c.argtypes = [
         ct.POINTER(ct.c_double), ct.c_double, ct.c_double
     ]
     self.expert.expert_flat_close_c.restype = ct.POINTER(ct.c_double)
     self.expert.expert_arc_close_c.argtypes = [
         ct.POINTER(ct.c_double), ct.c_double, ct.c_double
     ]
     self.expert.expert_arc_close_c.restype = ct.POINTER(ct.c_double)
     self.expert.expert_twist_close_c.argtypes = [
         ct.POINTER(ct.c_double), ct.c_double, ct.c_double
     ]
     self.expert.expert_twist_close_c.restype = ct.POINTER(ct.c_double)
     self.expert.expert_flat_c.argtypes = [
         ct.POINTER(ct.c_double), ct.c_double, ct.c_double
     ]
     self.expert.expert_flat_c.restype = ct.POINTER(ct.c_double)
     self.expert.expert_arc_c.argtypes = [
         ct.POINTER(ct.c_double), ct.c_double, ct.c_double
     ]
     self.expert.expert_arc_c.restype = ct.POINTER(ct.c_double)
     self.expert.expert_twist_c.argtypes = [
         ct.POINTER(ct.c_double), ct.c_double, ct.c_double
     ]
     self.expert.expert_twist_c.restype = ct.POINTER(ct.c_double)
     self.expert.apply_expert_c.argtypes = [
         ct.POINTER(ct.c_double),
         ct.POINTER(ct.c_double), ct.c_double
     ]
     self.expert.apply_hand_c.argtypes = [
         ct.POINTER(ct.c_double),
         ct.POINTER(ct.c_double),
         ct.POINTER(ct.c_double), ct.c_double
     ]
     self.expert.free_vec_c.argtypes = [ct.POINTER(ct.c_double)]
     self.expert.free_veci_c.argtypes = [ct.POINTER(ct.c_int)]
     #image output size
     self.w = 1024
     self.h = 768
     self.fovy = 90
     self.zNear = 0.1
     self.zFar = 5
     #background color
     self.bk_r = 1
     self.bk_g = 1
     self.bk_b = 1
     #cloth color
     self.cc_r = 0.7
     self.cc_g = 0.7
     self.cc_b = 0.7
     self.specular = 0.4
     #cloth color
     self.cco_r = 0.7
     self.cco_g = 0.2
     self.cco_b = 0.2
     self.specularo = 0.4
     #camera pos
     self.cx = 2.0
     self.cy = 2.0
     self.cz = 2.0
     #focal point
     self.fx = 0.5
     self.fy = 1.0
     self.fz = 0.0
     #view up
     self.ux = 0.0
     self.uy = 0.0
     self.uz = 1.0
     #lights
     self.lights = []
     self.lights = self.lights + [
         LightSource([1, 0, 2], 'color', [1, 1, 1])
     ]
コード例 #28
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)

    if step < 31:
        ins_id, atom_pos = get_ins(PATH_LINUX)

        camera = Camera('location', [0, 0, -300], 'look_at', [0, 0, 0])
        light = LightSource([0, 0, -100], 'color', [1, 1, 1])

        insulin_pos = atom_pos["N"] + atom_pos["O"]
        #these need to be removed because the used insulin (b chain) is from a sheep, for humans the last aa must be removed
        insulin_pos.remove(9997)
        insulin_pos.remove(9998)
        insulin_pos.remove(9999)
        insulin_pos.remove(10000)
        insulin_pos.remove(10001)
        insulin_pos.remove(10002)

        INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_LINUX,
                                           center=False,
                                           offset=[-10, 8, -5])
        INSULIN_RECEPTOR.move_to([0, 0, 0])
        insulin = INSULIN_RECEPTOR.divide(insulin_pos, 'insulin')
        #insulin.move_to([-100,0,0])
        x = (30 * 0.1) - (0.1 * step)
        y = (30 * 2) - (2 * step)
        insulin.move_offset([x, y, 0])

    if step > 30:
        camera = Camera('location', [-40, 0, -200], 'look_at', [0, 0, 0])
        light = LightSource([0, 0, -100], 'color', [1, 1, 1])

        ins_id, atom_pos = get_ins(PATH_LINUX)
        alphact = atom_pos["P"]
        alphact_stage_one_sliced = []
        alphact_stage_two_sliced = []

        INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_LINUX,
                                           center=False,
                                           offset=[-10, 8, -5])
        INSULIN_RECEPTOR.move_to([0, 0, 0])

        for pos in alphact:
            if pos in range(10014, 10171):
                alphact_stage_one_sliced.append(pos)
            if pos in range(10115, 10211):
                alphact_stage_two_sliced.append(pos)

        if step == 31:
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_one_sliced, 'alphact_one')
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 32:
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_two_sliced, "alphact_two")
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 33:
            alphact_stage_one_sliced += atom_pos["N"]
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_one_sliced, 'alphact_one')
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 34:
            alphact_stage_two_sliced += atom_pos["N"]
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_two_sliced, "alphact_two")
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 35:
            alphact_stage_two_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_two_sliced, "alphact_two")
            insulin_alpha = INSULIN_RECEPTOR.divide(atom_pos["N"],
                                                    "alphact_two")
            alphact_stage_two_sliced_mol.move_to([0, 0, 0])
            insulin_alpha.move_to([50, 0, 0])
            return Scene(camera,
                         objects=[light] + insulin_alpha.povray_molecule +
                         alphact_stage_two_sliced_mol.povray_molecule)

        #simulation
        step_start = 36
        if step >= step_start:
            if step <= step_start + 10:

                for num in range(10014, 10115):
                    if num < (step - step_start) * round(101 / 10) + 10014:
                        if num not in alphact_stage_two_sliced:
                            alphact_stage_one_sliced.remove(num)
                for num in range(10171, 10211):
                    if num < (step - step_start) * round(40 / 10) + 10171:
                        alphact_stage_one_sliced.append(num)

                alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                    alphact_stage_one_sliced, 'alphact_one')
                rotation = (step - step_start - 10) * -0.1
                alphact_stage_one_sliced_mol.rotate([0, 0, 1], rotation)

                insulin_alpha = INSULIN_RECEPTOR.divide(
                    atom_pos["N"], "alphact_two")
                insulin_alpha.move_offset([0, 30, 0])

                return Scene(camera,
                             objects=[light] +
                             alphact_stage_one_sliced_mol.povray_molecule +
                             insulin_alpha.povray_molecule)
            elif step > step_start + 10 and step <= step_start + 20:
                alphact_stage_two_sliced_mol = INSULIN_RECEPTOR.divide(
                    alphact_stage_two_sliced, "alphact_two")
                return Scene(camera,
                             objects=[light] +
                             alphact_stage_two_sliced_mol.povray_molecule)

    return Scene(camera,
                 objects=[light] +
                 alphact_stage_one_sliced_mol.povray_molecule)
コード例 #29
0
    - To render an MP4 movie using default settings:
        simulation.py --mp4
"""

import argparse
import sys
import ast
from pypovray import pypovray, SETTINGS, load_config, logger
from vapory import Scene, LightSource, Camera, Sphere, Cylinder, Plane, Texture, Pigment, Finish, Interior, Difference

# Scene Global Settings
RADIUS = 10  # scene circle radius

# Scene Settings and Static Objects
MAIN_LIGHT = LightSource([2, 4, -3], 3, 'fade_distance', 5,
                         'fade_power', 2, 'area_light', 3, 3, 12, 12,
                         'circular orient adaptive', 0)
BACK_LIGHT = LightSource([-8, 3, -1], 'color', [1, 0.8, 0, 4],
                         'fade_distance', 6, 'fade_power', 2,
                         'area_light', 3, 3, 12, 12,
                         'circular orient adaptive', 0)
CAMERA = Camera('location', [0, 10, -20], 'look_at', [0, 0, -3])
GROUND = Plane([0, 1, 0], -4, Texture(Pigment('color', [1.5, 1, 1])))

def sphere_circle():
    """ Creates a circle made up of 20 small spheres.
        A list of Sphere objects is returnded ready for rendering. """
    spheres = 20  # number of spheres to create
    ring = []
    ring_node_size = 0.6
    smodel = Texture(Pigment('color', [1, 0, 0], 'filter', 0.5),
コード例 #30
0
    def _render_structure(self, change=None):
        """Render the structure with POVRAY."""

        if not isinstance(self.structure, Atoms):
            return

        self.render_btn.disabled = True
        omat = np.array(self._viewer._camera_orientation).reshape(
            4, 4).transpose()

        zfactor = norm(omat[0, 0:3])
        omat[0:3, 0:3] = omat[0:3, 0:3] / zfactor

        bb = deepcopy(self.structure)
        bb.pbc = (False, False, False)

        for i in bb:
            ixyz = omat[0:3, 0:3].dot(np.array([i.x, i.y, i.z]) + omat[0:3, 3])
            i.x, i.y, i.z = -ixyz[0], ixyz[1], ixyz[2]

        vertices = []

        cell = bb.get_cell()
        vertices.append(np.array([0, 0, 0]))
        vertices.extend(cell)
        vertices.extend([
            cell[0] + cell[1],
            cell[0] + cell[2],
            cell[1] + cell[2],
            cell[0] + cell[1] + cell[2],
        ])

        for n, i in enumerate(vertices):
            ixyz = omat[0:3, 0:3].dot(i + omat[0:3, 3])
            vertices[n] = np.array([-ixyz[0], ixyz[1], ixyz[2]])

        bonds = []

        cutOff = neighborlist.natural_cutoffs(
            bb)  # Takes the cutoffs from the ASE database
        neighborList = neighborlist.NeighborList(cutOff,
                                                 self_interaction=False,
                                                 bothways=False)
        neighborList.update(bb)
        matrix = neighborList.get_connectivity_matrix()

        for k in matrix.keys():
            i = bb[k[0]]
            j = bb[k[1]]

            v1 = np.array([i.x, i.y, i.z])
            v2 = np.array([j.x, j.y, j.z])
            midi = v1 + (v2 - v1) * Radius[i.symbol] / (Radius[i.symbol] +
                                                        Radius[j.symbol])
            bond = Cylinder(
                v1,
                midi,
                0.2,
                Pigment("color", np.array(Colors[i.symbol])),
                Finish("phong", 0.8, "reflection", 0.05),
            )
            bonds.append(bond)
            bond = Cylinder(
                v2,
                midi,
                0.2,
                Pigment("color", np.array(Colors[j.symbol])),
                Finish("phong", 0.8, "reflection", 0.05),
            )
            bonds.append(bond)

        edges = []
        for x, i in enumerate(vertices):
            for j in vertices[x + 1:]:
                if (norm(np.cross(i - j, vertices[1] - vertices[0])) < 0.001
                        or norm(np.cross(i - j,
                                         vertices[2] - vertices[0])) < 0.001
                        or norm(np.cross(i - j,
                                         vertices[3] - vertices[0])) < 0.001):
                    edge = Cylinder(
                        i,
                        j,
                        0.06,
                        Texture(
                            Pigment("color",
                                    [212 / 255.0, 175 / 255.0, 55 / 255.0])),
                        Finish("phong", 0.9, "reflection", 0.01),
                    )
                    edges.append(edge)

        camera = Camera(
            "perspective",
            "location",
            [0, 0, -zfactor / 1.5],
            "look_at",
            [0.0, 0.0, 0.0],
        )
        light = LightSource([0, 0, -100.0], "color", [1.5, 1.5, 1.5])

        spheres = [
            Sphere(
                [i.x, i.y, i.z],
                Radius[i.symbol],
                Texture(Pigment("color", np.array(Colors[i.symbol]))),
                Finish("phong", 0.9, "reflection", 0.05),
            ) for i in bb
        ]

        objects = (
            [light] + spheres + edges + bonds +
            [Background("color", np.array(to_rgb(self._viewer.background)))])

        scene = Scene(camera, objects=objects)
        fname = bb.get_chemical_formula() + ".png"
        scene.render(
            fname,
            width=2560,
            height=1440,
            antialiasing=0.000,
            quality=11,
            remove_temp=False,
        )
        with open(fname, "rb") as raw:
            payload = base64.b64encode(raw.read()).decode()
        self._download(payload=payload, filename=fname)
        self.render_btn.disabled = False