demos/bunny.py
author Radek Brich <radek.brich@devl.cz>
Sat, 08 Dec 2007 16:02:37 +0100
branchpyrit
changeset 30 33f95441790e
parent 29 574c34441a1c
child 31 b4e09433934a
permissions -rwxr-xr-x
pyrit_verbosity: new variable for controlling amount of output, see common.h fix Makefile dependencies for raytracer_module fix bad view in buddha.py caused by last commit

#!/usr/bin/python

# this demo needs bunny model from
# http://graphics.stanford.edu/data/3Dscanrep/

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

from raytracer import Raytracer, Light, Sphere, Triangle, NormalVertex, Material
from plyreader import LoadStanfordPlyFile
import Image

rt = Raytracer()
mat = Material(colour=(0.9, 0.9, 0.9))
LoadStanfordPlyFile(rt, "../models/bunny/bun_zipper.ply",
	mat, smooth=True, scale=(-29.0, 29.0, 29.0), trans=(-1,-3,-3))

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

light2 = Light(position=(4.0, -3.0, 10.0), colour=(0.2, 0.9, 0.5))
rt.addlight(light2)

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