demos/triangles_monkey.py
author Radek Brich <radek.brich@devl.cz>
Thu, 15 May 2008 19:15:57 +0200
branchpyrit
changeset 97 2a853d284a6a
parent 95 ca7d4c665531
permissions -rwxr-xr-x
added bench.py demo which prints tree build and render times added Vertex to python binding, NormalVertex is now its subclass
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
e74bf781067e use python-config, strip python version from demos, change [PyRit] to [pyrit] -- should use unix name everywhere
Radek Brich <radek.brich@devl.cz>
parents: 0
diff changeset
     1
#!/usr/bin/python
0
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     3
from pyrit import *
29
574c34441a1c new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents: 28
diff changeset
     4
from objreader import LoadWavefrontObjFile
0
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
rt = Raytracer()
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     7
top = KdTree()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     8
rt.setTop(top)
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 90
diff changeset
     9
rt.setCamera(Camera(eye=(0,0,6)))
0
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
19
4e0955fca797 added Camera, currently w/o Python binding
Radek Brich <radek.brich@devl.cz>
parents: 6
diff changeset
    11
light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6))
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    12
rt.addLight(light)
0
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    14
mat = Material(colour=(0.9, 0.9, 0.9))
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    15
LoadWavefrontObjFile(rt, "../models/obj/monkey.obj", mat, 1.5)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    16
top.optimize()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    17
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    18
sampler = DefaultSampler(800, 600)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    19
rt.setSampler(sampler)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    20
rt.render()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    21
sampler.getPixmap().writePNG('triangles_monkey.png')