• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

MDL0 file information needed for Converter

Roo525

Smash Ace
Joined
Jan 20, 2010
Messages
537
I basically need all the information I can get for making a converter for MDL0 files. I have a friend who's a programmer, and he says he thinks he can make a converter, but only if he gets required information. Can anyone please reply?

It doesn't matter what info you provide, any will be of big help.
 

superyoshi888

Smash Lord
Joined
Apr 8, 2008
Messages
1,026
The prospect of an mdl0 converter is exciting, but your friend is going to have to be a little more specific. I know RandomTBush and Kryal are probably the ones that have dug the deepest into mdl0. In fact, Kryal almost had a fully functioning converter and RTB can convert some models into mdl0.

Here's RTB's thread on converting mdl0 from one game(such as NSMBwii) to Brawl. Basically, just info on reconstructing the header.
 

JoeGrandma

Smash Journeyman
Joined
Dec 11, 2008
Messages
368
Well, I have a small, inaccurate, basic understanding of MDL0. I have some notes, but some of it isn't accurate. It's all based off of studying and comparing the MDL0 files of Lucario, Link, Ganon, Captain Falcon, Samus, Zero Suit Samus and Mario. I went to study item MDL0 files and they're slightly different from character MDL0, so not all of this applies with items. Anyways, here are the notes:
Code:
--HEADER NOTES--

first 4 bytes always 4D 44 4C 30 or MDL0 in ASCII
offset 4 always 00
bytes 08 through 0F always 00 00 00 09 FF FF FF 80
bytes 10 thourgh 12 always 00 00 05
byte 13 always 90
bytes 14 through 16 always 00 00 05
bytes 18 through 1A always 00 00 0A
bytes 1C through 1D always 00 00
bytes 20 through 21 always 00 00
bytes 24 through 25 always 00 00
bytes 28 through 29 always 00 00
bytes 2C through 2D always 00 00
bytes 30 through 31 always 00 00
bytes 34 through 35 always 00 00
bytes 38 through 3C always 00 00 00 00 00
bytes 40 through 4F always 00 00 00 40 FF FF FF C0 00 00 00 00 00 00 00 00
bytes 50 through 53 is number of vertices in hex
bytes 54 through 57 is number of faces in hex
bytes 58 through 5B always 00 00 00 00
bytes 5C through 5F is number of nodes in hex
bytse 60 through 67 always 01 01 00 00 00 00 00 40
bytes 82 through 83 is number of nodes in hex
bytes 84 through 86 always 00 00 00
bytes 88 through 8A always 00 00 00
bytes 8C through 8C always 00 00 00
bytes 90 through 92 always 00 00 00
bytes 94 through 96 always 00 00 00

--BONE NOTES--
bones are D0 bytes big
first 6 bytes always 00 00 00 D0 FF FF
44 bytes after start of bone is BoneMin
50 bytes after start of bone is BoneMax
20 bytes after start of bone is Scale
2C bytes after start of bone is Rotation
38 bytes after start of bone is Translation
10 bytes after start of bone is NodeID
14 bytes after start of bone is Flags

--VERTICES NOTES--
first 4 bytes are TotalLen, or how big the vertices file is
8 bytes after start is DataOffset
C bytes after start is StringOffset
1E bytes after start is number of vertices

--NORMALS NOTES--

--COLORS NOTES--

--UV POINTS NOTES--

--MATERIALS1 NOTES--

--MATERIALS2 NOTES--

--POLYGONS NOTES--


--TEXTURES1 NOTES--
When it says always, it really isn't always, it's almost always. There are those few MDL0 files that break away from the norm and don't follow them.
Here's some of my notes. I didn't fill in anything for Vertex, Normals, etc. yet, but I'll do so later. And I think I might've listed the wrong values for a few things.

Code:
MDL0 HEADER

