demos/triangles_monkey.py
author Radek Brich <radek.brich@devl.cz>
Sat, 29 Mar 2008 18:01:45 +0100
branchpyrit
changeset 57 1e92c21b9a61
parent 29 574c34441a1c
child 60 a23b5089b9c3
permissions -rwxr-xr-x
new python demo: boxes

#!/usr/bin/python

import sys
sys.path.append(open('ModulePath').read().strip())

from raytracer import Raytracer, Light, Sphere, Triangle, NormalVertex, Material
from objreader import LoadWavefrontObjFile
import Image

rt = Raytracer()
mat = Material(colour=(0.9, 0.9, 0.9))
LoadWavefrontObjFile(rt, "monkey.obj", mat, 1.5)

light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6))
rt.addlight(light)

imagesize = (800, 600)
data = rt.render(imagesize)
img = Image.fromstring("RGB", imagesize, data)
img.save('triangles_monkey.png')