demos/car.py
branchpyrit
changeset 69 303583d2fb97
parent 62 07c2f8084719
child 75 20dee9819b17
equal deleted inserted replaced
68:2c154aad7f33 69:303583d2fb97
     5 import Image
     5 import Image
     6 from math import *
     6 from math import *
     7 
     7 
     8 rt = Raytracer()
     8 rt = Raytracer()
     9 
     9 
    10 cam = Camera(eye=(0.,5.,8.))
    10 cam = Camera(eye=(0.,2.,8.))
    11 rotx=0.3
    11 rotx=0.15
    12 cam.rotate((cos(rotx),-sin(rotx),0.,0.))
    12 cam.rotate((cos(rotx),-sin(rotx),0.,0.))
    13 rt.setcamera(cam)
    13 rt.setcamera(cam)
    14 
    14 
    15 mat = Material(colour=(0.9, 0.9, 0.9))
    15 LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4, trans=(-0.2,0,0.3))
    16 LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", mat, smooth=False, scale=0.4)
       
    17 
    16 
    18 light = Light(position=(-5.0, 10.0, 8.0), colour=(0.9, 0.9, 0.9))
    17 light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9))
    19 rt.addlight(light)
    18 rt.addlight(light1)
       
    19 light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7))
       
    20 rt.addlight(light2)
    20 
    21 
    21 imagesize = (800, 600)
    22 imagesize = (800, 600)
    22 data = rt.render(imagesize)
    23 data = rt.render(imagesize)
    23 img = Image.fromstring("RGB", imagesize, data)
    24 img = Image.fromstring("RGB", imagesize, data)
    24 img.save('car.png')
    25 img.save('car.png')