demos/car.py
author Radek Brich <radek.brich@devl.cz>
Mon, 05 May 2008 15:31:14 +0200
branchpyrit
changeset 92 9af5c039b678
parent 90 f6a72eb99631
child 96 9eb71e76c7fd
permissions -rwxr-xr-x
add MSVC compiler support, make it default for Windows new header file simd.h for SSE abstraction and helpers add mselect pseudo instruction for common or(and(...), andnot(...)) replace many SSE intrinsics with new names new MemoryPool class (mempool.h) for faster KdNode allocation remove setMaxDepth() from Octree and KdTree, make max_depth const, it should be defined in constructor and never changed, change after building tree would cause error in traversal modify DefaultSampler to generate nice 2x2 packets of samples for packet tracing optimize Box and BBox::intersect_packet add precomputed invdir attribute to RayPacket scons build system: check for pthread library on Windows check for SDL generate include/config.h with variables detected by scons configuration move auxiliary files to build/ add sanity checks add writable operator[] to Vector
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
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     3
from pyrit import *
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
from lworeader import LoadLightwaveLwoFile
59
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
     5
from math import *
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
rt = Raytracer()
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     8
top = KdTree()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
     9
rt.setTop(top)
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    10
cam = Camera(eye=(0.,2.,8.))
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    11
rotx=0.15
59
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.))
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    13
rt.setCamera(cam)
59
64e456ab823d add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents: 58
diff changeset
    14
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    15
LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4, trans=(-0.2,0,0.3))
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    17
light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9))
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    18
rt.addLight(light1)
69
303583d2fb97 move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    19
light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7))
75
20dee9819b17 unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents: 69
diff changeset
    20
rt.addLight(light2)
58
cfe98f5c0ae9 new python demo: car.py
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    22
top.optimize()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    23
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    24
sampler = DefaultSampler(800, 600)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    25
rt.setSampler(sampler)
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    26
rt.render()
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 75
diff changeset
    27
sampler.getPixmap().writePNG('car.png')