Offset		Name
0x00		MDL0 Identifier
0x04		MDL0 Size
0x08		Sections
0x0C		Model Nodes Offset
0x10		Definitions List
0x14		Bones List
0x18		Vertices List
0x1C		Normals List
0x20		Colors List
0x24		UV Points List
0x28		Materials 1 List
0x2C		Materials 2 List
0x30		Polygons List
0x34		Textures 1 List
0x38		Textures 2 List
0x3C		Model Name Offset
0x40		Header Length
0x44		Header Offset
0x48		Unknown 1
0x4C		Unknown 2
0x50		# of Vertices
0x54		# of Faces
0x58		Unknown 3
0x5C		# of Nodes
0x60		Version
0x62		Unknown 4
0x64		Unknown 5
0x68		Box Min. X
0x6C		Box Min. Y
0x70		Box Min. Z
0x74		Box Max. X
0x78		Box Max. Y
0x7C		Box Max. Z
0x80		# of Nodes (Copy?)

BONE HEADER

0x00		Header Length
0x04		MDL0 Offset
0x08		String Offset
0x0C		Bone Index
0x10		Node ID
0x14		Flags
0x18		Pad 1 (?)
0x1C		Pad 2 (?)
0x20		Scale X
0x24		Scale Y
0x28		Scale Z
0x2C		Rotation X
0x30		Rotation Y
0x34		Rotation Z
0x38		Translation X
0x3C		Translation Y
0x40		Translation Z
0x44		Box Min. X
0x48		Box Min. Y
0x4C		Box Min. Z
0x50		Box Max. X
0x54		Box Max. Y
0x58		Box Max. Z
0x5C		Parent Offset
0x60		First Child Offset
0x64		Next Offset
0x68		Previous Offset
0x6C		Bone Strings/Properties Offset
0x70		FrameMatrix Set 1 Float 1
0x74		FrameMatrix Set 2 Float 1
0x78		FrameMatrix Set 3 Float 1
0x7C		FrameMatrix Set 4 Float 1
0x80		FrameMatrix Set 1 Float 2
0x84		FrameMatrix Set 2 Float 2
0x88		FrameMatrix Set 3 Float 2
0x8C		FrameMatrix Set 4 Float 2
0x90		FrameMatrix Set 1 Float 3
0x94		FrameMatrix Set 2 Float 3
0x98		FrameMatrix Set 3 Float 3
0x9C		FrameMatrix Set 4 Float 3
0xA0		InverseBindMatrix Set 1 Float 1
0xA4		InverseBindMatrix Set 2 Float 1
0xA8		InverseBindMatrix Set 3 Float 1
0xAC		InverseBindMatrix Set 4 Float 1
0xB0		InverseBindMatrix Set 1 Float 2
0xB4		InverseBindMatrix Set 2 Float 2
0xB8		InverseBindMatrix Set 3 Float 2
0xBC		InverseBindMatrix Set 4 Float 2
0xC0		InverseBindMatrix Set 1 Float 3
0xC4		InverseBindMatrix Set 2 Float 3
0xC8		InverseBindMatrix Set 3 Float 3
0xCC		InverseBindMatrix Set 4 Float 3

POLYGONS HEADER

0x00		Total Length
0x04		MDL0 Offset
0x08		Node ID
0x0C		Flags 1
0x10		Flags 2
0x14		Unknown 1
0x18		Def. Size
0x1C		Def. Flags
0x20		Def. Offset
0x24		Data Length
0x28		Data Length (Copy?)
0x2C		Data Offset
0x30		Unknown 2
0x34		Unknown 3
0x38		String Offset
0x40		(Undocumented for now)

POLYGON TYPES

0x20		Bone Def 1
0x28		Bone Def 2
0x30		Bone Def 3
0x80 		Quads
0x90		Triangles
0x98		Triangle Strip
0xA0		Triangle Fan
0xA8		Lines
0xB0 		Line Strip
0xB8		Points

TEXTURES 1 HEADER

0x00	# of entries
0x04	Materials 1 Offset
0x08	Materials 2 Offset

