#!/usr/bin/python3 import sys, logging, time from Scene import Scene logging.basicConfig(level=logging.DEBUG) s = Scene() s.fromFile(sys.argv[1]) running = [] times = sorted(s.commands.keys()) t = 0 while t <= s.getDuration(): ## Check if we reached a new command ## if (len(times) > 0) and (t >= times[0]): for c in s.commands[times[0]]: print("%10dms: BEG: %s" % (t, c)) running.append((t, c)) times.pop(0) ## Maintain running commands ## stillRunning = [] for c in running: res = c[1].maintain(t-c[0]) if res == 0: stillRunning.append(c) elif res == 1: print("%10dms: END: %s" % (t, c[1])) elif res == 2: stillRunning.append(c) print("%10dms: RST: %s" % (t, c[1])) t -= 1 else: raise ValueError()
rRef= Utility.getRef1(ray,p,closestObj,scene,closestObj.reflectionFactor,r) image.colors[i][j] = rRef*closestObj.reflectionFactor + r print("\nimage rendered in {:.2f} seconds".format(time.time()-start_time)) Scene.writeImage(camera.outFile,image) print("image file is ready [{}]".format(camera.outFile)) import subprocess opener ="open" if sys.platform == "darwin" else "xdg-open" subprocess.call([opener, camera.outFile]) camera = Camera.fromFile(sys.argv[1]) scene = Scene.fromFile(sys.argv[2]) if (len(sys.argv)>3): op=int(sys.argv[3]) print(camera) print(scene) print([str(v) for v in scene.lights]) image = Image.getBlankImage(camera.sizeX,camera.sizeY,0.0,0.0,0.0) render(op,camera,scene,image) # Uncomment for animation # import time # for i in range(100):