3 from pyrit import * |
3 from pyrit import * |
4 |
4 |
5 rt = Raytracer() |
5 rt = Raytracer() |
6 top = KdTree() |
6 top = KdTree() |
7 rt.setTop(top) |
7 rt.setTop(top) |
8 rt.setCamera(Camera()) |
8 rt.setCamera(Camera(eye=(10,4,-6),lookat=(10,3.5,0))) |
9 |
9 |
10 light1 = Light(position=(0.0, 4.0, -3.0), colour=(0.9, 0.3, 0.6)) |
10 light1 = Light(position=(10.0, 7.0, 3.0), colour=(0.9, 0.3, 0.6)) |
11 rt.addLight(light1) |
11 rt.addLight(light1) |
12 |
12 |
13 #light2 = SphericalLight(position=(-2.0, 5.0, 1.0), radius=3.0, colour=(0.7, 1.0, 0.3)) |
13 light2 = Light(position=(8.0, 5.0, 1.0), colour=(0.7, 1.0, 0.3)) |
14 light2 = Light(position=(-2.0, -4.0, -1.0), colour=(0.7, 1.0, 0.3)) |
|
15 rt.addLight(light2) |
14 rt.addLight(light2) |
16 |
15 |
17 light2 = Light(position=(2.0, 5.0, 1.0), colour=(0.8, 0.9, 1.0)) |
16 light3 = Light(position=(12.0, 8.0, -1.0), colour=(0.8, 0.9, 1.0)) |
18 rt.addLight(light2) |
17 rt.addLight(light3) |
19 |
18 |
20 mat0 = Material(colour=(0.1, 0.2, 0.9)) |
19 mat0 = Material(colour=(0.1, 0.2, 0.9)) |
21 box = Box(L=(-20.0, -2.2, -20.0), H=(20.0, -2.0, 20.0), material=mat0) |
20 mat0.setReflectivity(0.0) |
|
21 box = Box(L=(-10.0, 0.0, 50.0), H=(30.0, 1.0, -1.0), material=mat0) |
22 rt.addShape(box) |
22 rt.addShape(box) |
23 |
23 |
24 mat1 = Material(colour=(1.0, 0.2, 0.1)) |
24 mat1 = Material(colour=(1.0, 0.2, 0.1)) |
25 mat1.setReflectivity(0.7) |
25 mat1.setReflectivity(0.7) |
26 bigsphere = Sphere(centre=(2.0, 1.0, -5.0), radius=2.5, material=mat1) |
26 bigsphere = Sphere(centre=(12.0, 4.0, 6.0), radius=2.5, material=mat1) |
27 rt.addShape(bigsphere) |
27 rt.addShape(bigsphere) |
28 |
28 |
29 mat2 = Material(colour=(0.1, 0.4, 0.2)) |
29 mat2 = Material(colour=(0.1, 0.4, 0.2)) |
30 mat2.setReflectivity(0.6) |
30 mat2.setReflectivity(0.6) |
31 smallsphere = Sphere(centre=(-4.5, 0.5, -8.0), radius=2.0, material=mat2) |
31 smallsphere = Sphere(centre=(6.5, 3.5, 8.0), radius=2.0, material=mat2) |
32 rt.addShape(smallsphere) |
32 rt.addShape(smallsphere) |
33 |
33 |
34 mat3 = Material(colour=(0.9, 0.9, 1.0)) |
34 mat3 = Material(colour=(0.9, 0.9, 1.0)) |
35 mat3.setPhong(0.2, 1.0, 0.2) |
35 mat3.setPhong(0.2, 1.0, 0.2) |
36 mat3.setTransmissivity(0.88) |
36 mat3.setTransmissivity(0.88) |
37 mat3.setReflectivity(0.1) |
37 mat3.setReflectivity(0.1) |
38 for i in range(10): |
38 for i in range(10): |
39 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) |
40 rt.addShape(sph) |
40 rt.addShape(sph) |
41 |
41 |
42 top.optimize() |
42 top.optimize() |
43 |
43 |
44 sampler = DefaultSampler(800, 600) |
44 sampler = DefaultSampler(800, 600) |