ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/txtprt.py
(Generate patch)

Comparing libgender/txtprt.py (file contents):
Revision 1.4 by root, Sun Oct 3 05:07:01 2004 UTC vs.
Revision 1.5 by root, Sun Oct 3 23:34:02 2004 UTC

11# Version 0.0 11# Version 0.0
12# Colin Peart 12# Colin Peart
13# Released under GPL (insert license text here) 13# Released under GPL (insert license text here)
14 14
15import Blender 15import Blender
16from Blender import Types, Object, NMesh, Camera, Lamp 16from Blender import Types, Object, NMesh, Camera, Lamp, Mathutils
17from Blender.Mathutils import *
18
17import sys 19import sys
18 20
19 21
20# dump -- the object dumper f: File, o: object 22# dump -- the object dumper f: File, o: object
21def dump(f, o, od): 23def dump(f, o, od):
75 # Modified to use only one pass, by building a variable with the text 77 # Modified to use only one pass, by building a variable with the text
76 faces = len(mesh.faces) 78 faces = len(mesh.faces)
77 data = "" 79 data = ""
78 colordata = "" 80 colordata = ""
79 for face in mesh.faces: 81 for face in mesh.faces:
80 if len (face.v) < 4: 82 if len (face.v) < 3:
83 faces = faces - 1
84 elif len (face.v) == 3:
81 # triangle 85 # triangle
82 data = data + `face.v[0].index` + " " + `face.v[2].index` + " " + `face.v[1].index` + "\n" 86 data = data + `face.v[0].index` + " " + `face.v[2].index` + " " + `face.v[1].index` + "\n"
87 data = data + `face.smooth` + "\n"
83 else: 88 else:
84 # this one is a quad 89 # this one is a quad
85 # Break it up into two triangles 90 # Break it up into two triangles
86 # Hence one additional face 91 # Hence one additional face
87 faces = faces + 1 92 faces = faces + 1
88 93
89 data = data + `face.v[0].index` + " " + `face.v[3].index` + " " + `face.v[1].index` + "\n" 94 data = data + `face.v[0].index` + " " + `face.v[3].index` + " " + `face.v[1].index` + "\n"
95 data = data + `face.smooth` + "\n"
96
90 data = data + `face.v[1].index` + " " + `face.v[3].index` + " " + `face.v[2].index` + "\n" 97 data = data + `face.v[1].index` + " " + `face.v[3].index` + " " + `face.v[2].index` + "\n"
98 data = data + `face.smooth` + "\n"
91 # Now I can write the header with the correct face count, and then the data 99 # Now I can write the header with the correct face count, and then the data
92 f.write("A " + `faces` + "\n") 100 f.write("A " + `faces` + "\n")
93 f.write(data) 101 f.write(data)
94 102
95 103

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines