demos/car.py
branchpyrit
changeset 59 64e456ab823d
parent 58 cfe98f5c0ae9
child 60 a23b5089b9c3
equal deleted inserted replaced
58:cfe98f5c0ae9 59:64e456ab823d
     1 #!/usr/bin/python
     1 #!/usr/bin/python
     2 
     2 
     3 import sys
     3 import sys
     4 sys.path.append(open('ModulePath').read().strip())
     4 sys.path.append(open('ModulePath').read().strip())
     5 
     5 
     6 from raytracer import Raytracer, Light, Sphere, Triangle, Material
     6 from raytracer import Raytracer, Light, Sphere, Triangle, Material, Camera
     7 from lworeader import LoadLightwaveLwoFile
     7 from lworeader import LoadLightwaveLwoFile
     8 import Image
     8 import Image
       
     9 from math import *
     9 
    10 
    10 rt = Raytracer()
    11 rt = Raytracer()
       
    12 
       
    13 cam = Camera(eye=(0.,5.,8.))
       
    14 rotx=0.3
       
    15 cam.rotate((cos(rotx),-sin(rotx),0.,0.))
       
    16 rt.setcamera(cam)
       
    17 
    11 mat = Material(colour=(0.9, 0.9, 0.9))
    18 mat = Material(colour=(0.9, 0.9, 0.9))
    12 LoadLightwaveLwoFile(rt, "../models/car/Nissan300ZX.lwo",	mat, smooth=True, scale=0.4) #, , trans=(0,-3,0))
    19 LoadLightwaveLwoFile(rt, "../models/car/Nissan300ZX.lwo", mat, smooth=False, scale=0.4)
    13 
    20 
    14 light = Light(position=(-5.0, 2.0, 8.0), colour=(0.2, 0.4, 0.6))
    21 light = Light(position=(-5.0, 2.0, 8.0), colour=(0.7, 0.7, 0.7))
    15 rt.addlight(light)
    22 rt.addlight(light)
    16 
    23 
    17 imagesize = (800, 600)
    24 imagesize = (800, 600)
    18 data = rt.render(imagesize)
    25 data = rt.render(imagesize)
    19 img = Image.fromstring("RGB", imagesize, data)
    26 img = Image.fromstring("RGB", imagesize, data)