author | Radek Brich <radek.brich@devl.cz> |
Mon, 05 May 2008 15:31:14 +0200 | |
branch | pyrit |
changeset 92 | 9af5c039b678 |
parent 90 | f6a72eb99631 |
permissions | -rw-r--r-- |
41
c1080cb5bd6d
fix possible division by zero in ccdemos/common_ply.h
Radek Brich <radek.brich@devl.cz>
parents:
29
diff
changeset
|
1 |
# Wavefron .obj file loader |
c1080cb5bd6d
fix possible division by zero in ccdemos/common_ply.h
Radek Brich <radek.brich@devl.cz>
parents:
29
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 Triangle, NormalVertex |
29 | 4 |
|
5 |
def LoadWavefrontObjFile(rt, filename, mat, scale): |
|
6 |
vertices = [] |
|
7 |
fp = file(filename) |
|
8 |
while True: |
|
9 |
ln = fp.readline() |
|
10 |
if ln == "": |
|
11 |
break; |
|
12 |
ln = ln.split() |
|
13 |
if ln[0] == "v": |
|
14 |
v = [scale*float(x) for x in ln[1:4]] |
|
15 |
vertices.append(tuple(v)) |
|
16 |
if ln[0] == "f": |
|
17 |
f = [vertices[int(x)-1] for x in ln[1:4]] |
|
18 |
face = Triangle(NormalVertex(f[0]), NormalVertex(f[1]), NormalVertex(f[2]), mat) |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
19 |
rt.addShape(face) |