Kitty Corp Meow Mix Forums

Super Smash Bros. Brawl Hacking => Programming => Topic started by: ForOhFor Error on July 06, 2011, 09:20:42 AM



Title: ForOhFor's Python Nest [Collisions to shadow system program released! 10/11/11]
Post by: ForOhFor Error on July 06, 2011, 09:20:42 AM
(http://dl.dropbox.com/u/5869687/PyNest.png)

Yep, I'm a novice Python programmer (Just started seriously this year) and have made a few simple (and one not-so-simple) brawl hacking utilities.

All of them require Python to run (Python 2.7 is what I use, you should install that version).
You can get Python for free at http://python.org/download/

So, on to the programs!

PyShade (Collisions to shadow system converter):
Adding the shadow system to a stage is time-consuming and annoying. I've made a program to streamline the process, by outputting shadow models that follow the path of a loaded collision file.

Contains a config file, the options should be straight-forward.

Download:
http://dl.dropbox.com/u/5869687/PyShade.zip

Brres Model Fixer:
Based on FW's programs for imported model fixing, this program fixed all of the models in a brres file.
The methods are... a bit buggy. They won't work on some games. Please tell me what games this does work on.
Confirmed games:
Okami
File to run:
PyModHex.pyw
Download:
http://dl.dropbox.com/u/5869687/BrresModelFixer.zip

Brres Separator (Auto-Hexing):

You're looking through a file, and it clearly has BRRES files in it (a memory dump, or some file from an iso, whatever.) However, it would take hours to extract them all manually.

This happened when I was looking through the stage files from okami. So I wrote a small program to fix it.

Simply start the program, select the file with the brres files contained within, and relax as the BRRES Separator creates all the BRRES files in that file, in the same directory the file is in.

What's more, this program will now AUTOMATICALLY hex the models in the BRRES!

File To Run:
BrresSep.py
Download:
http://dl.dropbox.com/u/5869687/AutoHexBrresSep.zip

Brres Separator (Non-Auto-Hexing):
Same as the above, but does not hex automatically. For files my Model Fixer cannot fix as of yet.
Download:
http://dl.dropbox.com/u/5869687/BrresSep.py

Automatic Polygon Reattacher:
It's a program that automatically does the steps in this tutorial:
http://forums.kc-mm.com/index.php?topic=23654.0
Download:
http://dl.dropbox.com/u/5869687/PythonPolygonReattacher.zip


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on July 06, 2011, 08:40:56 PM
Current running projects:

Wireframe model maker (sort of) and viewer:
A simple model viewer I'm building to display a model of my own primitive format in wireframe mode. Just a bit of playing around to see how much I can do. A demo may be released if it gets any good.

Collisions to shadow system:
Adding the shadow system to a stage is time-consuming and annoying. I'm making a program to streamline the process, by making the shadow system follow collisions.


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on August 09, 2011, 05:22:23 PM
Bump with an update.

I'm working on a program that runs on your computer being mostly passive. If you update a file in your dropbox account, then it detects it and, depending on the command, can give you a list of files and folders in a folder (to find files) and can send ANY FILE FROM THE COMPUTER IT'S RUNNING ON to your email.

Right now, it requires a link to the file on dropbox, and a gmail account with its password. I use a gmail account I only use for having Python send mail.

There's a version that can do it entirely through email, but it's very buggy.


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on August 09, 2011, 05:36:28 PM
u should try to update ur brres model hexing separator file so that it can also hex other model types.


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on August 09, 2011, 05:42:42 PM
I might, soon.


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on August 09, 2011, 06:26:52 PM
I might, soon.
ok :D


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on August 09, 2011, 08:30:04 PM
btw, I couldn't help but knowtice...

your model fixer doesn't fix the string offsets >_>


btw...
you don't appear to even know how it works...

I can tell ya if you like ;)


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on August 09, 2011, 08:32:17 PM
btw, I couldn't help but knowtice...

your model fixer doesn't fix the string offsets >_>


btw...
you don't appear to even know how it works...

