equal
deleted
inserted
replaced
1 #!/usr/bin/python |
1 #!/usr/bin/python |
2 |
2 |
3 from raytracer import Raytracer, Material, Box, Light |
3 from pyrit import * |
4 import Image |
|
5 |
4 |
6 rt = Raytracer() |
5 rt = Raytracer() |
|
6 top = Octree() |
|
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)) |
17 for y in range(8): |
19 for y in range(8): |
18 for z in range(8): |
20 for z in range(8): |
19 box = Box(L=(-4.3+x, -4.6+y, -8.6+z), H=(-3.7+x, -4.0+y, -8.0+z), material=mat0) |
21 box = Box(L=(-4.3+x, -4.6+y, -8.6+z), H=(-3.7+x, -4.0+y, -8.0+z), material=mat0) |
20 rt.addShape(box) |
22 rt.addShape(box) |
21 |
23 |
22 imagesize = (800, 600) |
24 top.optimize() |
23 data = rt.render(imagesize) |
25 |
24 img = Image.fromstring("RGB", imagesize, data) |
26 sampler = DefaultSampler(800, 600) |
25 img.save('boxes.png') |
27 rt.setSampler(sampler) |
|
28 rt.render() |
|
29 sampler.getPixmap().writePNG('boxes.png') |