demos/triangles_sphere.py
author Radek Brich <radek.brich@devl.cz>
Sun, 09 Dec 2007 15:01:51 +0100
branchpyrit
changeset 33 83d0200d4c09
parent 29 574c34441a1c
child 60 a23b5089b9c3
permissions -rwxr-xr-x
make over-sampling work together with sub-sampling

#!/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, "sphere.obj", mat, 1.5)

light1 = Light(position=(0.0, 2.0, 6.0), colour=(0.9, 0.3, 0.6))
light1.castshadows(False);
rt.addlight(light1)

light2 = Light(position=(-2.0, -5.0, 7.0), colour=(0.7, 1.0, 0.3))
light2.castshadows(False);
rt.addlight(light2)

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