author | Radek Brich <radek.brich@devl.cz> |
Thu, 15 May 2008 19:15:57 +0200 | |
branch | pyrit |
changeset 97 | 2a853d284a6a |
parent 95 | ca7d4c665531 |
permissions | -rwxr-xr-x |
26 | 1 |
#!/usr/bin/python |
2 |
||
3 |
# this demo needs bunny 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 |
26 | 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) |
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
12 |
rt.setCamera(Camera(eye=(4,2,3.5),lookat=(0.5,0.5,-3))) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
13 |
rt.setBgColour((0.5, 0.5, 0.2)) |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
14 |
|
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
15 |
mat = Material(colour=(0.4, 0.5, 0.9)) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
16 |
mat.setTransmissivity(0.95, 1.5) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
17 |
mat.setReflectivity(0) |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
18 |
mat.setSmooth(True) |
62
07c2f8084719
more SConscript tweaking, make model preparation work again
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
19 |
LoadStanfordPlyFile(rt, "../models/ply/bunny/bun_zipper.ply", |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
20 |
mat, scale=(-29.0, 29.0, 29.0), trans=(-1,-2.5,-3)) |
31 | 21 |
|
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
22 |
mat0 = Material(colour=(0.3, 0.5, 1.0)) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
23 |
floor = Box(L=(-20.0, -1.7, -20.0), H=(20.0, -1.5, 20.0), material=mat0) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
24 |
rt.addShape(floor) |
26 | 25 |
|
46 | 26 |
mat1 = Material(colour=(0.5, 0.5, 0.2)) |
31 | 27 |
mat1.setReflectivity(0.0) |
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
28 |
wall = Box(L=(-20.0, -20.0, -10.0), H=(20.0, 20.0, -12.0), material=mat1) |
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
29 |
rt.addShape(wall) |
31 | 30 |
|
46 | 31 |
light = Light(position=(-5.0, 3.0, 10.0), colour=(0.8, 0.5, 0.6)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
32 |
rt.addLight(light) |
26 | 33 |
|
46 | 34 |
light2 = Light(position=(4.0, 1.0, 10.0), colour=(0.5, 0.55, 0.7)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
35 |
rt.addLight(light2) |
26 | 36 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
37 |
top.optimize() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
38 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
39 |
sampler = DefaultSampler(800, 600) |
95
ca7d4c665531
build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents:
90
diff
changeset
|
40 |
sampler.setOversample(1) |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
41 |
rt.setSampler(sampler) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
42 |
rt.render() |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
75
diff
changeset
|
43 |
sampler.getPixmap().writePNG('bunny.png') |