I can tell ya if you like ;)
O.o  so is that y some of the okami models or textures dont work in Dolphin? (i use dolphin for testin my stages since i dont have my wii around me)


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on August 09, 2011, 08:44:07 PM
O.o  so is that y some of the okami models or textures dont work in Dolphin? (i use dolphin for testin my stages since i dont have my wii around me)

nah...
if it's with dolphin, IDK what the error is...

all I know is Okami uses v11 MDL0's

however...
it could possibly be a plugin or version error...

different dolphin versions work differently with different computers...
so the error with Okami may not happen on my computer

EDIT:
DEEERRRP...
you're talking about okami models working in brawl

A: that could be a possibility


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on August 09, 2011, 08:56:36 PM

nah...
if it's with dolphin, IDK what the error is...

all I know is Okami uses v11 MDL0's

however...
it could possibly be a plugin or version error...

different dolphin versions work differently with different computers...
so the error with Okami may not happen on my computer

EDIT:
DEEERRRP...
you're talking about okami models working in brawl

A: that could be a possibility
hah yeah, i meant Okami Models working in brawl. cause v4 i added more okami models to my stage, i started to get a error wit dolphin after adding a tree model from the game, then the error happened. would u be able to fix this urself tcll? o.o


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on August 09, 2011, 09:03:40 PM
hah yeah, i meant Okami Models working in brawl. cause v4 i added more okami models to my stage, i started to get a error wit dolphin after adding a tree model from the game, then the error happened. would u be able to fix this urself tcll? o.o
*sigh*
I don't  feel like, nor am I in the correct position, to fix nearly 60-80 string offsets...

Pachirisu's bad enough with nearly 20 offsets... so yeh... I give on that... heh


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on August 09, 2011, 09:28:30 PM
*sigh*
I don't  feel like, nor am I in the correct position, to fix nearly 60-80 string offsets...

Pachirisu's bad enough with nearly 20 offsets... so yeh... I give on that... heh
O_o  wow u have to fix 60-80 offsets in his MDL0 hexing program? yikes o.e... thats... bad ill say... i say tell ForOhFor on how to fix it and he should be able to do it! :D


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on August 10, 2011, 05:33:20 AM
not in his program...
they're in the MDL0's

but when fixing...
the string data has to have a value subtracted from it
(not sure how to get that value at this moment)


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on August 10, 2011, 11:17:18 AM
not in his program...
they're in the MDL0's

but when fixing...
the string data has to have a value subtracted from it
(not sure how to get that value at this moment)
ah i see... hmm... and his program doesnt fix those doesnt it?


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on August 10, 2011, 11:29:46 AM
No, my program changes so little, and I don't know what I'm even changing. I just automated a tutorial, basically.


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on August 10, 2011, 11:54:36 AM
heh... actually 404...
all your program does is delete the 3 unk offsets,
and then adds 'FFFFFFFF' * 3 to the end of the header. (before the pipelines)

then it changes the header length with a hard-coded length

and I believe that's it...
the string offsets arn't modified >_>

you can look at my MDL0 resource thread for detailed info on the format ;)
(including v11 header info)


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 27, 2011, 03:13:26 PM
Hmm.

Anyway, update! New program in progress!

Collisions to shadow system:
Adding the shadow system to a stage is time-consuming and annoying. I'm making a program to streamline the process, by making the shadow system follow collisions.
-----------------------
I've gotten it parsing all the collision data I'll need!


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on September 27, 2011, 03:16:02 PM
Hmm.

Anyway, update! New program in progress!

Collisions to shadow system:
Adding the shadow system to a stage is time-consuming and annoying. I'm making a program to streamline the process, by making the shadow system follow collisions.
-----------------------
I've gotten it parsing all the collision data I'll need!
and how does this work exactly? O.o


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 27, 2011, 03:28:07 PM
It will open the collision data, and read all of the points and planes. It takes every plane that is the floor type, and outputs a flat shadow model positioned correctly for that plane.

