diff -r fcf1487b398b -r f6a72eb99631 demos/buddha.py --- a/demos/buddha.py Tue Apr 29 13:56:29 2008 +0200 +++ b/demos/buddha.py Tue Apr 29 23:31:08 2008 +0200 @@ -3,20 +3,24 @@ # this demo needs buddha model from # http://graphics.stanford.edu/data/3Dscanrep/ -from raytracer import Raytracer, Light, Sphere, Triangle, Material +from pyrit import * from plyreader import LoadStanfordPlyFile -import Image rt = Raytracer() +top = KdTree() +rt.setTop(top) +rt.setCamera(Camera()) + +light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6)) +rt.addLight(light) + mat = Material(colour=(0.9, 0.9, 0.9)) mat.setSmooth(True) LoadStanfordPlyFile(rt, "../models/ply/happy/happy_vrip_res2.ply", mat, scale=20.0, trans=(0,-3,0)) - -light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6)) -rt.addLight(light) +top.optimize() -imagesize = (800, 600) -data = rt.render(imagesize) -img = Image.fromstring("RGB", imagesize, data) -img.save('buddha.png') +sampler = DefaultSampler(800, 600) +rt.setSampler(sampler) +rt.render() +sampler.getPixmap().writePNG('buddha.png')