equal
  deleted
  inserted
  replaced
  
    
    
     1 #!/usr/bin/python  | 
     1 #!/usr/bin/python  | 
     2   | 
     2   | 
     3 from raytracer import Raytracer, Material, Box, Sphere, Light  | 
     3 from pyrit import *  | 
     4 import Image  | 
         | 
     5   | 
     4   | 
     6 rt = Raytracer()  | 
     5 rt = Raytracer()  | 
         | 
     6 top = KdTree()  | 
         | 
     7 rt.setTop(top)  | 
         | 
     8 rt.setCamera(Camera())  | 
     7   | 
     9   | 
     8 light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6))  | 
    10 light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6))  | 
     9 rt.addLight(light1)  | 
    11 rt.addLight(light1)  | 
    10   | 
    12   | 
    11 light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3))  | 
    13 light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3))  | 
    26   | 
    28   | 
    27 mat3 = Material(colour=(0.0, 0.0, 1.0))  | 
    29 mat3 = Material(colour=(0.0, 0.0, 1.0))  | 
    28 tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3)  | 
    30 tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3)  | 
    29 rt.addShape(tinysphere)  | 
    31 rt.addShape(tinysphere)  | 
    30   | 
    32   | 
    31 imagesize = (800, 600)  | 
    33 top.optimize()  | 
    32 data = rt.render(imagesize)  | 
    34   | 
    33 img = Image.fromstring("RGB", imagesize, data) | 
    35 sampler = DefaultSampler(800, 600)  | 
    34 img.save('spheres_shadow.png') | 
    36 rt.setSampler(sampler)  | 
         | 
    37 rt.render()  | 
         | 
    38 sampler.getPixmap().writePNG('spheres_shadow.png') |