demos/boxes.py
branchpyrit
changeset 90 f6a72eb99631
parent 75 20dee9819b17
child 95 ca7d4c665531
--- a/demos/boxes.py	Tue Apr 29 13:56:29 2008 +0200
+++ b/demos/boxes.py	Tue Apr 29 23:31:08 2008 +0200
@@ -1,9 +1,11 @@
 #!/usr/bin/python
 
-from raytracer import Raytracer, Material, Box, Light
-import Image
+from pyrit import *
 
 rt = Raytracer()
+top = Octree()
+rt.setTop(top)
+rt.setCamera(Camera())
 
 light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6))
 rt.addLight(light1)
@@ -19,7 +21,9 @@
 			box = Box(L=(-4.3+x, -4.6+y, -8.6+z), H=(-3.7+x, -4.0+y, -8.0+z), material=mat0)
 			rt.addShape(box)
 
-imagesize = (800, 600)
-data = rt.render(imagesize)
-img = Image.fromstring("RGB", imagesize, data)
-img.save('boxes.png')
+top.optimize()
+
+sampler = DefaultSampler(800, 600)
+rt.setSampler(sampler)
+rt.render()
+sampler.getPixmap().writePNG('boxes.png')