def frame(step): lichtje = LightSource([2, 8, -5], 5.0) default_camera = Camera('location', [0, 4, -40], 'look_at', [0, 2, -5]) ''' Creates a sphere and places this in a scene ''' 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) shapes = legend([-15, 0, 0], 5) # Return the Scene object for rendering return Scene(default_camera, objects=[ lichtje, centerball, boxright, boxleft, boxupper, boxbottom, conetop, conebottom, coneleft, coneright ] + shapes, included=['colors.inc'])
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): 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): """ 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 make_objects(): global SPHERE, CYLINDER, LEGEND SPHERE = Sphere([6, 2, -2], 3, models.default_sphere_model) CYLINDER = Cylinder([-6, -1, 4], [-6, 7, 4], 3, models.default_sphere_model) LEGEND = legend([-15, 0, 0], 5)
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): """ 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) # 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)