Anyway, my output for the function which parses the collision data:
left point x coord (in floating point hex): c2a48244
left point y coord (in floating point hex): 4125cff3
right point x coord (in floating point hex): c26ef172
right point y coord (in floating point hex): 4125cff6
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): c26ef172
left point y coord (in floating point hex): 4125cff6
right point x coord (in floating point hex): 425c89f2
right point y coord (in floating point hex): 4125cff4
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): 425c89f2
left point y coord (in floating point hex): 4125cff4
right point x coord (in floating point hex): 42a4c3fa
right point y coord (in floating point hex): 4125cff0
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): 42a4c3fa
left point y coord (in floating point hex): 4125cff0
right point x coord (in floating point hex): 42a4c3f9
right point y coord (in floating point hex): c122e273
collision type: right wall
-------------------------------------------
left point x coord (in floating point hex): 42a4c3f9
left point y coord (in floating point hex): c122e273
right point x coord (in floating point hex): c2a48244
right point y coord (in floating point hex): c122e270
collision type: roof
-------------------------------------------
left point x coord (in floating point hex): c2a48244
left point y coord (in floating point hex): c122e270
right point x coord (in floating point hex): c2a48244
right point y coord (in floating point hex): 4125cff3
collision type: left wall
-------------------------------------------
The floating point hex isn't converted because I can't find a python method to do that :/


Title: Re: ForOhFor's Python Nest
Post by: DSX8 on September 27, 2011, 03:44:17 PM
It will open the collision data, and read all of the points and planes. It takes every plane that is the floor type, and outputs a flat shadow model positioned correctly for that plane.

Anyway, my output for the function which parses the collision data:
left point x coord (in floating point hex): c2a48244
left point y coord (in floating point hex): 4125cff3
right point x coord (in floating point hex): c26ef172
right point y coord (in floating point hex): 4125cff6
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): c26ef172
left point y coord (in floating point hex): 4125cff6
right point x coord (in floating point hex): 425c89f2
right point y coord (in floating point hex): 4125cff4
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): 425c89f2
left point y coord (in floating point hex): 4125cff4
right point x coord (in floating point hex): 42a4c3fa
right point y coord (in floating point hex): 4125cff0
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): 42a4c3fa
left point y coord (in floating point hex): 4125cff0
right point x coord (in floating point hex): 42a4c3f9
right point y coord (in floating point hex): c122e273
collision type: right wall
-------------------------------------------
left point x coord (in floating point hex): 42a4c3f9
left point y coord (in floating point hex): c122e273
right point x coord (in floating point hex): c2a48244
right point y coord (in floating point hex): c122e270
collision type: roof
-------------------------------------------
left point x coord (in floating point hex): c2a48244
left point y coord (in floating point hex): c122e270
right point x coord (in floating point hex): c2a48244
right point y coord (in floating point hex): 4125cff3
collision type: left wall
-------------------------------------------
The floating point hex isn't converted because I can't find a python method to do that :/
hmm i see... very useful program i say ;D


Title: Re: ForOhFor's Python Nest
Post by: ItalianStallion on September 27, 2011, 03:49:02 PM
Man this thread is so full of win, and so interesting. After lunch, I will read every [censored]ing line.

Collisions to shadow system:
Adding the shadow system to a stage is time-consuming and annoying. I'm making a program to streamline the process, by making the shadow system follow collisions.

*Gives you all my weed*


Title: Re: ForOhFor's Python Nest
Post by: SmashClash on September 27, 2011, 03:53:58 PM
I want your program! ;D


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 27, 2011, 04:13:02 PM
Mewtwo2000 is helping me out. I just need to figure out how to edit verticies manually in hex.

Then I can make my program do it XD

The current version is outputting some sort of triangle bull[censored].


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on September 27, 2011, 04:18:29 PM
It will open the collision data, and read all of the points and planes. It takes every plane that is the floor type, and outputs a flat shadow model positioned correctly for that plane.

