equal
deleted
inserted
replaced
|
1 #!/usr/bin/python |
|
2 |
|
3 import sys |
|
4 sys.path.append(open('ModulePath').read().strip()) |
|
5 |
|
6 from raytracer import Raytracer, Material, Box, Light |
|
7 import Image |
|
8 |
|
9 rt = Raytracer() |
|
10 |
|
11 light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) |
|
12 rt.addlight(light1) |
|
13 |
|
14 light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3)) |
|
15 rt.addlight(light2) |
|
16 |
|
17 mat0 = Material(colour=(0.7, 0.7, 0.7)) |
|
18 mat0.setReflectivity(0.0) |
|
19 for x in range(8): |
|
20 for y in range(8): |
|
21 for z in range(8): |
|
22 box = Box(L=(-4.3+x, -4.6+y, -8.6+z), H=(-3.7+x, -4.0+y, -8.0+z), material=mat0) |
|
23 rt.addshape(box) |
|
24 |
|
25 imagesize = (800, 600) |
|
26 data = rt.render(imagesize) |
|
27 img = Image.fromstring("RGB", imagesize, data) |
|
28 img.save('boxes.png') |