demos/bunny.py
author Radek Brich <radek.brich@devl.cz>
Wed, 26 Mar 2008 00:52:27 +0100
branchpyrit
changeset 46 6493fb65f0b1
parent 40 929aad02c5f2
child 60 a23b5089b9c3
permissions -rwxr-xr-x
Doxygen new Sampler object replacing rendering algorithm with more flexible one -- this breaks most of demos and disables threads and (over-/sub-)sampling functionality, need a rewrote

#!/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, 0.6))
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.5, 0.2))
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.8, 0.5, 0.6))
#light.castshadows(0)
rt.addlight(light)

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

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