demos/triangles_sphere.py
author Radek Brich <radek.brich@devl.cz>
Mon, 21 Apr 2008 08:47:36 +0200
branchpyrit
changeset 74 09aedbf5f95f
parent 62 07c2f8084719
child 75 20dee9819b17
permissions -rwxr-xr-x
kd-tree traversal - avoid dynamic memory allocation use minimum storage size for KdNode (8B on 32bit cpu) vector.h - add division operator, fix semicolons

#!/usr/bin/python

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, "../models/obj/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')