author | Radek Brich <radek.brich@devl.cz> |
Sat, 08 Dec 2007 16:02:37 +0100 | |
branch | pyrit |
changeset 30 | 33f95441790e |
parent 29 | 574c34441a1c |
child 31 | b4e09433934a |
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 |
||
6 |
import sys |
|
7 |
sys.path.append(open('ModulePath').read().strip()) |
|
8 |
||
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
26
diff
changeset
|
9 |
from raytracer import Raytracer, Light, Sphere, Triangle, NormalVertex, Material |
29
574c34441a1c
new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents:
28
diff
changeset
|
10 |
from plyreader import LoadStanfordPlyFile |
26 | 11 |
import Image |
12 |
||
13 |
rt = Raytracer() |
|
14 |
mat = Material(colour=(0.9, 0.9, 0.9)) |
|
29
574c34441a1c
new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents:
28
diff
changeset
|
15 |
LoadStanfordPlyFile(rt, "../models/bunny/bun_zipper.ply", |
574c34441a1c
new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents:
28
diff
changeset
|
16 |
mat, smooth=True, scale=(-29.0, 29.0, 29.0), trans=(-1,-3,-3)) |
26 | 17 |
|
18 |
light = Light(position=(-5.0, 2.0, 10.0), colour=(0.9, 0.3, 0.6)) |
|
19 |
rt.addlight(light) |
|
20 |
||
21 |
light2 = Light(position=(4.0, -3.0, 10.0), colour=(0.2, 0.9, 0.5)) |
|
22 |
rt.addlight(light2) |
|
23 |
||
24 |
imagesize = (800, 600) |
|
25 |
data = rt.render(imagesize) |
|
26 |
img = Image.fromstring("RGB", imagesize, data) |
|
27 |
img.save('bunny.png') |