demos/buddha.py
author Radek Brich <radek.brich@devl.cz>
Wed, 09 Apr 2008 17:55:29 +0200
branchpyrit
changeset 64 5785cca4cdb9
parent 62 07c2f8084719
child 69 303583d2fb97
permissions -rwxr-xr-x
add Help with list of targets to SConstruct
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/python
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
# this demo needs buddha model from
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
# http://graphics.stanford.edu/data/3Dscanrep/
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
from raytracer import Raytracer, Light, Sphere, Triangle, Material
29
574c34441a1c new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents: 28
diff changeset
     7
from plyreader import LoadStanfordPlyFile
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
import Image
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
rt = Raytracer()
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
mat = Material(colour=(0.9, 0.9, 0.9))
62
07c2f8084719 more SConscript tweaking, make model preparation work again
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    12
LoadStanfordPlyFile(rt, "../models/ply/happy/happy_vrip_res2.ply",
30
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
    13
	mat, smooth=True, scale=20.0, trans=(0,-3,0))
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
19
4e0955fca797 added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    15
light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6))
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
rt.addlight(light)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
imagesize = (800, 600)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
data = rt.render(imagesize)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
img = Image.fromstring("RGB", imagesize, data)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
img.save('buddha.png')