|
1 #!/usr/bin/python2.4 |
|
2 |
|
3 import sys |
|
4 sys.path.append("../") |
|
5 |
|
6 from raytracer import Raytracer, Material, Plane, Sphere, Light |
|
7 #, SphericalLight |
|
8 import Image |
|
9 |
|
10 rt = Raytracer() |
|
11 |
|
12 light1 = Light(position=(0.0, 5.0, 3.0), colour=(0.9, 0.3, 0.6)) |
|
13 rt.addlight(light1) |
|
14 |
|
15 #light2 = SphericalLight(position=(-2.0, 5.0, 1.0), radius=3.0, colour=(0.7, 1.0, 0.3)) |
|
16 light2 = Light(position=(-2.0, -5.0, 1.0), colour=(0.7, 1.0, 0.3)) |
|
17 rt.addlight(light2) |
|
18 |
|
19 mat0 = Material(colour=(0.1, 0.2, 0.9)) |
|
20 plane = Plane(normal=(0.0, 1.0, 0.0), d=1.0, material=mat0) |
|
21 rt.addshape(plane) |
|
22 |
|
23 mat1 = Material(colour=(1.0, 0.2, 0.1)) |
|
24 bigsphere = Sphere(centre=(2.0, 2.0, 5.0), radius=2.5, material=mat1) |
|
25 # reflection=0.6) |
|
26 rt.addshape(bigsphere) |
|
27 |
|
28 mat2 = Material(colour=(0.1, 0.7, 1.0)) |
|
29 smallsphere = Sphere(centre=(-5.5, 1.5, 8.0), radius=2.0, material=mat2) |
|
30 # reflection=1.0, diffuse=0.1) |
|
31 rt.addshape(smallsphere) |
|
32 |
|
33 mat3 = Material(colour=(0.9, 0.9, 0.1)) |
|
34 tinysphere = Sphere(centre=(-0.5, 0.0, 2.0), radius=0.5, material=mat3) |
|
35 # reflection=1.0, diffuse=0.1) |
|
36 rt.addshape(tinysphere) |
|
37 |
|
38 #for i in range(100): |
|
39 # sph=Sphere((-5.5+i/10.0, -0.5, 7.0), 2.0) |
|
40 # rt.addshape(sph) |
|
41 |
|
42 rendersize = (800, 600) |
|
43 data = rt.render(rendersize) |
|
44 img = Image.fromstring("RGB", rendersize, data) |
|
45 img.save('out.png') |