author | Radek Brich <radek.brich@devl.cz> |
Mon, 19 May 2008 22:59:04 +0200 | |
branch | pyrit |
changeset 98 | 64638385798a |
parent 90 | f6a72eb99631 |
permissions | -rwxr-xr-x |
18 | 1 |
#!/usr/bin/python |
2 |
||
3 |
# this demo needs dragon model from |
|
4 |
# http://graphics.stanford.edu/data/3Dscanrep/ |
|
5 |
||
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
6 |
from pyrit import * |
29
574c34441a1c
new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents:
28
diff
changeset
|
7 |
from plyreader import LoadStanfordPlyFile |
18 | 8 |
|
9 |
rt = Raytracer() |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
10 |
top = KdTree() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
11 |
rt.setTop(top) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
12 |
rt.setCamera(Camera()) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
13 |
|
18 | 14 |
mat = Material(colour=(0.9, 0.9, 0.9)) |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
15 |
mat.setSmooth(True) |
62
07c2f8084719
more SConscript tweaking, make model preparation work again
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
16 |
LoadStanfordPlyFile(rt, "../models/ply/dragon/dragon_vrip_res2.ply", |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
17 |
mat, scale=(-29.0, 29.0, -29.0), trans=(0.0, -3.6, 0.0)) |
18 | 18 |
|
25
b8232edee786
tuned ray-triangle intersection, now there are three algorithms to choose from:
Radek Brich <radek.brich@devl.cz>
parents:
24
diff
changeset
|
19 |
light1 = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.2)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
20 |
rt.addLight(light1) |
25
b8232edee786
tuned ray-triangle intersection, now there are three algorithms to choose from:
Radek Brich <radek.brich@devl.cz>
parents:
24
diff
changeset
|
21 |
|
b8232edee786
tuned ray-triangle intersection, now there are three algorithms to choose from:
Radek Brich <radek.brich@devl.cz>
parents:
24
diff
changeset
|
22 |
light2 = Light(position=(3.0, 0.0, 9.0), colour=(0.0, 1.0, 0.2)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
23 |
rt.addLight(light2) |
18 | 24 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
25 |
top.optimize() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
26 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
27 |
sampler = DefaultSampler(800, 600) |
98
64638385798a
add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
28 |
sampler.setOversample(1) |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
29 |
rt.setSampler(sampler) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
30 |
rt.render() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
31 |
sampler.getPixmap().writePNG('dragon.png') |