--- a/demos/spheres_ao.py Tue Apr 29 13:56:29 2008 +0200
+++ b/demos/spheres_ao.py Tue Apr 29 23:31:08 2008 +0200
@@ -1,9 +1,11 @@
#!/usr/bin/python
-from raytracer import Raytracer, Material, Box, Sphere, Light
-import Image
+from pyrit import *
rt = Raytracer()
+top = KdTree()
+rt.setTop(top)
+rt.setCamera(Camera())
rt.ambientOcclusion(samples=100, distance=16.0, angle=0.5)
light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6))
@@ -31,7 +33,9 @@
tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3)
rt.addShape(tinysphere)
-imagesize = (800, 600)
-data = rt.render(imagesize)
-img = Image.fromstring("RGB", imagesize, data)
-img.save('spheres_ao.png')
+top.optimize()
+
+sampler = DefaultSampler(800, 600)
+rt.setSampler(sampler)
+rt.render()
+sampler.getPixmap().writePNG('spheres_ao.png')