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'])
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'])
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)
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)
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)
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)
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]
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)
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)
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 ])
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)
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'])
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
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)
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 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")
def move_camera(frame, frames, start, end, start_frame): """ Animating the zooming into the binding process part """ # Frame 120 -> 180 x = (frame - start_frame) * ((end[0] - start[0]) / frames) + start[0] y = (frame - start_frame) * ((end[1] - start[1]) / frames) + start[1] z = (frame - start_frame) * ((end[2] - start[2]) / frames) + start[2] camera = Camera('location', [x, y, z], 'look_at', [x, y, z + 1]) return camera
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)
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)
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'])
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)
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)
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)
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)
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)
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) # obtain molecules from function create_molecules() # Creation of RNA molecule step_in_frame = step two_fifth_of_animation = n_frames // 5 * 2 if step in range(0, two_fifth_of_animation): create_first_part(step_in_frame, two_fifth_of_animation) # Return the Scene object for rendering return Scene(Camera('location', [0, 0, -50], 'look_at', [0, 0, 0]), objects=[models.default_light] + URACIL_ONE.povray_molecule + ADENINE.povray_molecule + ADENINE_TWO.povray_molecule + GUANINE.povray_molecule + CYTOSINE.povray_molecule)
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])
def frame(step): """ Returns the scene at step number (1 step per frame) """ cylinder = Cylinder([-6, -1, 4], [-6, 8, 4], 4, models.default_sphere_model) sphere = Sphere([6, 2, -2], 3, models.default_sphere_model) xyz_legend = legend([-15, 0, 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) distance_per_frame = 50 / nframes z_start = -25 z_end = 25 if step < (nframes / 2): z = z_start + step * distance_per_frame x = math.sqrt(25**2 - z**2) else: z = z_end - step * distance_per_frame x = -1 * math.sqrt(25**2 - z**2) 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, cylinder, models.checkered_ground, models.default_light ])
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)
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)