def main(args): """ Runs the simulation """ if args.config: pypovray.SETTINGS = load_config(args.config) if args.range: # User entered a range of frames to render start, stop = ast.literal_eval(args.range) frame_range = range(start, stop) else: # No range entered, use default 0, n_frames print(pypovray.SETTINGS.NumberFrames) frame_range = range(0, eval(pypovray.SETTINGS.NumberFrames)) if args.time: # User entered the specific timepoint to render (in seconds) pypovray.render_scene_to_png(frame, args.time) else: # No output file type and no specific time, exit if not args.gif and not args.mp4 and not args.range: parser.print_help() sys.exit("\nPlease specify either a specific time point, range of frames" \ " or output format for a movie file") # Render a movie, depending on output type selected (both files is possible) if args.gif: pypovray.render_scene_to_gif(frame, frame_range) if args.mp4: pypovray.render_scene_to_mp4(frame, frame_range) return 0
def main(args): """ Runs the simulation """ # Load a user defined configuration file if args.config: pypovray.SETTINGS = load_config(args.config) if args.frame: # Create objects for the scene (i.e. parse PDB files) scene_objects() # User entered the specific frame to render pypovray.render_scene_to_png(frame, args.frame) else: # No output file type and no specific frame, exit if not args.gif and not args.mp4: parser.print_help() sys.exit('\nPlease specify either a specific frame number or ' + 'output format for a movie file') else: # Create objects for the scene (i.e. parse PDB files) scene_objects() # Render a movie, depending on output type selected (both files is possible) if args.gif: pypovray.render_scene_to_gif(frame) if args.mp4: pypovray.render_scene_to_mp4(frame) return 0
def main(args): """ Main function performing the rendering """ # Checks how to run animation depending on given arguments if len(args) < 2: pydoc.help(__name__) elif len(args) < 3: if args[1] == "-": pypovray.render_scene_to_mp4(frame) else: pypovray.render_scene_to_png(frame, int(args[1])) elif len(args) < 4: pypovray.render_scene_to_mp4(frame, range(int(args[1]), int(args[2]) + 1)) else: pydoc.help(__name__) return 0
[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 ]) if __name__ == '__main__': # Render as an image pypovray.render_scene_to_png(frame)
[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] 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) if __name__ == '__main__': # If module not imported pypovray.render_scene_to_png(frame) # Render as an image
The Cylinder is first placed at [0, 0, 0] and extended on the y-axis (from -lipo_length to +lipo_length), then it is rotated using the 'angle' stored in coord[3] and finally positioned at the location of the added Sphere using the 'translate' function: 'translate': http://www.f-lohmueller.de/pov_tut/trans/trans_100e.htm 'rotate': http://www.f-lohmueller.de/pov_tut/trans/trans_200e.htm An alternative method would be to use the angle and the Sphere coordinate to calculate the Cylinder start- and end-point. ''' cyl = Cylinder([0, -lipo_length, 0], [0, lipo_length, 0], 0.5, Pigment('color', [1, 0, 0])) bottom_sphere = Sphere([0, -lipo_length, 0], 1, Pigment('color', [1, 0, 0])) top_sphere = Sphere([0, lipo_length, 0], 1, Pigment('color', [1, 0, 0])) lipos.append( Merge(cyl, top_sphere, bottom_sphere, 'rotate', [0, 0, coord[3]], 'translate', [coord[0], coord[1], coord[2]])) # The camera looks straight at the membrane otherwise the vesicle looks like an ellipse camera = Camera('location', [0, 0, -60], 'look_at', [0, 0, 0]) return Scene(camera, objects=[models.default_light] + spheres + lipos) if __name__ == '__main__': # Uncomment to use prototype settings #SETTINGS = povray.SETTINGS = load_config('prototype.ini') #pypovray.render_scene_to_gif(scene) pypovray.render_scene_to_png(scene, 5)
def main(args): """ Main function of this program """ logger.info(" Total time: %d (frames: %d)", SETTINGS.Duration, eval(SETTINGS.NumberFrames)) pypovray.render_scene_to_png(frame) return 0