demos/buddha.py
author Radek Brich <radek.brich@devl.cz>
Tue, 18 Dec 2007 12:36:01 +0100
branchpyrit
changeset 41 c1080cb5bd6d
parent 38 5d043eeb09d9
child 60 a23b5089b9c3
permissions -rwxr-xr-x
fix possible division by zero in ccdemos/common_ply.h don't use DEFS variable in makefiles, just add it to CCFLAGS compile float version of libs with -fsingle-precision-constant

#!/usr/bin/python

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

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

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

rt = Raytracer()
mat = Material(colour=(0.9, 0.9, 0.9))
LoadStanfordPlyFile(rt, "../models/happy/happy_vrip_res2.ply",
	mat, smooth=True, scale=20.0, trans=(0,-3,0))

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

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