Anyway, my output for the function which parses the collision data:
left point x coord (in floating point hex): c2a48244
left point y coord (in floating point hex): 4125cff3
right point x coord (in floating point hex): c26ef172
right point y coord (in floating point hex): 4125cff6
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): c26ef172
left point y coord (in floating point hex): 4125cff6
right point x coord (in floating point hex): 425c89f2
right point y coord (in floating point hex): 4125cff4
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): 425c89f2
left point y coord (in floating point hex): 4125cff4
right point x coord (in floating point hex): 42a4c3fa
right point y coord (in floating point hex): 4125cff0
collision type: floor
-------------------------------------------
left point x coord (in floating point hex): 42a4c3fa
left point y coord (in floating point hex): 4125cff0
right point x coord (in floating point hex): 42a4c3f9
right point y coord (in floating point hex): c122e273
collision type: right wall
-------------------------------------------
left point x coord (in floating point hex): 42a4c3f9
left point y coord (in floating point hex): c122e273
right point x coord (in floating point hex): c2a48244
right point y coord (in floating point hex): c122e270
collision type: roof
-------------------------------------------
left point x coord (in floating point hex): c2a48244
left point y coord (in floating point hex): c122e270
right point x coord (in floating point hex): c2a48244
right point y coord (in floating point hex): 4125cff3
collision type: left wall
-------------------------------------------
The floating point hex isn't converted because I can't find a python method to do that :/
hey 404... use the struct module ;)

import _struct as St #_struct is 1 step faster than struct
float32 = chr(0x3F)+chr(0x80)+chr(0x00)+chr(0x00)
print St.unpack('>f',float32)[0]

you can even import the needed functions:

from _struct import unpack as U

use unpack when reading from a file,
and use pack when writing to a file. ;)

check out my cmn.py module for more ;)
(my module for my converter)


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 27, 2011, 04:59:15 PM
hey 404... use the struct module ;)

import _struct as St #_struct is 1 step faster than struct
float32 = chr(0x3F)+chr(0x80)+chr(0x00)+chr(0x00)
print St.unpack('>f',float32)[0]

you can even import the needed functions:

from _struct import unpack as U

use unpack when reading from a file,
and use pack when writing to a file. ;)

check out my cmn.py module for more ;)
(my module for my converter)
Actually, I have already ;D
I found a function online :D


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on September 27, 2011, 05:24:29 PM
Actually, I have already ;D
I found a function online :D
IMO you should prbly use my code as it's worked alot better than using int(v,16) based codes
(don't give me credit as anyone can write it) :)

I would end up getting invalad conversions or a value='' result when it should be value='....'

so yea...
only use int(v,16) code for small things.
(16 variables to set is a large thing)


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 27, 2011, 07:50:48 PM
I'm using int(x,16) only for 2 small things (the number of points, and the number of plains)

also, I've gotten Mewtwo's MShadow tool to say the points are in the correct places... but there are many differences, and they crash BrBx.


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on September 28, 2011, 03:53:33 AM
I'm using int(x,16) only for 2 small things (the number of points, and the number of plains)

also, I've gotten Mewtwo's MShadow tool to say the points are in the correct places... but there are many differences, and they crash BrBx.
I'm up early as getting back to sleep seems to be quite a hastle D:

anyways...
those are ok I guess...

oh yea...
the error was with the bone translations on my old melee code.

as soon as I switched to my ru32() function, it worked near perfect :)
(you saw the best result I got)


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on September 28, 2011, 12:28:11 PM
BUMP!
hey 404...
how good are you at understanding Python classes??

I need to understand them as I'm creating widgets for the plugin settings.
(reference the widgets and define the logic in your plugin)

the actual result will display on the viewer
(another reason I need to know classes)


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 28, 2011, 01:22:07 PM
You can think of them like a list, sort of. They contain variables unique to one instance of the class, and have their own methods associated with each class type. You start with a Class <Name>: statement, then use def __init__(self,<other arguments>) to set any local variables contained within the class. you then use def <method name>(self,<other arguments>): to make a new method, and you use self.<var name> to reference the variables in the classes.

That's about all I know :/


Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on September 28, 2011, 03:29:33 PM
You can think of them like a list, sort of. They contain variables unique to one instance of the class, and have their own methods associated with each class type. You start with a Class <Name>: statement, then use def __init__(self,<other arguments>) to set any local variables contained within the class. you then use def <method name>(self,<other arguments>): to make a new method, and you use self.<var name> to reference the variables in the classes.

