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 #, SphericalLight |
|
5 import Image |
|
6 |
4 |
7 rt = Raytracer() |
5 rt = Raytracer() |
|
6 top = KdTree() |
|
7 rt.setTop(top) |
|
8 rt.setCamera(Camera()) |
8 |
9 |
9 light1 = Light(position=(0.0, 4.0, -3.0), colour=(0.9, 0.3, 0.6)) |
10 light1 = Light(position=(0.0, 4.0, -3.0), colour=(0.9, 0.3, 0.6)) |
10 rt.addLight(light1) |
11 rt.addLight(light1) |
11 |
12 |
12 #light2 = SphericalLight(position=(-2.0, 5.0, 1.0), radius=3.0, colour=(0.7, 1.0, 0.3)) |
13 #light2 = SphericalLight(position=(-2.0, 5.0, 1.0), radius=3.0, colour=(0.7, 1.0, 0.3)) |
36 mat3.setReflectivity(0.1) |
37 mat3.setReflectivity(0.1) |
37 for i in range(10): |
38 for i in range(10): |
38 sph = Sphere(centre=(-5.0+i, -1.5, -4.0), radius=0.5, material=mat3) |
39 sph = Sphere(centre=(-5.0+i, -1.5, -4.0), radius=0.5, material=mat3) |
39 rt.addShape(sph) |
40 rt.addShape(sph) |
40 |
41 |
41 rendersize = (800, 600) |
42 top.optimize() |
42 data = rt.render(rendersize) |
43 |
43 img = Image.fromstring("RGB", rendersize, data) |
44 sampler = DefaultSampler(800, 600) |
44 img.save('spheres_glass.png') |
45 rt.setSampler(sampler) |
|
46 rt.render() |
|
47 sampler.getPixmap().writePNG('spheres_glass.png') |