TEXTURES 2 HEADER

0x00	# of entries
0x04	Materials 1 Offset
0x08	Materials 2 Offset
And I don't have the values used for the lists yet, because I'm not even sure what half of the values are for. (I know one set's for the offset, and one's for the string, but I'm not sure about the other two.)
All of that stuff came from this thread.
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
alright...
finally got a blank thread :D
all the other threads are way too popular for me to join right now...

yea, I'm that friend of roo's who's programming an importer/exporter for blender...

but finally I get a thread I can subscribe to...


anyways...
thanx for the previous info...
that is quite a help to me :)

thing is, I need to know the conversion methods used,
as well as how to use them...

this would be alot easier if I could read C#
but I only read Py...

Microsoft has ripped me off more than a number of times,
and VC++ destroyed my computer... I quit Microsoft...
not to mention they're not free D:

anyways, so can anyone add comments to the code,
or explain to me how the code works??
 

JoeGrandma

Smash Journeyman
Joined
Dec 11, 2008
Messages
368
Hi, Tcll! Welcome to Smashboards, and way to make your first post!

I really have no idea about how the code works and any of that stuff, but you should visit the link at the very bottom of the post right above Roo's.

That's where a bunch of super coders are making a new Brawlbox, the tool used to open Brwal files and everything, so I suggest you go there to learn about how Brawl files are coded and stuff like that, but I'm not sure, because I don't know this stuff at all.
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
yea... I know what BrBx is... I use it... :p
and I already have the latest .cs files... XD

I just can't read any of them...
thanx though :)
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
You can make model converter?
I'm programmer of BrawlBox Modset. I may be able to explain about that code.
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
actually the correct term is mdl0 importer/exporter
but still... SWEET :D



and you know...
why not kill 2 birds with 1 stone...
need chr0 info too :p

basically I need to convert the data to XYZ translations, WXYZ rotations, and XYZ scales...
I hate quaternions DX
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
I tried to explain Kryal's code for a while,but I found it hard to do that....
Maybe, making converter myself is faster than explaining:ohwell:...
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
I didn't say that seriously:p
But explaining is actually hard. Wait for a while.
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
well if a brawl importer is still too big for me...

I could always use some help with either one of my melee projects... :ohwell:

I'm actually farther on my converter than I am on my importer...
here's a progress image:


I didn't work on this alone...
Milun and Revel8n get credit for this too. :)

yea I'm working on brawl as well as melee :p
I was able to get that through brute forcing the conversion process...
but I need to go through the relocation table and run the offset through a series of tests,
and continue converting until it hits the next offset, then start over with that offset until you reach the end...

my problem is...
I'm not exactly sure how to code something that can do that...
but at least I know what to do... so I'd say that's progress... :p
 
Last edited:

Pharrox

Smash Journeyman
Joined
Jan 26, 2007
Messages
397
Location
Belleville, MI
*Sigh* It's been a LONG time. If you have any questions, feel free to ask. I never really gave up on this, and I recently started a pretty thorough documentation on all Brawl's shader functions (by far the hardest part of graphics hacking, and the thing that stopped my attempts in their tracks). Also I see you're in MI. I don't suppose you go to any tourneys do you? I could probably answer any questions better in person, and give some examples, something I'm not great with doing over the computer.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
@Tcll
Sorry, but I have no time until next weekend.

@Pharrox
I thought that you have quit this stuff. But if you are working on this even now, please explain it in place of me...
 

Pharrox

Smash Journeyman
Joined
Jan 26, 2007
Messages
397
Location
Belleville, MI
Never really quit, just took a break, especially since it seemed that Kryal was on the verge of achieving it, and clearly had a better handle on it than I did, at least as far as programming is concerned. Right now I'm playing with the models from Pokemon Battle Revolution, but I'm trying to keep Brawl in mind and code for both at the same time. I'll be focusing on Brawl again once I'm done with my little PBR project.

