I'm currently working in another thread to find a better conversion method
here's my script:
#!BPY
"""
Name: 'Brawl (.mdl0)...'
Blender: 248
Group: 'Import'
Tooltip: 'Import a Brawl model file (.mdl0)'
"""
__author__= ['Tcll']
__url__ = ("")
__version__= '0.015'
__bpydoc__= '''\
mdl0 Importer
'''
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Bob Holcomb
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
# Importing modules
import struct as S
import Blender
def HexToDec(n):
return float(S.unpack("<h", S.pack("<H", int((n.encode('hex')), 16)))[0])
def readvert(v):
x, y, z = (HexToDec(mdl0.read(2))* 0.001), (HexToDec(mdl0.read(2))* 0.001), (HexToDec(mdl0.read(2))* 0.001)
v = v - 1
return x, y, z
def import_mdl0(path):
Blender.Window.WaitCursor(1)
name = path.split('\\')[-1].split('/')[-1]
mesh = Blender.NMesh.New( name ) # create a new mesh
# parse the file
mdl0 = open(path, 'rb')
if (mdl0.read(4).__str__() == "MDL0"):#MDL0 Magic
print "mdl0 is vald"
h02 = mdl0.read(4) #0x04(4) MDL0 Size
h03 = mdl0.read(4) #0x08(4) Sections
h04 = mdl0.read(4) #0x0C(4) Model Nodes Offset
h05 = mdl0.read(4) #0x10(4) Definitions List
h06 = mdl0.read(4) #0x14(4) Bones List
h07 = mdl0.read(4) #0x18(4) Vertices List
h08 = mdl0.read(4) #0x1C(4) Normals List
h09 = mdl0.read(4) #0x20(4) Colors List
h10 = mdl0.read(4) #0x24(4) UV Points List
h11 = mdl0.read(4) #0x28(4) Materials 1 List
h12 = mdl0.read(4) #0x2C(4) Materials 2 List
h13 = mdl0.read(4) #0x30(4) Polygons List
h14 = mdl0.read(4) #0x34(4) Textures 1 List
h15 = mdl0.read(4) #0x38(4) Textures 2 List
h16 = mdl0.read(4) #0x3C(4) Model Name Offset
h17 = mdl0.read(4) #0x40(4) Header Length
h18 = mdl0.read(4) #0x44(4) Header Offset
h19 = mdl0.read(4) #0x48(4) Unknown 1
h20 = mdl0.read(4) #0x4C(4) Unknown 2
h21 = mdl0.read(4) #0x50(4) # of Vertices
h22 = mdl0.read(4) #0x54(4) # of Faces
h23 = mdl0.read(4) #0x58(4) Unknown 3
h24 = mdl0.read(4) #0x5C(4) # of Nodes
h25 = mdl0.read(4) #0x60(4) Version
h26 = mdl0.read(2) #0x62(2) Unknown 4
h27 = mdl0.read(2) #0x64(2) Unknown 5
h28 = mdl0.read(4) #0x68(4) Box Min. X
h29 = mdl0.read(4) #0x6C(4) Box Min. Y
h30 = mdl0.read(4) #0x70(4) Box Min. Z
h31 = mdl0.read(4) #0x74(4) Box Max. X
h32 = mdl0.read(4) #0x78(4) Box Max. Y
h33 = mdl0.read(4) #0x7C(4) Box Max. Z
h34 = mdl0.read(4) #0x80(4) # of Nodes (Copy?)
a = 0
while(a==0):
x, y, z = (HexToDec(mdl0.read(2))* 0.001), (HexToDec(mdl0.read(2))* 0.001), (HexToDec(mdl0.read(2))* 0.001)
v = "v "+(x).__str__()+" "+(y).__str__()+" "+(z).__str__()
if (v == 'v 0.0 0.0 0.0'):
a = 1
mesh.verts.append(Blender.NMesh.Vert(x, y, z))
else:
print "file is not in mdl0 fomat"
mdl0.close()
# link the mesh to a new object
ob = Blender.Object.New('Mesh', name) # Mesh must be spelled just this--it is a specific type
ob.link(mesh) # tell the object to use the mesh we just made
scn = Blender.Scene.GetCurrent()
for o in scn.getChildren():
o.sel = 0
scn.link(ob) # link the object to the current scene
ob.sel= 1
ob.Layers = scn.Layers
Blender.Window.WaitCursor(0)
Blender.Window.RedrawAll()
Blender.Window.FileSelector(import_mdl0, 'Import')
I'm afraid this doesn't work correctly at the moment...
here's what I use to test the verts:
#!BPY
"""
Name: 'Brawl (.mdl0)...'
Blender: 248
Group: 'Import'
Tooltip: 'Import a Brawl model file (.mdl0)'
"""
__author__= ['Tcll']
__url__ = ("")
__version__= '0.015'
__bpydoc__= '''\
mdl0 Importer
'''
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Bob Holcomb
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
# Importing modules
import struct as S
import Blender
def HexToDec(n):
h = float(S.unpack("<h", S.pack("<H", int((n.encode('hex')), 16)))[0])
# while (h > 127): # uncomment this code for better results:
# h = h*(1/256)
return h
def import_mdl0(path):
Blender.Window.WaitCursor(1)
name = path.split('\\')[-1].split('/')[-1]
mesh = Blender.NMesh.New( name ) # create a new mesh
# parse the file
mdl0 = open(path, 'rb')
a = 0
while(a==0):
x, y, z = (HexToDec(mdl0.read(2))* 0.001), (HexToDec(mdl0.read(2))* 0.001), (HexToDec(mdl0.read(2))* 0.001)
v = "v "+(x).__str__()+" "+(y).__str__()+" "+(z).__str__()
if (v == 'v 0.0 0.0 0.0'):
a = 1
mesh.verts.append(Blender.NMesh.Vert(x, y, z))
# link the mesh to a new object
ob = Blender.Object.New('Mesh', name) # Mesh must be spelled just this--it is a specific type
ob.link(mesh) # tell the object to use the mesh we just made
scn = Blender.Scene.GetCurrent()
for o in scn.getChildren():
o.sel = 0
scn.link(ob) # link the object to the current scene
ob.sel= 1
ob.Layers = scn.Layers
Blender.Window.WaitCursor(0)
Blender.Window.RedrawAll()
Blender.Window.FileSelector(import_mdl0, 'Import')
the commented code shows you all the verts (jumbled),
image: http://lh6.ggpht.com/_IteXPmeC6ek/TEM0aOaSWNI/AAAAAAAABSI/TuaDipSUil8/vert.jpg
while uncommenting it shows you about 10 verts (clean).
image: http://lh6.ggpht.com/_IteXPmeC6ek/TES3ybhIrrI/AAAAAAAABS0/9vcAJLZtvio/progress.jpg
export a vert selection from an mdl0 file with Brawlbox, and impoort that file...
(make sure to add about 2 lines of '00' to the end of the file in a hex editor before importing)
the attatchment below is not a pdf file
it's the vert export I used
import directly into blender
(zero's are already added)