diff -r fcf1487b398b -r f6a72eb99631 demos/render_nff.py --- a/demos/render_nff.py Tue Apr 29 13:56:29 2008 +0200 +++ b/demos/render_nff.py Tue Apr 29 23:31:08 2008 +0200 @@ -4,16 +4,25 @@ # see http://tog.acm.org/resources/SPD/ # cylinders are not implemented -from raytracer import Raytracer, Camera, Light, Material, Sphere, NormalVertex, Triangle +from pyrit import * from math import pi -import sys, Image +import sys rt = Raytracer() +top = KdTree() +rt.setTop(top) +rt.setCamera(Camera()) + imagesize = (800, 600) mat = Material(colour=(1.0, 1.0, 1.0)) f = sys.stdin +fbase = "render_nff" +if len(sys.argv) > 1: + f = open(sys.argv[1]) + fbase = sys.argv[1].rsplit('.',1)[0] + while True: line = f.readline() if line == "": @@ -90,6 +99,9 @@ print "Not implemented:", line f.close() -data = rt.render(imagesize) -img = Image.fromstring("RGB", imagesize, data) -img.save('render_nff.png') +top.optimize() + +sampler = DefaultSampler(imagesize) +rt.setSampler(sampler) +rt.render() +sampler.getPixmap().writePNG(fbase+'.png')