demos/buddha.py
author Radek Brich <radek.brich@devl.cz>
Fri, 28 Mar 2008 00:53:20 +0100
branchpyrit
changeset 49 558fde7da82a
parent 38 5d043eeb09d9
child 60 a23b5089b9c3
permissions -rwxr-xr-x
workaround for divide by zero bug in octree enable oversampling for DefaultSampler sampler and camera performance enhancements
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
import sys
24
d0d76e8a5203 new C++ demo: realtime_dragon.cc
Radek Brich <radek.brich@devl.cz>
parents: 19
diff changeset
     7
sys.path.append(open('ModulePath').read().strip())
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
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
    10
from plyreader import LoadStanfordPlyFile
13
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
import Image
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
rt = Raytracer()
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
mat = Material(colour=(0.9, 0.9, 0.9))
38
5d043eeb09d9 realtime_dragon demo: now fullsize model + octree
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    15
LoadStanfordPlyFile(rt, "../models/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
    16
	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
    17
19
4e0955fca797 added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    18
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
    19
rt.addlight(light)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
imagesize = (800, 600)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
data = rt.render(imagesize)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
img = Image.fromstring("RGB", imagesize, data)
fbd1d2f7d94e new python demo: buddha
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
img.save('buddha.png')