demos/car.py
author Radek Brich <radek.brich@devl.cz>
Thu, 10 Apr 2008 23:20:36 +0200
branchpyrit
changeset 65 242839c6d27d
parent 62 07c2f8084719
child 69 303583d2fb97
permissions -rwxr-xr-x
basic detection of compiler (GCC or ICC) and CPU capabilities try to detect Python path in Windows and allow direct specification through build option plus other build system fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/python
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
59
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
     3
from raytracer import Raytracer, Light, Sphere, Triangle, Material, Camera
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
from lworeader import LoadLightwaveLwoFile
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
import Image
59
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
     6
from math import *
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
rt = Raytracer()
59
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
     9
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
    10
cam = Camera(eye=(0.,5.,8.))
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
    11
rotx=0.3
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
    12
cam.rotate((cos(rotx),-sin(rotx),0.,0.))
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
    13
rt.setcamera(cam)
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
    14
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
mat = Material(colour=(0.9, 0.9, 0.9))
62
07c2f8084719 more SConscript tweaking, make model preparation work again
Radek Brich <radek.brich@devl.cz>
parents: 60
diff changeset
    16
LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", mat, smooth=False, scale=0.4)
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
60
a23b5089b9c3 moving to SCons build system
Radek Brich <radek.brich@devl.cz>
parents: 59
diff changeset
    18
light = Light(position=(-5.0, 10.0, 8.0), colour=(0.9, 0.9, 0.9))
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
rt.addlight(light)
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
imagesize = (800, 600)
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
data = rt.render(imagesize)
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
img = Image.fromstring("RGB", imagesize, data)
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
img.save('car.png')