author | Radek Brich <radek.brich@devl.cz> |
Thu, 24 Apr 2008 10:49:11 +0200 | |
branch | pyrit |
changeset 81 | 9dbb9c8c115b |
parent 75 | 20dee9819b17 |
child 90 | f6a72eb99631 |
permissions | -rwxr-xr-x |
1
e74bf781067e
use python-config, strip python version from demos, change [PyRit] to [pyrit] -- should use unix name everywhere
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
1 |
#!/usr/bin/python |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
6
diff
changeset
|
3 |
from raytracer import Raytracer, Material, Box, Sphere, Light |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
import Image |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
rt = Raytracer() |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
7 |
rt.ambientOcclusion(samples=100, distance=16.0, angle=0.5) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
19
4e0955fca797
added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents:
14
diff
changeset
|
9 |
light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
10 |
light1.castShadows(False) |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
11 |
rt.addLight(light1) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
|
19
4e0955fca797
added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents:
14
diff
changeset
|
13 |
light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
14 |
light2.castShadows(False) |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
15 |
rt.addLight(light2) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
mat0 = Material(colour=(0.7, 0.7, 0.7)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
6
diff
changeset
|
19 |
box = Box(L=(-20.0, -1.2, -20.0), H=(20.0, -1.0, 20.0), material=mat0) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
20 |
rt.addShape(box) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
mat1 = Material(colour=(1.0, 0.0, 0.0)) |
19
4e0955fca797
added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents:
14
diff
changeset
|
23 |
bigsphere = Sphere(centre=(3.0, 2.0, -7.0), radius=3.0, material=mat1) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
24 |
rt.addShape(bigsphere) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
mat2 = Material(colour=(0.0, 1.0, 0.0)) |
19
4e0955fca797
added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents:
14
diff
changeset
|
27 |
smallsphere = Sphere(centre=(-5.5, 1.5, -8.0), radius=2.0, material=mat2) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
28 |
rt.addShape(smallsphere) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
mat3 = Material(colour=(0.0, 0.0, 1.0)) |
19
4e0955fca797
added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents:
14
diff
changeset
|
31 |
tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
32 |
rt.addShape(tinysphere) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
imagesize = (800, 600) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
data = rt.render(imagesize) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
img = Image.fromstring("RGB", imagesize, data) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
img.save('spheres_ao.png') |