def main(): print('Reading ...') start = datetime.datetime.now() # data source name data_source_name = 'better-ball.d' # shading type: # 0 - no shading (framework) # 1 - constant shading # 2 - Gouraud shading # 3 - Phong shading shading = 3 world_space = Space() world_space.append_by_file(data_source_name + '.txt') # geometry data camera = Camera() camera.set_by_file(data_source_name + '.camera.txt') # camera profile light = Light() light.set_by_file(data_source_name + '.light.txt') # light profile material = Material() material.set_by_file(data_source_name + '.material.txt') # material profile illumination = Illumination() illumination.set(camera, light, material, shading) display = Display() display.set(800) # change window size cost = datetime.datetime.now() - start print('Finish. (cost = ' + str(cost) + ')\n') print('Calculating: transform ...') start = datetime.datetime.now() view_space = copy.deepcopy(world_space) view_space.transform(world_to_view, camera) screen_space = copy.deepcopy(view_space) screen_space.transform(view_to_screen, camera) device_space = copy.deepcopy(screen_space) device_space.transform(screen_to_device, display) cost = datetime.datetime.now() - start print('Finish. (cost = ' + str(cost) + ')\n') window = Window() window.set(world_space, device_space, illumination, display) window.show()
def main(): print('Reading ...') start = datetime.datetime.now() ball = 'data' + os.sep + 'better-ball.d' lay = Lay() lay.set_by_file(ball + '.lay.p') local_space = Space() local_space.append_by_file(ball) camera = Camera() camera.set_by_file('data' + os.sep + 'camera.p') display = Display() display.set_by_file('data' + os.sep + 'display.p') light = Light() light.set_by_file('data' + os.sep + 'light.p') shading = Shading() shading.set_by_file('data' + os.sep + 'shading.p') texture = Texture(True) # enable texture (in Phong shading) cost = datetime.datetime.now() - start print('Finish. (cost = ' + str(cost) + ')\n') print('Calculating: transform ...') start = datetime.datetime.now() world_space = copy.deepcopy(local_space) world_space.transform(local_to_world, lay) device_space = copy.deepcopy(world_space) device_space.transform(world_to_view, camera) device_space.transform(view_to_screen, camera) device_space.transform(screen_to_device, display) cost = datetime.datetime.now() - start print('Finish. (cost = ' + str(cost) + ')\n') window = Window() window.set(world_space, device_space, camera, display, light, shading, texture, lay) window.show()
def main(): print('Reading ...') start = datetime.datetime.now() ball_1 = 'data' + os.sep + 'better-ball.1.d' ball_2 = 'data' + os.sep + 'better-ball.2.d' ball_3 = 'data' + os.sep + 'better-ball.3.d' lay_ball_1 = Lay() lay_ball_1.set_by_file(ball_1 + '.lay.p') lay_ball_2 = Lay() lay_ball_2.set_by_file(ball_2 + '.lay.p') lay_ball_3 = Lay() lay_ball_3.set_by_file(ball_3 + '.lay.p') local_space_ball_1 = Space() local_space_ball_1.append_by_file(ball_1) local_space_ball_2 = Space() local_space_ball_2.append_by_file(ball_2) local_space_ball_3 = Space() local_space_ball_3.append_by_file(ball_3) camera = Camera() camera.set_by_file('data' + os.sep + 'camera.p') display = Display() display.set_by_file('data' + os.sep + 'display.p') light = Light() light.set_by_file('data' + os.sep + 'light.p') shading = Shading() shading.set_by_file('data' + os.sep + 'shading.p') cost = datetime.datetime.now() - start print('Finish. (cost = ' + str(cost) + ')\n') print('Calculating: transform ...') start = datetime.datetime.now() world_space = Space() temp = copy.deepcopy(local_space_ball_1) temp.transform(local_to_world, lay_ball_1) world_space.append_by_space(temp) temp = copy.deepcopy(local_space_ball_2) temp.transform(local_to_world, lay_ball_2) world_space.append_by_space(temp) temp = copy.deepcopy(local_space_ball_3) temp.transform(local_to_world, lay_ball_3) world_space.append_by_space(temp) device_space = copy.deepcopy(world_space) device_space.transform(world_to_view, camera) device_space.transform(view_to_screen, camera) device_space.transform(screen_to_device, display) cost = datetime.datetime.now() - start print('Finish. (cost = ' + str(cost) + ')\n') window = Window() window.set(world_space, device_space, camera, display, light, shading) window.show()