equal
deleted
inserted
replaced
1 #!/usr/bin/python |
1 #!/usr/bin/python |
2 |
2 |
3 from raytracer import Raytracer, Light, Sphere, Triangle, Material, Camera |
3 from pyrit import * |
4 from lworeader import LoadLightwaveLwoFile |
4 from lworeader import LoadLightwaveLwoFile |
5 import Image |
|
6 from math import * |
5 from math import * |
7 |
6 |
8 rt = Raytracer() |
7 rt = Raytracer() |
9 |
8 top = KdTree() |
|
9 rt.setTop(top) |
10 cam = Camera(eye=(0.,2.,8.)) |
10 cam = Camera(eye=(0.,2.,8.)) |
11 rotx=0.15 |
11 rotx=0.15 |
12 cam.rotate((cos(rotx),-sin(rotx),0.,0.)) |
12 cam.rotate((cos(rotx),-sin(rotx),0.,0.)) |
13 rt.setCamera(cam) |
13 rt.setCamera(cam) |
14 |
14 |
17 light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9)) |
17 light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9)) |
18 rt.addLight(light1) |
18 rt.addLight(light1) |
19 light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7)) |
19 light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7)) |
20 rt.addLight(light2) |
20 rt.addLight(light2) |
21 |
21 |
22 imagesize = (800, 600) |
22 top.optimize() |
23 data = rt.render(imagesize) |
23 |
24 img = Image.fromstring("RGB", imagesize, data) |
24 sampler = DefaultSampler(800, 600) |
25 img.save('car.png') |
25 rt.setSampler(sampler) |
|
26 rt.render() |
|
27 sampler.getPixmap().writePNG('car.png') |