コード例 #1
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def bind_phosphorus(frame, size):
    """
    Animating the process of phosfor binding to the Tyr
    """

    phosphorus_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0))
    text_model = Texture(Pigment('color', [1, 1, 0], ), Finish('reflection', 0))

    phosphorus = []
    s = size

    # frame 480 -> 570
    x_locs = [[-20, -5], [20, 5], [-20, -5], [20, 5]]
    y_locs = [13, 13, 10, 10]

    for _ in range(4):
        if frame < 570:
            x = (frame - 480) * ((x_locs[_][1]*s - x_locs[_][0]*s) / 90) + x_locs[_][0]*s
            y = 0 - y_locs[_] * s
        else:
            x = x_locs[_][1]*s
            y = 0 - y_locs[_]*s
        phosphorus.append(Sphere([x, y, 2], s * 1.2, phosphorus_model))
        phosphorus.append(Text('ttf', '"timrom.ttf"', '"{}"'.format(str('P')), 0.5, [0, 0, 0], text_model, 'scale', 7, 'translate', [x - 0.2*s, y-0.5*s, -1.5*s]))
    return phosphorus
コード例 #2
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'])
コード例 #3
0
ファイル: legend.py プロジェクト: wouterzeevat/thema2
def legend(loc, length):
    """
    Creates a legend in a given location.
        Usage: legend([x, y, z], length)
    """

    # Defining textures for each axis
    x_model = Texture(Pigment(
        'color',
        [1, 0, 0],
    ), Finish('reflection', 0))
    z_model = Texture(Pigment(
        'color',
        [0, 0, 1],
    ), Finish('reflection', 0))
    y_model = Texture(Pigment(
        'color',
        [0, 1, 0],
    ), Finish('reflection', 0))

    # Create objects
    x_cyl = Cylinder(loc, [loc[0] + length, loc[1], loc[2]], 0.1, x_model)
    x_cone = Cone([loc[0] + length, loc[1], loc[2]], 0.3,
                  [loc[0] + length + 1, loc[1], loc[2]], 0, x_model)

    z_cyl = Cylinder(loc, [loc[0], loc[1], loc[2] + length], 0.1, y_model)
    z_cone = Cone([loc[0], loc[1], loc[2] + length], 0.3,
                  [loc[0], loc[1], loc[2] + length + 1], 0, y_model)

    y_cyl = Cylinder(loc, [loc[0], loc[1] + length, loc[2]], 0.1, z_model)
    y_cone = Cone([loc[0], loc[1] + length, loc[2]], 0.3,
                  [loc[0], loc[1] + length + 1, loc[2]], 0, z_model)

    return [x_cyl, x_cone, y_cyl, y_cone, z_cyl, z_cone]
コード例 #4
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
                 ])
コード例 #5
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)
コード例 #6
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def bind_schematic(frame, size):

    """
    Animating the binding part schematicly
    """

    insuline_model = Texture(Pigment('color', [0, 1, 0.5], ), Finish('reflection', 0))
    text_model = Texture(Pigment('color', [1, 1, 0], ), Finish('reflection', 0))

    insuline = []
    s = size

    # frame 30 -> 120
    if frame < 120:
        x = (frame - 30) * (24.5*s / 90) - 30*s
        y = (frame - 30) * (-15*s / 90) + 20*s 
    else:
        x = -5*s
        y = 5*s

    insuline.append(Sphere([x, y, 0], s * 1.5, insuline_model))
    insuline.append(Text('ttf', '"timrom.ttf"', '"{}"'.format(str('Insulin')), 0.5, [0, 0, 0], text_model, 'scale', 5, 'translate', [x - s, y-0.5*s, -2*s]))

    insuline.append(Sphere([0-x, y, 0], s * 1.5, insuline_model))
    insuline.append(Text('ttf', '"timrom.ttf"', '"{}"'.format(str('Insulin')), 0.5, [0, 0, 0], text_model, 'scale', 5, 'translate', [0-x -1.4*s, y-0.5*s, -2*s]))

    return insuline