I don't really have any general documentation (everything I have is extremely old and inaccurate), and my shader docs are somewhat out of date, but I'll try to write some up when I get the chance. I've been telling myself that forever though.

In the mean time, I'll copy paste an email I just sent to mariokart64n on the subject of vertex weights (the second hardest part after TEV/shader commands)

Ah, Brawl's vertex weights, the bane of anyone trying to fully learn
Brawl's model structure. The weights are actually in a couple
different places. In the header of the MDL0 file, I'm sure you will
see a long series of 0xFFFFFFFF, this is a quick way too find the
first listing.

Every joint in a model has a weight entry for itself, even if it isn't
actually used for weighting any vertices directly. In the MDL0's
header there will be a few 32 bit ints, followed by the aforementioned
block of 0xFFFFFFFF, and then a few more 32 bit ints. The first set
of ints are the indexes of the joints which have vertices that are
weighted only by them (a weight of 1.0 from that joint). After that
there will be a 0xFFFFFFFF entry for every weight used by them model
with influence from multiple joints, and finally the last set of ints
will be the indexes of joints which do not have have any vertices
weighted directly to them.

Next you will need to skip down a bit to the root entry titled
"NodeMix". This is the block of entries which start with either 0x03
or 0x05. I always forget which is which, so I may have it backwards,
but I believe that 0x05 is for weights which are only influenced by
one joint and the 0x03 is for weights with multiple joint influence.
The first set of weights (the ones weighted by a single joint) will
simply list the index of the weight (determined by where the weight
appeared up in the MDL0 header), followed by the index of the joint
which influences it. After that are the weights influenced by
multiple joints which will first have a 16 bit number for the number
of joint influences, followed by that number of entries with a 16 bit
index (the index of a weight which is influenced by only one joint
(not the index of the joint itself)), followed by a 32 bit float
telling the amount of influence that weight/joint has.

I should also mention that in each joint's header is the index of the
weight which it has full influence over. I don't think this is
actually ever used in game, but I figure I should mention it just in
case for the sake of completeness.

Next is the matter of how the weights are applied to the geometry.
There are two ways weights can be applied. The first id for a mesh
which is controlled entirely by a single joint, and the second is for
a mesh which will have different vertices weighted by different vertex
weights. For the first way, if the 8th byte of a polygon block is not
-1, then the entire mesh listed in that block will be weighted by the
weight with the index listed at 0x08. Also, the position of the mesh
will be multiplied to the inverse bind matrix of the joint that
controls it.

Second and finally, there is the matter of how they are applied when
the vertices in a mesh are controlled by multiple weights (0x08 ==
-1). I'm going to assume for this that you already have a basic
understanding of the Wii's primitive lists and draw functions (0x90
for a triangle, 0x98 for tristrip, etc.). In the list of primitive
draw commands there will be entries for transform matrices (0x20 for
position, 0x28 for normals, 0x30 for texture coords, and 0x38 for
lights (not really ever used)). Bear in mind I don't have my
computer, or any files for reference right now, so this may be
slightly off, but I'm sure that you could find any slight errors I
might make for this next part. I believe, after the flag byte (0x20
being the important one) there will be a 16 bit index of a weight,
followed by a 16 bit memory address which the Wii will use for finding
the transform matrix. You will need to find the index of this address
by doing a little math. I believe that for 0x20 the index is:

ActiveWeightIndex = (Address - 0xB000) / 0x1E

This index I will call the ActiveWeightIndex. After which will be a
series of draw commands with their vertex description. The first byte
will be the ActiveWeightIndex and the weight that controls it will be
the weight from the first index of that 0x20 entry. Also, if that
vertex's weight is controlled by a single joint (a weight of 1.0), then
you must multiply the position of that vertex by the inverse bind
matrix of the joint that controls it. Vertices that are weighted by
multiply joints do not have any transforms applied to them.

