57
|
1 |
#!/usr/bin/python
|
|
2 |
|
|
3 |
from raytracer import Raytracer, Material, Box, Light
|
|
4 |
import Image
|
|
5 |
|
|
6 |
rt = Raytracer()
|
|
7 |
|
|
8 |
light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6))
|
|
9 |
rt.addlight(light1)
|
|
10 |
|
|
11 |
light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3))
|
|
12 |
rt.addlight(light2)
|
|
13 |
|
|
14 |
mat0 = Material(colour=(0.7, 0.7, 0.7))
|
|
15 |
mat0.setReflectivity(0.0)
|
|
16 |
for x in range(8):
|
|
17 |
for y in range(8):
|
|
18 |
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)
|
|
20 |
rt.addshape(box)
|
|
21 |
|
|
22 |
imagesize = (800, 600)
|
|
23 |
data = rt.render(imagesize)
|
|
24 |
img = Image.fromstring("RGB", imagesize, data)
|
|
25 |
img.save('boxes.png')
|