コード例 #7
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)
コード例 #8
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def make_membrane(loc, amount, size=5):
    """
    Create the membrane and returns the object
    """

    sphere_model = Texture(Pigment('color', [1, 0, 0], ), Finish('reflection', 0))
    cyl_model = Texture(Pigment('color', [0.7, 0.3, 0], ), Finish('reflection', 0))

    x_position = loc[0]
    y_position = loc[0] - size * 6
    objects = []
    for index in range(1, amount + 1):

        # Create top spheres
        objects.append(Sphere([x_position, loc[1], loc[2]], size, sphere_model))
        objects.append(Sphere([0 - x_position, loc[1], loc[2]], size, sphere_model))

        # Create top cylinders
        location = [x_position - size/3, loc[1], loc[2]], [x_position - size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [x_position + size/3, loc[1], loc[2]], [x_position + size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position - size/3, loc[1], loc[2]], [0-x_position - size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position + size/3, loc[1], loc[2]], [0-x_position + size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        # Create bottom spheres
        objects.append(Sphere([x_position, y_position, loc[2]], size, sphere_model))
        objects.append(Sphere([0 - x_position, y_position, loc[2]], size, sphere_model))

        # Create bottom cylinders
        location = [x_position - size/3, y_position, loc[2]], [x_position - size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [x_position + size/3, y_position, loc[2]], [x_position + size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position - size/3, y_position, loc[2]], [0-x_position - size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position + size/3, y_position, loc[2]], [0-x_position + size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        x_position += size * 2

    return objects
コード例 #9
0
def frame(step):
    ''' Creates a sphere, boxes and cones and places it all in a scene '''
    colour_purple = Pigment('color', [
        1,
        0,
        1,
    ])
    colour_aquamarine = Pigment(
        'color',
        [0, 1, 1],
    )
    sphere = Sphere([0, 0, 0], 4, colour_purple)
    side_box_1 = Box(
        [4, -7, -4],
        [5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_2 = Box(
        [-4, -7, -4],
        [-5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_3 = Box(
        [5.5, 5.5, -4],
        [-5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_4 = Box(
        [5.5, -5.5, -4],
        [-5.5, -7, 4],
        colour_aquamarine,
    )
    cone_1 = Cone([0, 7, 0], 3.5, [0, 11, 0], 0, colour_purple)
    cone_2 = Cone([0, -7, 0], 3.5, [0, -11, 0], 0, colour_purple)
    cone_3 = Cone([
        5.5,
        0,
    ], 3.5, [
        9.5,
        0,
    ], 0, colour_purple)
    cone_4 = Cone([-5.5, 0, 0], 3.5, [-9.5, 0, 0], 0, colour_purple)
    # Return the Scene object for rendering
    return Scene(models.default_camera,
                 objects=[
                     models.default_light, side_box_1, side_box_2, side_box_3,
                     side_box_4, cone_1, cone_2, cone_3, cone_4, sphere
                 ])
コード例 #10
0
def scene(step):
    # Storing the cylinders
    cylinders = []
    n = 7
    for i in range(n):
        cylinders.append(
            Cylinder([0, 0, 0], [1.2, 0, 0], 1.0, 1.0, 'scale', [1, 0.25, 1],
                     'rotate', [-30, 0, 0], 'translate', [1.25, 0, 0],
                     'rotate', [0, i * 360 / n, 0], Texture('Chrome_Texture'),
                     Pigment('color', [0.1, 0.1, 0.1]),
                     Finish('phong', 1, 'reflection', 1)))

    # Reset color for the center sphere
    degrees = (360 / (SETTINGS.Duration * SETTINGS.RenderFPS)) * step

    prop = Blob(
        'threshold',
        0.65,
        # Add a Sphere with radius and strength = 1
        Sphere(
            [0, 0, 0],
            1.00,
            1.00,
            # Double the heigth of the Sphere
            'scale',
            [1, 2, 1],
            # Make it shine
            Texture('Chrome_Texture', Pigment('color', [0.1, 0.1, 0.1]),
                    Finish('phong', 0.5, 'reflection', 0.5))),
        # unpack cylinders
        *cylinders,
        # Scale the whole objects (enlarge)
        'scale',
        1.8,
        # rotate counter-clockwise
        'rotate',
        [90, 0, degrees],
        # re-center
        'translate',
        [0, 0.5, 0])

    camera = Camera('location', [5, 10, -8], 'look_at', [0, 0, 0])
    xyz_legend = legend([-10, 0, 0], 3)
    return Scene(
        camera,
        objects=[prop] + xyz_legend + povray.default_spots,
        # The 'Chrome_Texture comes from the 'textures.inc' file
        included=['textures.inc'])
コード例 #11
0
def legend(start_position, axis_length):
    """ Legend function for calling importable legend"""

    # Reduce the AXIS_LENGTH by the length of the Cone (1) so that
    # the total length is exactly the AXIS_LENGTH
    axis_length -= 1

    # Initialize the Cylinder END-position to a COPY of the start position
    cylinder_coords_end = {
        'x': list(start_position),
        'y': list(start_position),
        'z': list(start_position)
    }

    # Add the AXIS_LENGTHs to the corresponding coordinate
    cylinder_coords_end['x'][0] += axis_length
    cylinder_coords_end['y'][1] += axis_length
    cylinder_coords_end['z'][2] += axis_length

    # creation of the Cylinders

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))
    linex = Cylinder(start_position, cylinder_coords_end['x'], 0.1, style)
    liney = Cylinder(start_position, cylinder_coords_end['y'], 0.1, style)
    linez = Cylinder(start_position, cylinder_coords_end['z'], 0.1, style)

    cylinders = {'x': linex, 'y': liney, 'z': linez}

    # Cone START is the same as the Cylinder END, so we COPY these lists
    cones_coords_start = {
        'x': list(cylinder_coords_end['x']),
        'y': list(cylinder_coords_end['y']),
        'z': list(cylinder_coords_end['z'])
    }

    # Copy the START as END coordinate
    cones_coords_end = {
        'x': list(cones_coords_start['x']),
        'y': list(cones_coords_start['y']),
        'z': list(cones_coords_start['z'])
    }

    # Extend the tip of the cones with length 1
    cones_coords_end['x'][0] += 1
    cones_coords_end['y'][1] += 1
    cones_coords_end['z'][2] += 1

    # Creation of the Cones

    conex = Cone(cones_coords_start['x'], 0.5, cones_coords_end['x'], 0, style)
    coney = Cone(cones_coords_start['y'], 0.5, cones_coords_end['y'], 0, style)
    conez = Cone(cones_coords_start['z'], 0.5, cones_coords_end['z'], 0, style)

    cones = {'x': conex, 'y': coney, 'z': conez}

    # Add ALL objects to a LIST and return
    legend_objects = list(cylinders.values()) + list(cones.values())

    return legend_objects
コード例 #12
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def make_receptor(loc, size=5):
    """
    Creates the receptor and returns the object
    """
    rec_model = Texture(Pigment('color', [0, 1, 1], ), Finish('reflection', 0))

    x = loc[0]
    y = loc[1]
    z = loc[2]

    rec = list()
    rec.append(Cylinder([x - size * 1.2, y - size * 15, z], [x - size * 1.2, y + size*2, z], size, rec_model))
    rec.append(Cylinder([x + size * 1.2, y - size * 15, z], [x + size * 1.2, y + size*2, z], size, rec_model))
    rec.append(Cylinder([x - size * 1.2, y + size * 1.2, z], [x - size * 5, y + size * 4, z], size, rec_model))
    rec.append(Cylinder([x - size * 7.2, y + size * 4, z - size/2],
                        [x - size * 3.2, y + size * 4, z - size/2],
                        size / 1.321, rec_model))

    rec.append(Cylinder([x + size * 1.2, y + size * 1.2, z], [x + size * 5, y + size * 4, z], size, rec_model))
    rec.append(Cylinder([x + size * 7.2, y + size * 4, z - size/2],
                        [x + size * 3.2, y + size * 4, z - size/2],
                        size / 1.321, rec_model))

    rec.append(Sphere([x, y - size * 6, z], size * 3, rec_model))

    return rec
コード例 #13
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])
コード例 #14
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)
コード例 #15
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)
コード例 #16
0
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
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def make_tyrine(loc, size):
    """
    Creates the tyrine molecules
    """
    text_model = Texture(Pigment('color', [1, 1, 0], ), Finish('reflection', 0))
    cyl_model = Texture(Pigment('color', [0, 1, 0.5], ), Finish('reflection', 0))

    tyr = []
    y_always = [13, 13, 10, 10]
    x_text = [-3, 5, -3, 5]
    x_end = [-5, 5, -5, 5]
    x = loc[0]
    y = loc[1]
    z = loc[2] + 7
    for _ in range(4):
        tyr.append(Cylinder([x, y-size * y_always[_], z], [x-size*x_end[_], y-size*y_always[_], z], size, cyl_model))
        text = Text('ttf', '"timrom.ttf"', '"{}"'.format(str('Tyr')), 2, [0, 0, 0], text_model, 'scale', 5, 'translate', [x-size*x_text[_], y-size*y_always[_], z - 7])
        tyr.append(text)
    return tyr
コード例 #18
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)
コード例 #19
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")
コード例 #20
0
ファイル: eindopdracht.py プロジェクト: wouterzeevat/thema2
def bind_IRS(frame, size):
    """
    Animating the process of IRS binding to the phosfor
    """

    IRS_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0))
    text_model = Texture(Pigment('color', [1, 1, 0], ), Finish('reflection', 0))

    IRS = []
    s = size

    # frame 570 -> 630
    if frame < 630:
        x = (frame - 570) * ((7*s-30*s) / 60) + 30*s
        y = -12*s
    else:
        x = 7*s
        y = -12*s

    IRS.append(Sphere([x, y, 0], s * 2, IRS_model))
    IRS.append(Text('ttf', '"timrom.ttf"', '"{}"'.format(str('IRS')), 0.5, [0, 0, 0], text_model, 'scale', 5, 'translate', [x - s, y, -2*s]))
    return IRS
コード例 #21
0
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),
                     Finish('phong', 0.8, 'reflection', 0.5))
    for i in range(spheres):
        ring.append(Sphere([0, 0, 0], ring_node_size, smodel,
                           'translate', [RADIUS, 0, 0],
                           'rotate', [0, 360/spheres * i, 0]))
    return ring
