def export_collada(mesh):
'''
Export a mesh as a COLLADA file.
'''
from ..templates import get_template
from string import Template
template_string = get_template('collada.dae.template')
template = Template(template_string)
# we bother setting this because np.array2string uses these printoptions
np.set_printoptions(threshold=np.inf, precision=5, linewidth=np.inf)
replacement = dict()
replacement['VERTEX'] = np.array2string(mesh.vertices.reshape(-1))[1:-1]
replacement['FACES'] = np.array2string(mesh.faces.reshape(-1))[1:-1]
replacement['NORMALS'] = np.array2string(mesh.vertex_normals.reshape(-1))[1:-1]
replacement['VCOUNT'] = str(len(mesh.vertices))
replacement['VCOUNTX3'] = str(len(mesh.vertices) * 3)
replacement['FCOUNT'] = str(len(mesh.faces))
export = template.substitute(replacement)
return export
评论列表
文章目录