|
1 #!/usr/bin/python |
|
2 |
|
3 from pyrit import * |
|
4 |
|
5 rt = Raytracer() |
|
6 top = KdTree() |
|
7 rt.setTop(top) |
|
8 rt.setCamera(Camera(eye=(10,4,-6),lookat=(10,3.5,0))) |
|
9 |
|
10 light1 = Light(position=(10.0, 7.0, 3.0), colour=(0.9, 0.3, 0.6)) |
|
11 rt.addLight(light1) |
|
12 |
|
13 light2 = Light(position=(8.0, 5.0, 1.0), colour=(0.7, 1.0, 0.3)) |
|
14 rt.addLight(light2) |
|
15 |
|
16 light3 = Light(position=(12.0, 8.0, -1.0), colour=(0.8, 0.9, 1.0)) |
|
17 rt.addLight(light3) |
|
18 |
|
19 mat0 = Material() |
|
20 mat0.setTexture(CloudTexture(5, LinearColourMap((0.0, 0.0, 0.5), (0.5, 1.0, 1.0)))) |
|
21 mat0.setReflectivity(0.0) |
|
22 box = Box(L=(-10.0, 0.0, 50.0), H=(30.0, 1.0, -1.0), material=mat0) |
|
23 rt.addShape(box) |
|
24 |
|
25 mat1 = Material(colour=(1.0, 0.2, 0.1)) |
|
26 mat1.setReflectivity(0.7) |
|
27 bigsphere = Sphere(center=(12.0, 4.0, 6.0), radius=2.5, material=mat1) |
|
28 rt.addShape(bigsphere) |
|
29 |
|
30 mat2 = Material(colour=(0.1, 0.4, 0.2)) |
|
31 mat2.setReflectivity(0.6) |
|
32 smallsphere = Sphere(center=(6.5, 3.5, 8.0), radius=2.0, material=mat2) |
|
33 rt.addShape(smallsphere) |
|
34 |
|
35 mat3 = Material(colour=(0.9, 0.9, 1.0)) |
|
36 mat3.setPhong(0.2, 1.0, 0.2) |
|
37 mat3.setTransmissivity(0.88) |
|
38 mat3.setReflectivity(0.1) |
|
39 for i in range(10): |
|
40 sph = Sphere(center=(5.0+i, 1.5, 4.0), radius=0.5, material=mat3) |
|
41 rt.addShape(sph) |
|
42 |
|
43 top.optimize() |
|
44 |
|
45 sampler = DefaultSampler(800, 600) |
|
46 sampler.setOversample(1) |
|
47 rt.setSampler(sampler) |
|
48 rt.render() |
|
49 sampler.getPixmap().writePNG('texture.png') |