author | Radek Brich <radek.brich@devl.cz> |
Thu, 15 May 2008 00:07:25 +0200 | |
branch | pyrit |
changeset 96 | 9eb71e76c7fd |
parent 95 | ca7d4c665531 |
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 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
3 |
from pyrit import * |
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 |
|
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 |
rt = Raytracer() |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
6 |
top = KdTree() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
7 |
rt.setTop(top) |
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
8 |
rt.setCamera(Camera(eye=(10,4,-6),lookat=(10,3.5,0))) |
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
|
9 |
|
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
10 |
light1 = Light(position=(10.0, 7.0, 3.0), colour=(0.9, 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
|
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 |
|
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
13 |
light2 = Light(position=(8.0, 5.0, 1.0), colour=(0.7, 1.0, 0.3)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
14 |
rt.addLight(light2) |
31 | 15 |
|
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
16 |
light3 = Light(position=(12.0, 8.0, -1.0), colour=(0.8, 0.9, 1.0)) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
17 |
rt.addLight(light3) |
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
|
18 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
mat0 = Material(colour=(0.1, 0.2, 0.9)) |
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
20 |
mat0.setReflectivity(0.0) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
21 |
box = Box(L=(-10.0, 0.0, 50.0), H=(30.0, 1.0, -1.0), material=mat0) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
22 |
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
|
23 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
mat1 = Material(colour=(1.0, 0.2, 0.1)) |
31 | 25 |
mat1.setReflectivity(0.7) |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
95
diff
changeset
|
26 |
bigsphere = Sphere(center=(12.0, 4.0, 6.0), radius=2.5, material=mat1) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
27 |
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
|
28 |
|
56
d4481fc43952
fix sphere transmissivity, rename demo.py to spheres_glass.py
Radek Brich <radek.brich@devl.cz>
parents:
31
diff
changeset
|
29 |
mat2 = Material(colour=(0.1, 0.4, 0.2)) |
d4481fc43952
fix sphere transmissivity, rename demo.py to spheres_glass.py
Radek Brich <radek.brich@devl.cz>
parents:
31
diff
changeset
|
30 |
mat2.setReflectivity(0.6) |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
95
diff
changeset
|
31 |
smallsphere = Sphere(center=(6.5, 3.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
|
32 |
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
|
33 |
|
31 | 34 |
mat3 = Material(colour=(0.9, 0.9, 1.0)) |
35 |
mat3.setPhong(0.2, 1.0, 0.2) |
|
56
d4481fc43952
fix sphere transmissivity, rename demo.py to spheres_glass.py
Radek Brich <radek.brich@devl.cz>
parents:
31
diff
changeset
|
36 |
mat3.setTransmissivity(0.88) |
d4481fc43952
fix sphere transmissivity, rename demo.py to spheres_glass.py
Radek Brich <radek.brich@devl.cz>
parents:
31
diff
changeset
|
37 |
mat3.setReflectivity(0.1) |
31 | 38 |
for i in range(10): |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
95
diff
changeset
|
39 |
sph = Sphere(center=(5.0+i, 1.5, 4.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
|
40 |
rt.addShape(sph) |
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
|
41 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
42 |
top.optimize() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
43 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
44 |
sampler = DefaultSampler(800, 600) |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
95
diff
changeset
|
45 |
sampler.setOversample(1) |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
46 |
rt.setSampler(sampler) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
47 |
rt.render() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
48 |
sampler.getPixmap().writePNG('spheres_glass.png') |