I hope this helps out a little and is at least somewhat
understandable. I tend to be pretty bad when explaining things like
this. If you need any clarification, feel free to ask. It is quite a
bit complicated and several people have asked me how it works, I
myself had to have it explained to me by Sabretooth, who is the real
genius here for being the one to actually figure it out. I also just
feel like mentioning that I'm playing around with the models in
Pokemon Battle Revolution, and the weights are giving me some trouble
there as well. Nintendo just can't make it easy for us.
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
*Sigh* It's been a LONG time. If you have any questions, feel free to ask. I never really gave up on this, and I recently started a pretty thorough documentation on all Brawl's shader functions (by far the hardest part of graphics hacking, and the thing that stopped my attempts in their tracks). Also I see you're in MI. I don't suppose you go to any tourneys do you? I could probably answer any questions better in person, and give some examples, something I'm not great with doing over the computer.
hey Pharrox :bee:
glad to be talking to a pro :)

ah...
one of those times where it's easier shown than told...

about the tourneys...
wish I could go to some...
I live in monroe, and the only tourney I go to is the one Yoshi holds... (my friend)
if you've ever heard of him, he also goes by: Wuvvz, ~lol~, YoSsY, and lostmagic103
but yea, sry bout that... :(

if you'd like...
I read better in pictures with description...
(as I gave on my melee post)
if you can give simple explanations in pictures
then it should be easy enough :)
and thanx for the shader info, it'll certainly be useful for later. :)

@ Bero

it's ok...
I'm not worried about when...
just worried about if... :)
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
ok... just to get me started...

does anyone have any notes on vert conversion??
I can't seem to get the verts to import right...

here's what I know so far...

header (64 bytes)[data listed below]
relocation table
data table
string table

string offsets relative to data offsets.
 

RandomTBush

Smash Ace
Joined
Aug 10, 2009
Messages
889
Location
Donut Plains
Right now I'm playing with the models from Pokemon Battle Revolution, but I'm trying to keep Brawl in mind and code for both at the same time. I'll be focusing on Brawl again once I'm done with my little PBR project.
W... wait, Battle Revolution? As in, you're working on an exporter for those models, or something along those lines?
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
aww... common someone...

