demos/triangles_monkey.py
author Radek Brich <radek.brich@devl.cz>
Sun, 20 Apr 2008 19:27:59 +0200
branchpyrit
changeset 73 a5127346fbcd
parent 62 07c2f8084719
child 75 20dee9819b17
permissions -rwxr-xr-x
correct camera angle of view render_nff.py - polygonal patches
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
29
574c34441a1c new C++ demo: realtime_bunny
Radek Brich <radek.brich@devl.cz>
parents: 28
diff changeset
     3
from raytracer import Raytracer, Light, Sphere, Triangle, NormalVertex, Material
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
import Image
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
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
rt = Raytracer()
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
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
     9
LoadWavefrontObjFile(rt, "../models/obj/monkey.obj", mat, 1.5)
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))
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
    12
rt.addlight(light)
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
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
imagesize = (800, 600)
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
data = rt.render(imagesize)
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
img = Image.fromstring("RGB", imagesize, data)
3547b885df7e initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
img.save('triangles_monkey.png')