demos/dragon.py
author Radek Brich <radek.brich@devl.cz>
Wed, 23 Apr 2008 19:35:03 +0200
branchpyrit
changeset 80 907929fa9b59
parent 75 20dee9819b17
child 90 f6a72eb99631
permissions -rwxr-xr-x
remove forgotten noise.h includes common_ply.h: ignore invalid faces with duplicated points (this solves visual flaws in dragon model) extend loadShape for loading triangles realtime_dragon.cc demo: add kd-tree dump/load functionality, add colored perlin cloud texture

#!/usr/bin/python

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

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))
mat.setSmooth(True)
LoadStanfordPlyFile(rt, "../models/ply/dragon/dragon_vrip_res2.ply",
	mat, scale=(-29.0, 29.0, -29.0), trans=(0.0, -3.6, 0.0))

light1 = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.2))
rt.addLight(light1)

light2 = Light(position=(3.0, 0.0, 9.0), colour=(0.0, 1.0, 0.2))
rt.addLight(light2)

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