--- a/demos/triangles_sphere.py Tue Apr 29 13:56:29 2008 +0200
+++ b/demos/triangles_sphere.py Tue Apr 29 23:31:08 2008 +0200
@@ -1,12 +1,12 @@
#!/usr/bin/python
-from raytracer import Raytracer, Light, Sphere, Triangle, NormalVertex, Material
+from pyrit import *
from objreader import LoadWavefrontObjFile
-import Image
rt = Raytracer()
-mat = Material(colour=(0.9, 0.9, 0.9))
-LoadWavefrontObjFile(rt, "../models/obj/sphere.obj", mat, 1.5)
+top = KdTree()
+rt.setTop(top)
+rt.setCamera(Camera())
light1 = Light(position=(0.0, 2.0, 6.0), colour=(0.9, 0.3, 0.6))
light1.castShadows(False);
@@ -16,7 +16,11 @@
light2.castShadows(False);
rt.addLight(light2)
-imagesize = (800, 600)
-data = rt.render(imagesize)
-img = Image.fromstring("RGB", imagesize, data)
-img.save('triangles_sphere.png')
+mat = Material(colour=(0.9, 0.9, 0.9))
+LoadWavefrontObjFile(rt, "../models/obj/sphere.obj", mat, 1.5)
+top.optimize()
+
+sampler = DefaultSampler(800, 600)
+rt.setSampler(sampler)
+rt.render()
+sampler.getPixmap().writePNG('triangles_sphere.png')