コード例 #22
0
def frame(step):
    """ Returns the scene at the given step  """
    # Show some information about how far we are with rendering
    curr_time = step * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    ## Rotating sphere, placed in the center
    sphere_rad = 1.8
    sphere = Sphere([0, 0, 0], sphere_rad,
                    Pigment('color', [0.9, 0.05, 0.05], 'filter', 0.7),
                    Interior('ior', 1), Finish('phong', 0.6, 'reflection', 0.4))

    # Intersecting cylinder object
    rod = Cylinder([0, 0, 3], [0, 0, -3],
                   1.0, 'open', Pigment('color', [1, 0, 0], 'filter', 0.8),
                   Interior('ior', 1), Finish('phong', 0, 'reflection', 0))

    # 'Hollow out' the rotating sphere with the intersecting cylinder using the Difference,
    # move to a spot on the circle (top) and rotate on the x-axis
    traveller = Difference(sphere, rod, 'translate', [RADIUS, 0, 0],
                           'rotate', [0, 360/eval(SETTINGS.NumberFrames)*step*2, 0])

    return Scene(CAMERA, objects=[GROUND, MAIN_LIGHT, BACK_LIGHT, traveller] + RING)
コード例 #23
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)
コード例 #24
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)
コード例 #25
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])
コード例 #26
0
ファイル: vapory.py プロジェクト: tpvasconcelos/mdsea
    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)
