self.edges=[]
self.verts=[v for v in mf.verts]
self.flag=False
-
+
def __getattr__(self, attr):
return getattr(self._mface, attr)
self.out_file=sys.stdout
else:
self.out_file=file(fn, "w")
+ self.use_strips=True
+ self.use_degen_tris=True
def find_smooth_group(self, face, sg):
face.smooth_group=sg
result=[v2, v1]
else:
result=[v1, v2]
-
- print edge.key
- print [v.index for v in result]
while 1:
face.flag=True
- print "face =",[v.index for v in face.verts]
- print [e.key for e in face.edges]
for i in range(2, len(face.verts)):
v=face.get_following_vertex(result[-2], result[-1])
- print v.index
result.append(v)
- print [v.index for v in result]
i1=result[-2].index
i2=result[-1].index
smooth_groups.append(sg)
self.find_smooth_group(f, sg)
- strips=[]
- """XXX Stripping and smoothing are currently imcompatible
for sg in smooth_groups:
- for f in sg.faces:
- if not f.flag:
- strip=self.create_strip(f)
- if strip:
- strips.append(strip)"""
-
- for i in mesh.verts:
- print i.co
+ sg.find_vertices()
- #print [v.index for v in strips[0]]
+ strips=[]
+ if self.use_strips:
+ for sg in smooth_groups:
+ for f in sg.faces:
+ if not f.flag:
+ strip=self.create_strip(f)
+ if strip:
+ strips.append(strip)
+
+ if self.use_degen_tris:
+ big_strip=[]
+ for s in strips:
+ if big_strip:
+ big_strip+=[big_strip[-1], s[0]]
+ big_strip+=s
+
+ for f in faces:
+ if not f.flag:
+ if big_strip:
+ big_strip+=[big_strip[-1], f.verts[0]]
+ big_strip+=[f.verts[i] for i in (0, 1, -1)]
+ if len(f.verts)==4:
+ big_strip.append(f.verts[-2])
+ f.flag=True
+
+ strips=[big_strip]
verts=[]
for sg in smooth_groups:
- sg.find_vertices()
for v in sg.verts:
v.index=len(verts)
verts.append(v)
- #print [v.index for v in strips[0]]
-
self.out_file.write("vertices NORMAL3_VERTEX3\n{\n")
for v in verts:
self.out_file.write("\tnormal3 %f %f %f;\n"%tuple(v.no))
self.out_file.write("};\n")
for s in strips:
self.out_file.write("batch TRIANGLE_STRIP\n{\n\tindices")
+ n=0
for v in s:
self.out_file.write(" %u"%v.index)
+ n+=1;
+ if n%32==0:
+ self.out_file.write(";\n\tindices")
self.out_file.write(";\n};\n")
first=True