class MeshExporter:
def __init__(self):
self.show_progress = True
- self.use_strips = True
- self.use_degen_tris = False
self.export_all = False
- def join_strips(self, strips):
- big_strip = []
-
- for s in strips:
- if big_strip:
- # Generate glue elements, ensuring that the next strip begins at
- # an even position
- glue = [big_strip[-1], s[0]]
- if len(big_strip)%2:
- glue += [s[0]]
-
- big_strip += glue
-
- big_strip += s
-
- return big_strip
-
def export_to_file(self, context, out_fn):
if self.export_all:
objs = [o for o in context.selected_objects if o.type=="MESH"]
st.append(Token("TEXCOORD"+size))
else:
st.append(Token("TEXCOORD{}_{}".format(size, u.unit)))
- if mesh.tbn_vecs:
+ if mesh.tangent_vecs:
st.append(Token("TANGENT3"))
- st.append(Token("BINORMAL3"))
if mesh.vertex_groups:
st.append(Token("GROUP{}".format(mesh.max_groups_per_vertex)))
st.append(Token("WEIGHT{}".format(mesh.max_groups_per_vertex)))
color = None
uvs = [None]*len(mesh.uv_layers)
tan = None
- bino = None
group = None
weight = None
for v in mesh.vertices:
else:
st.sub.append(Statement("multitexcoord", u.unit, *v.uvs[i]))
uvs[i] = v.uvs[i]
- if mesh.tbn_vecs:
+ if mesh.tangent_vecs:
if v.tan!=tan:
st.sub.append(Statement("tangent", *v.tan))
tan = v.tan
- if v.bino!=bino:
- st.sub.append(Statement("binormal", *v.bino))
- bino = v.bino
if mesh.vertex_groups:
v_group = [g.group for g in v.groups]
v_weight = [g.weight for g in v.groups]
statements.append(st)
- if self.use_strips:
- strips = mesh.vertex_sequence
- if self.use_degen_tris:
- strips = [self.join_strips(strips)]
-
- for s in strips:
+ if mesh.use_strips:
+ for s in mesh.vertex_sequence:
st = Statement("batch", Token("TRIANGLE_STRIP"))
for i in range(0, len(s), 32):
st.sub.append(Statement("indices", *(v.index for v in s[i:i+32])))