it's been 2 days and I still don't have anything that works well...:(


I mean... I know programming takes a long time...
but at least keep me updated...

hopfully I can do something instead of just sitting around waiting for a reply...:urg:
oh how I wish I could read C... =o=
 

Pharrox

Smash Journeyman
Joined
Jan 26, 2007
Messages
397
Location
Belleville, MI
I'll post a write up on the polygon blocks as soon as I get my laptop back up and running. Just out of curiosity, what model are you using to test this on?

And yeah, writing an exporter for the PBR models. Currently I have successfully extracted the geometry, a slightly deformed skeleton, and some slightly distorted textures. Right now I'm pretty sure that the only major challenge remaining is figuring out the vertex weights.
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
I'll post a write up on the polygon blocks as soon as I get my laptop back up and running. Just out of curiosity, what model are you using to test this on?
KK

models are just random...
but I am mainly gonna use Pikachu...

even though he's already in blender XD
 

RandomTBush

Smash Ace
Joined
Aug 10, 2009
Messages
889
Location
Donut Plains
And yeah, writing an exporter for the PBR models. Currently I have successfully extracted the geometry, a slightly deformed skeleton, and some slightly distorted textures. Right now I'm pretty sure that the only major challenge remaining is figuring out the vertex weights.
Awesome! :D
 

Roo525

Smash Ace
Joined
Jan 20, 2010
Messages
537
So wait, are TCLL and Pharrox working on this thing together? I'm totally lost... :(
 

pokelover980

Smash Ace
Joined
Oct 4, 2007
Messages
905
Eh, I'm bored, I have no time, etc., and I think I'll go through the painful and boring process of seeing how shaders work. In BrawlBox 0.64 Beta you can extract shader files from the MDL0 IIRC, so I'll just mess with those and see how those work. Of course, don't expect anything to come out of it, just some random nonsense.
 

Pharrox

Smash Journeyman
Joined
Jan 26, 2007
Messages
397
Location
Belleville, MI
Well I (seem) to have a fully working laptop again, so here's a writeup on the polygon blocks to the best of my knowledge.

Code:
0x00 - [4] Size
0x04 - [4] MDL0 offset
0x08 - [4] Mesh weight/transform (-1 for per vertex weights)
0x0C - [4] Vertex descriptor 1 (See Bits0)
0x10 - [4] Vertex descriptor 2 (See Bits1)
0x14 - [4] Number of uvs, color channels and normals* per vertex (See Bits2)
0x18 - [4] Vertex descriptor position, normal, color source layout
0x1C - [4] Vertex descriptor uv source layout
0x20 - [4] Offset to shader intructions
0x24 - [4] Size of data block
0x28 - [4] Size od data block
0x2C - [4] Offset to data block
0x30 - [4] Vetrex descriptor source layput
0x34 - [4] Unknown (Always 0x00000000)
0x38 - [4] String offset
0x3C - [4] Index
0x40 - [4] Number of vertices
0x44 - [4] Number of faces
0x48 - [2] Position input
0x4A - [2] Normal input
0x4C - [2] Color0 input
0x4E - [2] Color1 input
0x50 - [2] Coord0 input
0x52 - [2] Coord1 input
0x54 - [2] Coord2 input
0x56 - [2] Coord3 input
0x58 - [2] Coord4 input
0x5A - [2] Coord5 input
0x5C - [2] Coord6 input
0x5E - [2] Coord7 input
0x60 - [4] Weights offset


Weight List
0x00 - [4] Number of weights
0x## - [2] Weight index


Data flags
0x20 - Position matrix
0x28 - Normal matrix
0x30 - Texture matrix
0x38 - Light matrix
0x80 - Quads
0x90 - Triangles
0x98 - Tristrip
0xA0 - Trian
0xA8 - Lines
0xB0 - Linestrip
0xB8 - Points


 _______
|       \
| Bits0  \
|_________\___________________________________
|                                             |
| 0000 0000  0000 000A   ABBC CDDE  FGHI JKLM |
|_____________________________________________|
|                                             |
| A = Color1                                  |
| B = Color0                                  |
| C = Normals                                 |
| D = Posiions                                |
| E = Texture transform0                      |
| F = Texture transform1                      |
| G = Texture transform2                      |
| H = Texture transform3                      |
| I = Texture transform4                      |
| J = Texture transform5                      |
| K = Texture transform6                      |
| L = Texture transform7                      |
| M = Position transform                      |
|_____________________________________________|

 _______
|       \
| Bits1  \
|_________\___________________________________
|                                             |
| 0000 0000  0000 0000   AABB CCDD  EEFF GGHH |
|_____________________________________________|
|                                             |
| A = Coord7                                  |
| B = Coord6                                  |
| C = Coord5                                  |
| D = Coord4                                  |
| E = Coord3                                  |
| F = Coord2                                  |
| G = Coord1                                  |
| H = Coord0                                  |
|_____________________________________________|

 _______
|       \
| Bits2  \
|_________\___________________________________
|                                             |
| 0000 0000  0000 0000   0000 0000  AAAA BBCC |
|_____________________________________________|
|                                             |
| A = UV                                      |
| B = Normals                                 |
| C = Colors                                  |
|_____________________________________________|



* 0 = none, 1 = normal, 2 = nbt

Also, while I'll try to help out where I can, I don't consider myself an active participant in this project.

Finally, for anyone who's interested:
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
thanks for the block info... :)
that'll help out alot...

and nice hob on Ninetails


so how do I convert verticies??

and RTB... did you check yur PM??
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
would it help if I posted my really bad import script...

Code:
updated
I know there's alot of header data missing...
I just want a good vert code is all...