That's about all I know :/
you know...
you've actually explained that part better than any other documentation I have :D

so basically:

class foo():

    def __init__(self,name,blah):
        #not sure what to define exactly
        pass

    def init mthd(blah,BLAH):
        #don't have much of anything to define... heh
        self.blah = blah

I need to learn a little bit about connections and everything you can do with a class...

yeh... I'm an 0.0 NOOB with classes... :P


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 28, 2011, 07:01:16 PM
No prob. And you've about got it right. You need self at the start of any method definitions.

Anyway, I'm so close to having that shadow tool done. I'm getting the right shape, but writing the points in the wrong order.



Title: Re: ForOhFor's Python Nest
Post by: DarkPikachu on September 28, 2011, 07:18:16 PM
No prob. And you've about got it right. You need self at the start of any method definitions.

Anyway, I'm so close to having that shadow tool done. I'm getting the right shape, but writing the points in the wrong order.


KK thanx. :)

hey...
you know what'd be a good idea for a program?

a shadow model generator for imports or vertex edits :)

all you'd need is polygon reduction with preset materials to render a blank model that casts a shadow.
(it's better if you build a material from scratch) ;)


Title: Re: ForOhFor's Python Nest
Post by: ForOhFor Error on September 28, 2011, 08:06:30 PM
I don't know how do do that XD

Anyway, tried it out in game. The parts it worked for worked remarkably well (aside from a few minor issues caused by the wrong-ordered vertex points and some collision misplacements), but the parts it didn't work for... well, they had models over the spot, but the shadows just didn't appear :/


Title: Re: ForOhFor's Python Nest
Post by: Mewtwo2000 on September 29, 2011, 03:29:46 AM
Then they may be on the wrong side. Have you tried to make the type of the material to be 0? That's not the real solution, of course, but the visual results would be good enough.


Title: Re: ForOhFor's Python Nest [Collisions to shadow system program released! 10/11/11]
Post by: ForOhFor Error on October 11, 2011, 08:45:36 PM
Turns out I misplaced the model. Anyway, here's the program:

PyShade (Collisions to shadow system converter):
Adding the shadow system to a stage is time-consuming and annoying. I've made a program to streamline the process, by outputting shadow models that follow the path of a loaded collision file.

Contains a config file, the options should be straight-forward.

Download:
http://dl.dropbox.com/u/5869687/PyShade.zip


Title: Re: ForOhFor's Python Nest [Collisions to shadow system program released! 10/11/11]
Post by: Mastaklo on June 24, 2012, 09:52:15 AM
how do i use the collision to shadow programm
i cant figure it out


Title: Re: ForOhFor's Python Nest [Collisions to shadow system program released! 10/11/11]
Post by: ForOhFor Error on June 24, 2012, 12:28:10 PM
Just run the .py file, then select the raw .coll file, exported from the stage's .pac file.

A folder will be created in the out folder that contains a bunch of models and a texture, import those into the stage.

Nothing's simpler.


Title: Re: ForOhFor's Python Nest [Collisions to shadow system program released! 10/11/11]
Post by: Naruto200Man on September 12, 2012, 01:13:29 PM
Hmm...do you think you could fix a program up that fixes errors from 3DS Max imports?

Like say I just wanted to change marths sword and he imports back into BB fine, but the eye materials are messed up?

A program that rearanges/fixes polygons and materials so they were like they were when you exported the file would be useful :3

Otherwise do you think you could help me fix Ike's eyes on my hacks, I've tried every method with every version of BB that I have. I might try with a much older bb but I can't find a download for it. the first version of BB that can import .DAE's from max would be nice.


Title: Re: ForOhFor's Python Nest [Collisions to shadow system program released! 10/11/11]
Post by: ForOhFor Error on September 12, 2012, 04:30:43 PM
Nope.
And stop spamming threads for your problem. There's a help area for a reason >.>