demos/buddha.py
author Radek Brich <radek.brich@devl.cz>
Wed, 19 Aug 2009 09:18:29 +0200
branchpyrit
changeset 101 50a994a57849
parent 90 f6a72eb99631
permissions -rwxr-xr-x
vcproj build target only for cc=msvc, fix sdl-config
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
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
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     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
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    14
light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6))
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    15
rt.addLight(light)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    16
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
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
    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/happy/happy_vrip_res2.ply",
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    20
	mat, scale=20.0, trans=(0,-3,0))
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    21
top.optimize()
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    23
sampler = DefaultSampler(800, 600)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    24
rt.setSampler(sampler)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    25
rt.render()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    26
sampler.getPixmap().writePNG('buddha.png')