demos/bunny.py
author Radek Brich <radek.brich@devl.cz>
Wed, 19 Mar 2008 17:18:59 +0100
branchpyrit
changeset 45 76b254ce92cf
parent 40 929aad02c5f2
child 46 6493fb65f0b1
permissions -rwxr-xr-x
note for new camera classes

#!/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, Box, Triangle, Material
from plyreader import LoadStanfordPlyFile
import Image

rt = Raytracer()
#rt.ambientocclusion(samples=100, distance=16.0, angle=0.5)

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

mat0 = Material(colour=(0.1, 0.2, 1.0))
box1 = Box(L=(-20.0, -1.7, -20.0), H=(20.0, -1.5, 20.0), material=mat0)
rt.addshape(box1)

mat1 = Material(colour=(0.5, 0.2, 0.1))
mat1.setReflectivity(0.0)
box2 = Box(L=(-20.0, -20.0, -10.0), H=(20.0, 20.0, -12.0), material=mat1)
rt.addshape(box2)

light = Light(position=(-5.0, 3.0, 10.0), colour=(0.9, 0.3, 0.6))
#light.castshadows(0)
rt.addlight(light)

light2 = Light(position=(4.0, 1.0, 10.0), colour=(0.2, 0.9, 0.5))
#light2.castshadows(0)
rt.addlight(light2)

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