コード例 #27
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])
コード例 #28
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """
    sphere_model = Texture(Pigment(
        'color',
        [250, 0, 0],
    ), Finish('reflection', 0.5))

    # 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 = -5
    x_end = 5
    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

    y_coord = 2 * math.sin((2 * math.pi / 2) * (x_coord - 1)) + 0.5
    # Create sphere at calculated x-coordinate using default model
    sphere = Sphere([x_coord, y_coord, 0], 1, sphere_model)

    # Return the Scene object containing all objects for rendering
    return Scene(models.default_camera, objects=[sphere, models.default_light])
コード例 #29
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()

    step_in_frame = step
    two_fifth_of_animation = n_frames // 5 * 2
    three_fifth_of_animation = n_frames // 5 * 3

    VESICLE = Sphere([100, 0, 0], 20, Texture(Pigment('color', [0.7, 1, 1], 'filter', 0.6),
                                              Finish('phong', 0.4, 'reflection', 0.2)))

    camera_z = -100
    # Creation of RNA molecule
    if step in range(0, two_fifth_of_animation):
        create_first_part(step_in_frame, two_fifth_of_animation + 1)

    # Sphere covering the RNA molecule
    if step in range(two_fifth_of_animation, three_fifth_of_animation + 1):
        NUCL_1.move_offset([50, 0, 0])
        NUCL_2.move_offset([50, 0, 0])
        NUCL_3.move_offset([50, 0, 0])
        NUCL_4.move_offset([50, 0, 0])
        NUCL_5.move_offset([50, 0, 0])
        NUCL_6.move_offset([50, 0, 0])
        NUCL_7.move_offset([50, 0, 0])

        step_in_frame = step - two_fifth_of_animation
        x_start = 100
        x_end = -50

        distance_x = x_end - x_start
        distance_per_frame_x = (distance_x / three_fifth_of_animation) * 2

        x_coord = x_start + step_in_frame * distance_per_frame_x
        y_coord = 2 * sin(x_coord/5)
        print(y_coord)

        VESICLE = Sphere([x_coord, y_coord, 0], 20, Texture(Pigment('color', [0.7, 1, 1], 'filter', 0.6),
                                                            Finish('phong', 0.4, 'reflection', 0.2)))


    # Vesicle growth
    if step in range(n_frames // 5 * 3, n_frames // 5 * 4 + 1):
        NUCL_1.move_offset([50, 0, 0])
        NUCL_2.move_offset([50, 0, 0])
        NUCL_3.move_offset([50, 0, 0])
        NUCL_4.move_offset([50, 0, 0])
        NUCL_5.move_offset([50, 0, 0])
        NUCL_6.move_offset([50, 0, 0])
        NUCL_7.move_offset([50, 0, 0])
        VESICLE = Sphere([0, 0, 0], 20, Texture(Pigment('color', [0.7, 1, 1], 'filter', 0.6),
                                                            Finish('phong', 0.4, 'reflection', 0.2)))
        # camere movement
        if step in range(n_frames // 5 * 3, n_frames // 5 * 4 // 2):
            camera_z_start = -100
            camera_z_end = -150
            distance_camera_z = camera_z_end - camera_z_start
            z_camera_coord = step_in_frame * distance_per_frame - camera_z_start
    # # Sphere division
    # if step in range(n_frames // 5 * 4, n_frames):

    # Return the Scene object for rendering
    return Scene(Camera('location', [0, 0, camera_z], 'look_at', [0, 0, 0]),
                 objects=[models.default_light, VESICLE] + NUCL_1.povray_molecule + NUCL_2.povray_molecule +
                 NUCL_3.povray_molecule + NUCL_4.povray_molecule + NUCL_5.povray_molecule +
                         NUCL_6.povray_molecule + NUCL_7.povray_molecule)
コード例 #30
0
def legend(start_position, axis_length):
    """
    Returns the objects of a legend
    :param start_position: the position where the legend is rendered
    :param axis_length: the length of each line+arrow in the x, y and z direction
    :return legend_objects: the objects of a legend
    """

    # Reduce the AXIS_LENGTH by the length of the Cone (1) so that
    # the total length is exactly the AXIS_LENGTH
    axis_length -= 1

    # Initialize the Cylinder END-position to a COPY of the start position
    cylinder_coords_end = {
        'x': list(start_position),
        'y': list(start_position),
        'z': list(start_position)
    }

    # Add the AXIS_LENGTHs to the corresponding coordinate
    cylinder_coords_end['x'][0] += axis_length
    cylinder_coords_end['y'][1] += axis_length
    cylinder_coords_end['z'][2] += axis_length
    ''' CREATE THE CYLINDERS'''
    cylinders = {
        'x':
        Cylinder(start_position, cylinder_coords_end['x'], 0.1,
                 Texture(Pigment('color', [1, 0, 0]), Finish('reflection',
                                                             1))),
        'y':
        Cylinder(start_position, cylinder_coords_end['y'], 0.1,
                 Texture(Pigment('color', [0, 0, 1]), Finish('reflection',
                                                             1))),
        'z':
        Cylinder(start_position, cylinder_coords_end['z'], 0.1,
                 Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1)))
    }

    # Cone START is the same as the Cylinder END, so we COPY these lists
    cones_coords_start = {
        'x': list(cylinder_coords_end['x']),
        'y': list(cylinder_coords_end['y']),
        'z': list(cylinder_coords_end['z'])
    }

    # Copy the START as END coordinate
    cones_coords_end = {
        'x': list(cones_coords_start['x']),
        'y': list(cones_coords_start['y']),
        'z': list(cones_coords_start['z'])
    }

    # Extend the tip of the cones with length 1
    cones_coords_end['x'][0] += 1
    cones_coords_end['y'][1] += 1
    cones_coords_end['z'][2] += 1
    ''' CREATE THE CONES '''
    cones = {
        'x':
        Cone(cones_coords_start['x'], 0.3, cones_coords_end['x'], 0,
             Texture(Pigment('color', [1, 0, 0]), Finish('reflection', 1))),
        'y':
        Cone(cones_coords_start['y'], 0.3, cones_coords_end['y'], 0,
             Texture(Pigment('color', [0, 0, 1]), Finish('reflection', 1))),
        'z':
        Cone(cones_coords_start['z'], 0.3, cones_coords_end['z'], 0,
             Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1))),
    }

    # Add ALL objects to a LIST and return
    legend_objects = list(cylinders.values()) + list(cones.values())
    return legend_objects