Now there is a at least partially implemented importer (prints a lot of stuff to the console) All you need to do is copy the script in the editor and
edit this (last) line before pressing the run button:
importMX("c:\\path\\avatar.mx", 'Avatar')
The first argument is the path to the file to import, second the object name in Blender.
import bpy
import mathutils
import struct
def read_n_items(file, n, func):
for i in range(n):
func(i, file)
def read_struct_from_file(file, fmt):
return struct.unpack(fmt, file.read(struct.calcsize(fmt)))
def skip_string(file):
s=''
while True:
c = struct.unpack('c', file.read(1))[0]
s = s + c.decode("utf-8")
if c == b'\x00':
print(s)
return
def importMX(filename, obj_name):
verts=[]
faces=[]
with open(filename, 'rb') as file:
prjx = read_struct_from_file(file, '8ch')
print(prjx)
num_texture_files = prjx[8]
print(num_texture_files)
while num_texture_files > 0:
num_texture_files = num_texture_files - 1
skip_string(file)
groups = read_struct_from_file(file, 'h')[0]
exec_lists = read_struct_from_file(file, 'I')[0]
exec_type = read_struct_from_file(file, 'h')[0]
vertices = read_struct_from_file(file, 'h')[0]
#groups,exec_lists,exec_type,vertices = read_struct_from_file(file, 'hIhh')
print( 'vertices=%d' % vertices )
idx=0
while idx < vertices:
x,y,z,reserved,colour,specular,tu,tv = read_struct_from_file(file,'fffIIIII')
print('%d %f %f %f' % (idx,x,y,z))
verts.append((x,y,z))
idx = idx + 1
num_tex_groups = read_struct_from_file(file, 'h')[0]
print(num_tex_groups)
while num_tex_groups > 0:
texture_type,start_vertex,num_vertices,texture_no,num_triangles = read_struct_from_file( file, 'hhhhh' )
num_tex_groups = num_tex_groups - 1
print( "tt=%d sv=%d nv=%d tno=%d tria=%d" % (texture_type,start_vertex,num_vertices,texture_no,num_triangles ))
while num_triangles > 0:
v0,v1,v2,pa = read_struct_from_file( file, 'hhhh' )
nx,ny,nz = read_struct_from_file( file, 'fff' )
print('%d,%d,%d %f %f %f' % (v0,v1,v2,nx,ny,nz))
num_triangles = num_triangles - 1
faces.append((v0,v1,v2))
print(verts)
print(faces)
mesh = bpy.data.meshes.new( obj_name )
object = bpy.data.objects.new( obj_name, mesh)
object.location = (0,0,0)
bpy.context.scene.objects.link(object)
mesh.from_pydata(verts,[],faces)
if __name__ == "__main__":
importMX("c:\\path\\avatar.mx", 'Avatar')
Result:
avatar.mx

airmoble.mx

To get started you can extend on the following code, there is also an undocumented 8 byte "PRJX...." id at beginning of the file besides that the format seems to match.
See https://docs.python.org/3.4/library/struct.html for the format strings like: h=uint16 and I=uint32 etc.
