Title: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: ForOhFor Error on April 06, 2011, 06:40:57 PM We already have working programs to hex imports from games with MDL0s into usable models. However, these programs are fairly slow, only fix one MDL0 at a time, and, well, there's 3 of the things thatn eed to be run separately.
I am doing my first full program, based in python, to remedy that situation. It will combine the 3 steps (header, materials, polygons) into one program, which will hex every model in a brres file. And, since it's in Python instead of Gamemaker, it's much faster than the existing programs. It will be useful for, say, hexing those bothersome okami models. UPDATE LOG: V 2.0: -Added a GUI -Added multi-BRRES support -Now overwrites input files Program completed, download here: http://dl.dropbox.com/u/5869687/Python%20Model%20Hexer%202%20%28GUI%29.zip Old version: http://dl.dropbox.com/u/5869687/Python%20Model%20Hexer%20-%20Complete.zip TO DO BEFORE FULL RELEASE: Done In progress Bug fixing Not started - Opening file, translating into a usable string - Locating all MDL0s and logging their locations - Creation of a module to store long functions - MDL0 header fixing function - MDL0 material fixing function - MDL0 polygon fixing function - Launching these functions through a main program - Translating usable hex back to a savable format - Saving the file I may need some help along the way, just for the locating of specific values in the hex data. Title: Re: [Python] All-in-one import hexer. Post by: BlackJax96 on April 06, 2011, 06:50:00 PM Nice. This will help a lot.
Good luck, if you need it ;) Title: Re: [Python] All-in-one import hexer. Post by: ForOhFor Error on April 06, 2011, 07:30:41 PM Thanks!
(Also, note that, not only being my first utility program, I've never really manually hexed anything before :P) I've made some progress, but have a small problem: How a certain block should look like after the header fix (From the existing fixing program): How it does look: No clue what's causing it... but that's the only difference once both have been header fixed. Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 07, 2011, 01:53:51 PM how are you handeling the values??
are the values being handeled floats or ints?? it's possible you could be handeling a float as an int Title: Re: [Python] All-in-one import hexer. Post by: ForOhFor Error on April 07, 2011, 02:05:14 PM as a string...
Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 07, 2011, 02:28:25 PM ah
here, the full mdl0 header should look like this: note: this is reading from it #<<header>> magic = fr.read(4) if magic == 'MDL0': #check if valad print 'MDL0 file is valad' #check #--header (part1)-- strtbl_offset = ui(fr.read(4)) sections = ui(fr.read(4)) nodes_offset = si(fr.read(4))*(0-1) #list offsets to relocation table groups definits_list = ui(fr.read(4)) bones_list = ui(fr.read(4)) vertices_list = ui(fr.read(4)) normals_list = ui(fr.read(4)) colors_list = ui(fr.read(4)) uv_points_list = ui(fr.read(4)) materials_list = ui(fr.read(4)) shader_conf_list = ui(fr.read(4)) objects_list = ui(fr.read(4)) textures_list = ui(fr.read(4)) pallets_list = ui(fr.read(4)) #--header (part2)-- string_offset = ui(fr.read(4)) header_length = ui(fr.read(4)) #64 header_offset = ui(fr.read(4)) #--displayed in brawlbox:-- unknown_1 = fr.read(4) unknown_2 = fr.read(4) NumVertices = ui(fr.read(4)) NumFaces = ui(fr.read(4)) unknown_3 = fr.read(4) NumNodes = ui(fr.read(4)) version = hex(fr.read(4)) #no idea how to handle unknown_4 = fr.read(4) MinX,MinY,MinZ = fl(fr.read(4)),fl(fr.read(4)),fl(fr.read(4)) MaxX,MaxY,MaxZ = fl(fr.read(4)),fl(fr.read(4)),fl(fr.read(4)) NumNodes2 = fr.read(4) #(Copy?) #<</header>> here's the common functions being used: #--<<common functions>>-- import struct as St def L(this): return St.unpack('>l', this)[0] #return a long int def hex(this): return this.encode('hex') #return the hex value of a char def ui(this): return int(this.encode('hex'),16) #return an unsigned 8bit, 16bit, or 32bit int (most common) def si(this): return int(long(this.encode('hex'),16)-2**32) #return a signed 8bit, 16bit, or 32bit int def bfl(this): return St.unpack("<f", this)[0] #return a big endian 32bit float def fl(this): return St.unpack(">f", this)[0] #return a 32bit float (highly common) #--<</common functions>>-- Title: Re: [Python] All-in-one import hexer. Post by: ForOhFor Error on April 07, 2011, 02:36:13 PM That code from your Universal Model Converter?
Thing is, I'm just using this here (the tutorial): http://www.smashboards.com/showthread.php?t=263127 as a guide for what to change, using code to do the steps. :/ Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 07, 2011, 02:37:57 PM if you're having any problems understanding how to code for the MDL0,
you can look into my WIP template for HexEdit: http://brawlimports.proboards.com/index.cgi?board=templates&action=display&thread=12 Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 07, 2011, 02:42:43 PM That code from your Universal Model Converter? yea...you can use it to see how to write the values btw, use St.pack not St.unpack as in the functions use the L() function when writing something like '00 00 00 09' if you use ui(), you'll just get '09' I like to use chr(int(h,16)) alot, and I use chr(0) for padding Title: Re: [Python] All-in-one import hexer. Post by: ForOhFor Error on April 07, 2011, 02:56:41 PM Well, here's the code I'm using in the MDL0 fixing module:
Code: import string I call fixHeader() first, with my logged position of the MDL0 file (indexNum) and the data of the brres file, saved as a string (Data) as arguments (This does all the steps in the text tutorial, excluding adding 3 'FFFFFFFF's), set a new data string (newdata) to the returned string then call fixHeaderPt2() to add the 3 'FFFFFFFF's and set newdata to that. Here's the main program's code: Code: import os Of course, that's just what I have so far. The problematic part is that the output from this program differs from the fixed product of the existing MDL0 header fixer :/ Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 07, 2011, 03:13:43 PM that's some complicated code you got there it'd be a shame if something were to happen to it... lol but I see you're storing the file in a var... that might be your complication... you'll notice I'm just using: fr.read(4) fr.read(4) fr.read(4) you could use: fw.write(var1) fw.write(var2) fw.write(var3) I find it alot more simpler and organized to do than all that fancy code-work with a stored data var I'm not too sure of your prob since I'm seeing that :/ that would take me a while to figure out... I'm on a minecraft server right now, so I'm not too into the coding stuff... doesn't mean I can't lend over some info though :) use my code to figure out how to write the specific data types to the header (weather to write int(), float(), long(), etc...) glad your using len() for alot of it btw, been wanting to say this for so long: your ava is freakin WIN!!! <3 <3 Title: Re: [Python] All-in-one import hexer. Post by: Difegue on April 07, 2011, 03:20:21 PM I don't know if it can be of any use to you, but I have the Game Maker source files of FortWaffles' original programs >.> (GM8 decompiler works wonders)
Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 07, 2011, 03:22:35 PM I don't know if it can be of any use to you, but I have the Game Maker source files of FortWaffles' original programs >.> (GM8 decompiler works wonders) I can haz plz =D I've been wanting to look at FW's src codes for quite a while :D Title: Re: [Python] All-in-one import hexer. Post by: Difegue on April 07, 2011, 03:34:54 PM Sure, I'll copy-paste the scripts... They're written in Game Maker Code, so ask me if you don't understand a function or something:
If it's of any use to you, I'll post the codes for the Matrix and Polygon fixers ;) Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 07, 2011, 04:39:12 PM If it's of any use to you, I'll post the codes for the Matrix and Polygon fixers ;) all of them plz hmm, GM code looks like a mix of C++ and Py interesting Title: Re: [Python] All-in-one import hexer. Post by: ForOhFor Error on April 07, 2011, 05:07:17 PM So, properly following the steps I've been trying to follow gives the exact output as the existing fixer does.
That's good... any other way, and I'd go insane XD Title: Re: [Python] All-in-one import hexer. Post by: ForOhFor Error on April 07, 2011, 09:36:17 PM HYESS!
I've done it! I've fixed the problem! The program will now fix every header in any amount of MDL0 files! EDIT: Wait... what? I ran it through some... fixed 'em fine. Then I ran it through some different files. It made every model be named ÿÿÿ¸ÿÿÿÀ clearly, I have some bugs... Title: Re: [Python] All-in-one import hexer. Post by: DarkPikachu on April 08, 2011, 01:21:26 PM glad to hear of your progress :)
I'll prbly do better if I get your src when it's finished ;) EDIT: can you leave alot of commenting like I do :/ Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: ForOhFor Error on April 08, 2011, 07:20:11 PM I added a lot of comments. The second function has no comments, but you should be able to figure it out, it's almost the same as the first function.
Alpha version released, only fixes the header: http://dl.dropbox.com/u/5869687/PythonModelHexer%20-%20HEADER%20ONLY%20ALPHA.rar It should determine which function is needed. If it doesn't work, please post a bug report here. Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: DarkPikachu on April 08, 2011, 09:03:54 PM alright :)
also, could I reverse-engineer this...?? like say I wanted to get a model from brawl into Pokepark or some game I want my converter to be able to work both ways :/ Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: the98pika on April 08, 2011, 09:10:34 PM When i double click it says windows can't open this file what do i do?
Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: BlackJax96 on April 08, 2011, 09:14:42 PM When i double click it says windows can't open this file what do i do? You install python 2.6 lol Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: ForOhFor Error on April 08, 2011, 09:34:31 PM alright :) Sure :Dalso, could I reverse-engineer this...?? like say I wanted to get a model from brawl into Pokepark or some game I want my converter to be able to work both ways :/ BTW, I'm fine-tuning my BRRES separator to auto-fix the brres files output from it. Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: ForOhFor Error on April 10, 2011, 02:28:16 PM I realized that, though going at header fixing on a model-by-model basis works quite well, the same cannot be said for material and polygon fixing.
Therefore, I'm doing separate counts of models, materials, and polygons. BTW, material fixing is working. I think. EDIT: My mistake. It's ALMOST working. Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: SSJCerious on April 10, 2011, 04:49:17 PM This is going to be a good program, good luck ForOhFoR~
Title: Re: [Python] All-in-one import hexer. ALPHA (Header only) RELEASED Post by: ForOhFor Error on April 12, 2011, 04:15:34 AM Thanks
I haven't gotten much working. I'm gonna work on it more this weekend. And I'm also gonna learn how to 3D print this Sunday (not that I have a 3D printer)! Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: ForOhFor Error on April 12, 2011, 02:44:34 PM Program completed, download here:
http://dl.dropbox.com/u/5869687/Python%20Model%20Hexer%20-%20Complete.zip Gonna go implement these functions in the BRRES separator. Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: Difegue on April 12, 2011, 03:44:45 PM you are my hero
Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DarkPikachu on April 12, 2011, 03:59:07 PM I'm gonna try my hand at brres conversion as well...
since the brres format is more like the blend format... somewhat pac/pcs is actually closer Melee's dat format is like a brres that can't be split D: ^blah Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: ForOhFor Error on April 12, 2011, 04:08:25 PM Oh, Tcll, check out the brres separator thread. I've implemented the model fixing into it, so it will fix every mdl0 in every brres in the input file.
Which means you can extract and fix all of pokepark's pokemon very, very quickly. ;D Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DarkPikachu on April 12, 2011, 04:44:33 PM Oh, Tcll, check out the brres separator thread. I've implemented the model fixing into it, so it will fix every mdl0 in every brres in the input file. I saw that already :)Which means you can extract and fix all of pokepark's pokemon very, very quickly. ;D nice job :D Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: BlackJax96 on April 12, 2011, 04:49:34 PM This will save so much time :srs:
Freakin AWESOME job; will use. Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: ForOhFor Error on April 12, 2011, 04:58:36 PM And, of course, anyone's free to use the code in their own projects.
If they can read the uncommented hellscape that my coding is XD Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: BlackJax96 on April 12, 2011, 05:03:53 PM And, of course, anyone's free to use the code in their own projects. If they can read the uncommented hellscape that my coding is XD I may try to translate it to C#... (So I can add it to Brawlbox :D) Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DarkPikachu on April 12, 2011, 05:06:51 PM I may try to translate it to C#... (So I can add it to Brawlbox :D) heh... good luck with that... Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: Naruto200Man on April 12, 2011, 05:26:48 PM So
I would be able to make a tales of symphonia model work with this? I'm dying to make a Genis psa =3 You should also add a bone tree editor, like it automatically rigs the bones for brawl use. If that's possible, since most models from other games have a [censored]-ton of bones. Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: ForOhFor Error on April 12, 2011, 05:42:28 PM So This program only changes a few bytes of data. Redoing bones, besides being completely unknown to me, would probably a complete restructure of the model.I would be able to make a tales of symphonia model work with this? I'm dying to make a Genis psa =3 You should also add a bone tree editor, like it automatically rigs the bones for brawl use. If that's possible, since most models from other games have a [censored]-ton of bones. In other terms, no. Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DarkPikachu on April 12, 2011, 06:01:30 PM you could create a program for my method of adding bones :/
here's an example for Pika (the one I know by heart): bones: TopN -TransN --XRotN ---YRotN ----HipN -----HaveN (to be repositioned to the char's head or hand) -----(add your bones here) ----ThrowN ^don't animate these bones... (only animate your bones) Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DSX8 on April 16, 2011, 02:45:42 PM ok umm how do i exactly use this? i dont see a application/exe program... i only see these...
___MDL0Fix___.py ___MDL0Fix___.pyc PyModHex.py Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: BlackJax96 on April 16, 2011, 02:49:54 PM Run PyModHex.py
If nothing happens when you double click it, install Python. Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DSX8 on April 16, 2011, 02:50:37 PM Run PyModHex.py If nothing happens when you double click it, install Python. and where CAN i find python? Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: BlackJax96 on April 16, 2011, 02:53:13 PM http://www.python.org/download/
:af: Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DSX8 on April 16, 2011, 02:53:30 PM [url]http://www.python.org/download/[/url] :af: xDD thanks :af: Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: BlackJax96 on April 16, 2011, 02:54:16 PM Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: SmashClash on April 17, 2011, 01:50:42 PM Some day I hope a external graphic importer is made for PSA. :)
Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: SSJCerious on April 17, 2011, 01:55:31 PM ^I hope you mean from other games, if not, then your dream as already come true~
Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: SmashClash on April 17, 2011, 01:57:37 PM ^I hope you mean from other games, if not, then your dream as already come true~ Some day I hope a external graphic importer is made for PSA. :) You sure? Cuz in PSA some characters need enough graphics for enough models to be able to be imported.Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: SSJCerious on April 17, 2011, 01:59:24 PM Um...what? I was reffering to TheShyGuy's ext model replacer program....you should check it out. 3rd or 4th page in OnTopic Discussion.
Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: DarkPikachu on April 17, 2011, 03:44:41 PM Um...what? I was reffering to TheShyGuy's ext model replacer program....you should check it out. 3rd or 4th page in OnTopic Discussion. I'm still working on my REFT editor... it'll be better than TSG's, and you'll be able to actually replace more with it although... I havn't worked on it in a while... been having too many other things to worry about >_> Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: ForOhFor Error on April 18, 2011, 06:01:59 PM I've been messing around with tkinter. Should I implement a GUI?
Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: SmashClash on April 18, 2011, 06:20:35 PM I'm still working on my REFT editor... it'll be better than TSG's, and you'll be able to actually replace more with it although... I havn't worked on it in a while... been having too many other things to worry about >_> Title: Re: [Python] All-in-one import hexer. DONE! Get the complete version! Post by: ForOhFor Error on April 18, 2011, 07:30:29 PM New version:
http://dl.dropbox.com/u/5869687/Python%20Model%20Hexer%202%20%28GUI%29.zip Has a GUI, and multiple file support. What's more, it overwrites the input files. Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: DarkPikachu on April 18, 2011, 07:55:03 PM New version: [url]http://dl.dropbox.com/u/5869687/Python%20Model%20Hexer%202%20%28GUI%29.zip[/url] Has a GUI, and multiple file support. What's more, it overwrites the input files. multiple files you say... interesting I wanna do that to my converter :D EDIT: btw, you don't need both the py and pyc theyre the same exact files... one's just a compiled output Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: Parvati ~ <3 on April 18, 2011, 08:04:13 PM YES! ITS FINALLY OUT!
Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: DarkPikachu on April 18, 2011, 08:08:26 PM hey...
hav you figured out how to save filetypes by the filter type?? Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: ForOhFor Error on April 18, 2011, 08:34:27 PM No.
And I'm putting both .py and .pyc because .pyc is auto-created when using import, and the .py is for anyone who wants to use my code. Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: BlackJax96 on April 18, 2011, 08:49:25 PM New version: [url]http://dl.dropbox.com/u/5869687/Python%20Model%20Hexer%202%20%28GUI%29.zip[/url] Has a GUI, and multiple file support. What's more, it overwrites the input files. I just fixed more than 60 brres files with more than two mdl0s in them in under a minute. Your program is a flipping lifesaver!!! Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: Naruto200Man on April 18, 2011, 08:52:36 PM *sideglance*
BJ I just want to know one thing... WHAT ANIME IS THAT VID FROM?? XD dang, I just remembered a sparta clip idea that I had :l But crap, I have to download a bunch of jackie chan adventures episodes from youtube to make it XD Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: BlackJax96 on April 18, 2011, 08:57:01 PM *sideglance* BJ I just want to know one thing... WHAT ANIME IS THAT VID FROM?? XD dang, I just remembered a sparta clip idea that I had :l But crap, I have to download a bunch of jackie chan adventures episodes from youtube to make it XD lol it's Azumanga Daioh Osaka :srs: Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: ForOhFor Error on April 18, 2011, 09:16:22 PM I just fixed more than 60 brres files with more than two mdl0s in them in under a minute. Your program is a flipping lifesaver!!! Heh, no problem. Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: DarkPikachu on April 18, 2011, 09:20:56 PM I'm starting to have that feeling of:
I was the first to have the idea and now someone else is getting all the credit -.-* -_- Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: Difegue on April 19, 2011, 05:50:14 AM Haha, I was using your program earlier and actually thought "dawg it'd be cool if I didn't have to relaunch the program everytime" and there you go.
This is the best thing, brb fixing my 60-something brres from Haruhi Wii Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: BlackJax96 on April 19, 2011, 04:38:22 PM This is the best thing, brb fixing my 60-something brres from Haruhi Wii Haha that's what I was fixing too lol I'm gonna see if I can fix Elebits models now Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: SSJCerious on April 19, 2011, 04:44:31 PM I'm starting to have that feeling of: Well, i had a idea of making a Goku vertex, does that mean Beyond's getting MY credit?I was the first to have the idea and now someone else is getting all the credit -.-* -_- No. Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: DarkPikachu on April 19, 2011, 04:52:32 PM Well, i had a idea of making a Goku vertex, does that mean Beyond's getting MY credit? lolNo. yea... but I did mention it and I even PM'd someone I'd do it... heh so yea... I know I'm still getting credit for the idea :) just wish I could've done it is all -.- Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: Naruto200Man on April 21, 2011, 12:38:01 PM Hey,
any chance you could make an exe version of this that doesn't need python :af2: Title: Re: [Python] All-in-one import hexer. Version 2! GUI and multiple file support! Post by: DarkPikachu on April 21, 2011, 12:49:03 PM Hey, any chance you could make an exe version of this that doesn't need python :af2: you can make exe's with Py... all you need to do is include the python##.dll (I think) I havn't really looked into it so I can't really say I know how... but I do know it can be done >_> |