demos/triangles_sphere.py
branchpyrit
changeset 90 f6a72eb99631
parent 75 20dee9819b17
child 95 ca7d4c665531
--- 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')