demos/car.py
branchpyrit
changeset 90 f6a72eb99631
parent 75 20dee9819b17
child 96 9eb71e76c7fd
--- a/demos/car.py	Tue Apr 29 13:56:29 2008 +0200
+++ b/demos/car.py	Tue Apr 29 23:31:08 2008 +0200
@@ -1,12 +1,12 @@
 #!/usr/bin/python
 
-from raytracer import Raytracer, Light, Sphere, Triangle, Material, Camera
+from pyrit import *
 from lworeader import LoadLightwaveLwoFile
-import Image
 from math import *
 
 rt = Raytracer()
-
+top = KdTree()
+rt.setTop(top)
 cam = Camera(eye=(0.,2.,8.))
 rotx=0.15
 cam.rotate((cos(rotx),-sin(rotx),0.,0.))
@@ -19,7 +19,9 @@
 light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7))
 rt.addLight(light2)
 
-imagesize = (800, 600)
-data = rt.render(imagesize)
-img = Image.fromstring("RGB", imagesize, data)
-img.save('car.png')
+top.optimize()
+
+sampler = DefaultSampler(800, 600)
+rt.setSampler(sampler)
+rt.render()
+sampler.getPixmap().writePNG('car.png')