tried just the vert code on the exported verts of an mdl0 file
got 4 sections of scrambled verts...

what am I doing wrong...
please someone tell me what I've been asking for all along...

EDIT:
you might be interested in the HexToDec function...
it's the same method used for Melee... (working)
but I've tried everything to get it to work for Brawl...
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
I have an update to my code showing the labeled vars that will be used...

Code:
revised
didn't do anything except the vars :p

EDIT:
oops :p

should've read a little further before posting this...
wrong header
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
here it is:

Code:
#!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): #not finished
 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) #MDL0 Size
  h03 = mdl0.read(4) #Sections
  h04 = mdl0.read(4) #Model Nodes Offset
  h05 = mdl0.read(4) #Definitions List
  h06 = mdl0.read(4) #Bones List
  h07 = mdl0.read(4) #Vertices List
  h08 = mdl0.read(4) #Normals List
  h09 = mdl0.read(4) #Colors List
  h10 = mdl0.read(4) #UV Points List
  h11 = mdl0.read(4) #Materials 1 List
  h12 = mdl0.read(4) #Materials 2 List
  h13 = mdl0.read(4) #Polygons List
  h14 = mdl0.read(4) #Textures 1 List
  h15 = mdl0.read(4) #Textures 2 List
  h16 = mdl0.read(4) #Model Name Offset
  h17 = mdl0.read(4) #Header Length
  h18 = mdl0.read(4) #Header Offset
  h19 = mdl0.read(4) #Unknown 1
  h20 = mdl0.read(4) #Unknown 2
  h21 = mdl0.read(4) #number of Vertices
  h22 = mdl0.read(4) #number of Faces
  h23 = mdl0.read(4) #Unknown 3
  h24 = mdl0.read(4) #number of Nodes
  h25 = mdl0.read(4) #Version
  h26 = mdl0.read(2) #Unknown 4
  h27 = mdl0.read(2) #Unknown 5
  h28 = mdl0.read(4) #Box Min. X
  h29 = mdl0.read(4) #Box Min. Y
  h30 = mdl0.read(4) #Box Min. Z
  h31 = mdl0.read(4) #Box Max. X
  h32 = mdl0.read(4) #Box Max. Y
  h33 = mdl0.read(4) #Box Max. Z
  h34 = mdl0.read(4) #number 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')
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
I've got 2 other forums where I'm trying to work on this as well...

however...
1 doesn't have anything good yet...
and the other doesn't have enough members... (mine)

this is pretty much the only place where I can work on this well...
hope someone replies soon :)

EDIT:
I know quint posting makes me look bad...
but this took a day and a half to build...

emutalk moves faster than this...
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
Looks nice (to bad that I can't use Blender though).
shoot... anyone can use blender dude :)

if I can install blender on an intel celeron 400 mhz processor with 834 mb of ram and a 9 gb hdd running xp
then you can install it on yours

even if it's a laptop...
blender can literally run on anything
(including win95 (I was desparate))
 

ds22

Smash Lord
Joined
Aug 30, 2009
Messages
1,662
Location
Rotterdam, The Netherlands
anyone can use blender dude :)

if I can install blender on an intel celeron 400 mhz processor with 834 mb of ram and a 9 gb hdd running xp
then you can install it on yours

even if it's a laptop...
blender can literally run on anything
(including win95 (I was desparate))
Is Python needed to run it properly?
But I will try it.
Also, how do you get your script to work in Blender?
 

Tcll

Smash Lord
Joined
Jul 10, 2010
Messages
1,780
Location
The Gates of Darkness
NNID
Tcll5850
Is Python needed to run it properly?
python 2.6 :)

I'd suggest using blender 2.49

But I will try it.
Also, how do you get your script to work in Blender?
go to 'SR:5-Scripting' at the top and paste the script in the text editor/script parser
press 'Alt+P' to run the script

(you won't see the model verts... (only a few verts))
 
Top Bottom