demos/car.py
author Radek Brich <radek.brich@devl.cz>
Sun, 20 Apr 2008 16:48:24 +0200
branchpyrit
changeset 72 7c3f38dff082
parent 69 303583d2fb97
child 75 20dee9819b17
permissions -rwxr-xr-x
kd-tree building - check all axes for best split, add additional shape-bbox check extent Container bounds by Eps to fix invisible triangles on borders new Camera constructor with more intuitive lookat/up vectors fix camera axes (mirrored images) better camera angle-of-view change capitalization of addShape and addLight

#!/usr/bin/python

from raytracer import Raytracer, Light, Sphere, Triangle, Material, Camera
from lworeader import LoadLightwaveLwoFile
import Image
from math import *

rt = Raytracer()

cam = Camera(eye=(0.,2.,8.))
rotx=0.15
cam.rotate((cos(rotx),-sin(rotx),0.,0.))
rt.setcamera(cam)

LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4, trans=(-0.2,0,0.3))

light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9))
rt.addlight(light1)
light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7))
rt.addlight(light2)

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