@Paul Johnston
I knew something slipped by in all that mess.
Here's the updated script, should fix all the issues.
Replace the code within d13_modelConverter.py with the following:
# -- coding: utf-8 --
import pyassimp
import os,sys
from os import path
from sys import argv
import string
#print argv
input = ""
output = ""
if len(argv) == 1: sys.exit()
elif len(argv) == 2:
input = argv[1]
output = input[input.find(".")+1:] + ".ago"
else:
input = argv[1]
output = argv[2]
fileOut = open(output,'w')
obj = pyassimp.load(input)
fileOut.write("Object\n{\n")
fileOut.write("RightHand{1}\n")
fileOut.write("Position{0,0,0}\n")
fileOut.write("RotationQ{1,0,0,0}\n\n")
#vertices
verts = 0
for i,mesh in enumerate(obj.meshes):
verts += len(mesh.vertices)
fileOut.write("VertexCount{" + str(verts) + "}\n")
fileOut.write("VertexAttrib\n{\nName{\"position\"}\nType{\"Float\"}\nComponents{3}\nNormalize{\"no\"}\nData\n{\n")
inc = 0
for i,mesh in enumerate(obj.meshes):
for j in mesh.vertices:
inc += 1
d = str(j).strip("[]")
fileOut.write(d)
if inc == verts:
fileOut.write("\n")
else:
fileOut.write(",\n")
fileOut.write("}\n}\n\n")
normals = 0
for i,mesh in enumerate(obj.meshes):
normals += len(mesh.normals)
fileOut.write("VertexAttrib\n{\nName{\"normal\"}\nType{\"Float\"}\nComponents{3}\nNormalize{\"no\"}\nData\n{\n")
inc = 0
for i,mesh in enumerate(obj.meshes):
for j in mesh.normals:
inc += 1
d = str(j).strip("[]")
fileOut.write(d)
if inc == normals:
fileOut.write("\n")
else:
fileOut.write(",\n")
fileOut.write("}\n}\n\n")
uvs = 0
for i,mesh in enumerate(obj.meshes):
for j in mesh.texcoords:
for k in j:
if str(k) != "None":
uvs += 1
fileOut.write("VertexAttrib\n{\nName{\"uv\"}\nType{\"Float\"}\nComponents{3}\nNormalize{\"no\"}\nData\n{\n")
inc = 0
write = 0
for i,mesh in enumerate(obj.meshes):
for j in mesh.texcoords:
for k in j:
if str(k) != "None":
d = str(k).strip("[]")
fileOut.write(d)
inc += 1
if inc == uvs:
fileOut.write("\n")
else:
fileOut.write(",\n")
fileOut.write("}\n}\n\n")
indices = 0
for i,mesh in enumerate(obj.meshes):
for j in mesh.faces:
indices += len(j.indices)
fileOut.write("IndexCount{"+str(indices)+"}\n")
fileOut.write("Indices\n{\n")
inc = 0
for i,mesh in enumerate(obj.meshes):
for j in mesh.faces:
inc += 1
x = int(j.indices[0])
y = int(j.indices[1])
z = int(j.indices[2])
v = [x,y,z]
d = str(v).strip("[]")
fileOut.write(d)
if inc*3 == indices:
fileOut.write("\n")
else:
fileOut.write(",\n")
fileOut.write("}\n\n")
for i,mat in enumerate(obj.materials):
props = pyassimp.GetMaterialProperties(mat)
texture = props['$tex.file']
fileOut.write("Texture\n{\n")
fileOut.write("Stage{"+str(i)+"}\n")
fileOut.write("Filename{\""+texture+"\"}\n")
fileOut.write("}\n")
fileOut.write("\n")
fileOut.write("}\n")
pyassimp.release(obj)