What's new

Melee Arcive Viewer (MAV) in development project.

revel8n

New member
unsigned values do not allow for negative numbers, where as signed values do. so an unsigned 16-bit value would range from +0..+65535, where as a signed 16-bit value would range from -32768...+32767. "Technically" negative numbers would represent the upper half of the unsigned range if converted directly, which is why if you treat a signed number as unsigned you appear to get a very large value. You could visualize the range value wise as being +0...+65535 for unsigned and signed as +0...+32767,-32768...-1 (i.e. 0x7FFF == +32767 and 0x8000 == -32768, 0xFFFF == -1, and so on.)

Don't know how python handles this. but after a quick search it appears pythons conversion types are already signed, but i don't know what your conversion code looks like.

in c/c++ it would just be the difference between 'signed short' and 'unsigned short'.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
thanx :)
that helps alot.

here's my code so far
(it only works for verts)

use this in idle and copy the data from the interpreter.
Be sure to get rid of the spaces in the txt file
instead of F5 50
it should be F550
after that...
just wait for the error at the end of the conversion.
the error means it's finished.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
I think I know why the values arn't exactly perfect
and I can't believe I didn't think of ths before (FACEPALM)

what we are dealing with is archive data.
so we are seeing everything in its compressed value.

so first off... we would need a decompressor and then a convertor
I have the convertor... but I don't have the decompressor...
that's why the values are off.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
I just imported PlPkNr and well... it imported with exactly the same layout as FitPikachu00

so that must mean I'm getting close.

I guess the IPO's affected the verts when it was compiled

anyone got any ideas on how armature(bone) data looks??
 

revel8n

New member
could you give this a try this for me. may need to be fixed. just curious what you get as output. i am by no means a python programmer. could you send me one of your text files to test with?

Code:
import struct

#offset = open("import.dat", 'rb') #my method
offset = open("import.txt", 'r')
outfile = open("export.obj", 'w')
def hex2dec(s):
    return int(s, 16)

a = 0
while (a == 0):
 of1 = offset.read(4)
 of2 = offset.read(4)
 of3 = offset.read(4)

 tmp1 = hex2dec(of1)
 tmp2 = hex2dec(of2)
 tmp3 = hex2dec(of3)

 of1 = struct.pack("<HHH", tmp1, tmp2, tmp3)
 of1 = struct.unpack("<hhh", of1)
 tmp1 = float(of1[0]) * 0.01
 tmp2 = float(of1[1]) * 0.01
 tmp3 = float(of1[2]) * 0.01

 tmp1 = tmp1.__str__()
 tmp2 = tmp2.__str__()
 tmp3 = tmp3.__str__()

 #vert = tmp1+" "+tmp2+" "+tmp3+" "+tmp4+" "+tmp5+" "+tmp6 #hex
 vert = "v "+tmp1+" "+tmp2+" "+tmp3 #obj

 print vert
 outfile.write(vert+"\n")
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
OMG How the freak did you do that!!! <8O

it don't need to be fixed
it imports perfectly.

you've just fixed the freakin grid bug I was dealing with. 8D

anyways...
as for a test file...

all I have right now is Pk to compair it with brawl Pk...
but here you go:
Download

what does "struct" do??
and "\n" does that mean enter??
-----------------------------------------------
now we need to impress Milun. XP XD
 
Last edited:

revel8n

New member
"\n" is for newline - which is similar to what pressing enter would do when typing, yes.

struct was necessary for accessing the pack and unpack functionality for python. i looked these things up on google solely to achieve the results i was looking for. Cannot really tell you too much more about python related functionality as i am a c/c++ programmer. But basically the 'H' used in pack converts things to unsigned short (16-bit) values while the 'h' format specifier used with unpack treats the values as signed short values. Then i just convert the values to float so that i can scale the values down by 100 (* 0.01). Technically the values don't really need scaling, and if things come out smaller than you would like you can just change the scale value i use, but best to keep them consistent if you are going to be converting multiple files.
 
OP
Tcll

Tcll

Complexity == Fun >:3
so my bug was between the signed/unsigned ints...
hmm...

I don't have an idea for faces however... :(
but that would definatly impress Milun XD

btw: I've got the final code right here:
Code:
import struct as S
off = open("import.txt", 'r')
out = open("export.obj", 'w')
a = 0
while (a == 0):
 t1 = off.read(4)
 t2 = off.read(4)
 t3 = off.read(4)
 
 t = S.pack("<HHH", int(t1, 16), int(t2, 16), int(t3, 16))
 t = S.unpack("<hhh", t)
 x = float(t[0]) * 0.01
 y = float(t[1]) * 0.01
 z = float(t[2]) * 0.01
 v = "v "+x.__str__()+" "+y.__str__()+" "+z.__str__()
 print v
 out.write(v+"\n")

do you have any idea on how to work the faces??
 
Last edited:

revel8n

New member
The faces work as i described earlier. The first value in a group of indices is the vertex index, then you may or may not have index values for normals and uv coordinates. The data repeats this pattern for the number of indices specified after the primitive flags. To determine how to build faces you have to look at the primitive type value you get from the primitive flags (triangles means every 3 index groups defines an individual face, and so on). If you are not accustomed to the methods used to render things in real-time graphics may need to look into that for some useful information (both opengl and direct3d documentation have information on interpreting the various primitive types).

Finding the data in the first place can be a little tricky if you are doing it by hand, although it is easy to pick out once you have found the right area in the file. i am looking into some things i have been trying to decipher to see if it holds some of the relevant data i am seeking. i use 010 Editor (www.sweetscape.com) and i may have some things that would make it even easier to see the relevant data through the use of their binary template format. Will have to see what i can dig up.

Also note that because gamecube/wii api design allows for indexing vertices, normals, and uv coordinates separately, it is quite likely you will need to have a prepass that either converts things to triangle lists (duplicating vertices and other values as necessary depending on the support of your intended application or renderer api).

Let me know what other questions you may have, and i will see what information i can provide.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
this 010 Editor is amazing 8D

and I kinda mis-stated myself...
I ment how do I decipher the face data??
I would like to know the math on how to if you know...

im tired of reading through numberous docs that dont tell me exactly what I need to know...
IDK...
maybe it's just my fault...
maybe I do have what I need to know...
but I'm just not looking at it correctly.

but yea I do have 1 Q:
how do I find/decipher the bone data??
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
here is a little something I've been re-doing:
Code:
import struct as S
off = open("import.dat", 'r')
out = open("export.obj", 'w')
t0 = off.read(32)#header
a = 0
while (a == 0):
    h1 = off.read(2).encode('hex')
    h2 = off.read(2).encode('hex')
    h3 = off.read(2).encode('hex')
 
    #this returns the hault error as a value
    #and can be deleted after it is fixed
    if (h1 == ''):
        h1 = '00'
    if (h2 == ''):
        h2 = '00'
    if (h3 == ''):
        h3 = '00'
 
    c = S.pack("<HHH", int(h1, 16), int(h2, 16), int(h3, 16))
    c = S.unpack("<hhh", c)
    x = float(c[0]) * 0.01
    y = float(c[1]) * 0.01
    z = float(c[2]) * 0.01
    v = "v "+x.__str__()+" "+y.__str__()+" "+z.__str__()
    if (v == 'v 0.0 0.0 0.0'):
        a = 1
        out.close()
    else:
        print v
        out.write(v+"\n")

it takes the raw data from the dat file and converts it from there.
instead of taking the hex values from a txt file...

there is a bug however...:(
when you run the program, it will only convert so much before ending the conversion process...

if anyone knows what I'm missing..., please help.
 

revel8n

New member
Models are free to have a vertex at (0,0,0) so that is not a reliable check. Is there a way yo break out of a loop early in python? The check for a null return from the read calls is far more accurate in telling when you have reached the end of the file. So if any of the '' checks pass you are at the end of the file can exit the loop. Probably want to check before even attempting the encode calls at that.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
well... thanx for letting me know that...

but during the conversion process,
there's not enough data converted before it reaches the 0 loop

ther's alot more data converted from the txt file

with his there's only about 1/8th of that data converted.
thus the name "The HAULT Error"
it haults at a certain point somewhere at the beginning of the vertex data

I need some help here... :(
 
Last edited:

Milun

New member
Oh, also, make sure you are treating values as signed when necessary.

To take an example from Milun's page:
(F5 50 becomes 62800) as unsigned is very different when compared to
(F5 50 becomes -2736) when treated as a signed value.

Sorry for my late answer (time zones), but my particular '-256...' equation was for the occasion on which you would convert F5 50 separately, so the final value would be:

F5.50 or 245.(1/256)*80 when converted.

I don't know if you've already solved this, so disregard my post if that's the case, also sorry that I can't be much help in the programming. The best I could do to help is to send you my god awful Game Maker (don't laugh) file that converts the hex to dec (btw I fixed the bad placement of the points in this version). So if you want the file, just say and I'll upload it.

Oh, and with your check with the 0's, my advice would be to look for an occurrence of 00 00 00 00 00 00 00 00 00 00 00 00 (2 vert's in 0,0,0). I've never encountered a time where there were two points in that location, so it could work.

Oh, and I've noticed a little something when hacking actual Pl.dat's: The edges are separated constantly.

For instance, if Jigglypuff has 1300 vertices, there will be a section of hex for faces, but it will only connect vertices 1 - 54, then another section of codes (seperated from the previous one with a heap of 00's) that goes from vertice 1 - 48. My best guess, is that where the model vertice hex is stored, vertice's 1 - 54 are one object, then vertices 55 - 102 (54+48) are another. Don't qoute me on this, I have no proof, and the figures I used aren't really in Jigg's hex.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
that's still not what I ment by the 0 loop...

here's what I ment:
Code:
v -1.92 31.36 -1.28
v 62.08 120.96 -3.84
v 81.28 41.6 -1.28
v -66.56 27.2 -1.28
v 42.56 58.88 2.56
v -5.12 57.28 1.28
v -34.24 21.44 0.0
v -4.8 1.28 -0.96
v -0.64 -1.6 0.96
v 42.24 33.6 -18.88
v -0.96 22.72 0.32
v 75.52 28.16 -18.24
v -71.04 5.44 42.56
v 0.0 17.92 88.0
v 71.04 5.44 42.56
v -56.0 6.08 -54.4
v -78.4 5.12 -17.6
v 0.0 3.52 -69.76
v 56.0 6.08 -54.4
v 78.4 5.12 -17.6
v 19.2 13.12 11.52
v 17.92 -0.32 17.6
v 14.72 -12.8 8.0
v 13.44 -9.28 -8.0
v 16.0 8.0 -10.88
v 18.56 16.0 -2.24
v 13.12 -1.92 8.96
v 8.0 -0.32 0.64
v 7.36 -5.12 -0.32
v 13.44 8.0 6.72
v 12.8 -8.96 3.52
v 13.76 9.92 -1.28
v 12.48 -6.72 -5.76
v 12.8 6.4 -4.16
v 12.8 3.52 -8.32
v 6.72 -2.56 2.24
v 11.2 6.08 0.0
v 11.84 -7.04 -8.0
v 6.08 -9.28 1.28
v 11.2 -8.32 -0.64
v -49.6 -32.0 -54.08
v -77.76 -11.2 -5.76
v 16.0 12.8 -17.28
v 20.48 16.96 3.52
v 49.6 -32.0 -54.08
v 0.0 -27.52 -65.6
v -56.96 -33.92 43.84
v -9.6 -39.68 25.92
v 20.48 16.96 -3.52
v 16.0 13.12 16.96
v 9.6 -39.68 25.92
v 0.0 -39.68 74.56
v 0.0 12.48 87.68
v -6.4 16.32 85.44
v 0.0 18.24 84.8
v 0.0 22.4 75.84
v -40.64 5.12 76.16
v -43.84 -23.68 52.8
v -41.28 -2.56 58.88
v -66.56 -14.72 39.04
v -43.2 -21.76 62.72
v -43.84 54.08 -26.88
v -29.44 76.8 -0.96
v -53.44 58.56 17.92
v -30.4 75.2 21.76
v -19.52 73.6 39.36
v -62.4 -20.8 30.72
v -72.64 -16.32 -5.76
v -59.84 7.68 45.12
v -65.28 0.96 28.48
v -46.4 56.32 49.6
v -50.24 17.28 65.28
v -64.64 28.48 3.84
v 6.4 16.32 85.44
v 40.64 5.12 76.16
v 0.0 72.96 43.84
v 0.0 80.0 23.68
v 0.0 0.0 0.0
v 0.0 0.0 0.0
v 0.0 0.0 0.0
v 0.0 0.0 0.0
v 0.0 0.0 0.0
v 0.0 0.0 0.0
v 0.0 0.0 0.0
...
v 0.0 0.0 0.0
v 0.0 0.0 0.0
there's not nearly enough converted data here.
but what is converted works perfectly.

and yes..., this is straight from the dat file.

and the main reason for the 0 loop is well...
the original char is blank..., so I replaced the blank with '00' (0 loop)
so yea you could basically say I made the 0 loop
but it comes after the hault error (when conversion comes to a hault)
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
I've made a little bit of code here that you can play with:
Code:
import struct as S
off = open("import.dat", 'rb') #'r') bugfix :P
out = open("export.obj", 'w')
t0 = off.read(32)#header
 
switch = 1 #flip this to display hex data
 
a = 0
while (a == 0):
    h1 = off.read(2).encode('hex')
    h2 = off.read(2).encode('hex')
    h3 = off.read(2).encode('hex')
 
    h = S.pack("<HHH", int(h1, 16), int(h2, 16), int(h3, 16))
    h = S.unpack("<hhh", h)
    x = float(h[0]) * 0.01
    y = float(h[1]) * 0.01
    z = float(h[2]) * 0.01
    if (switch == 1):
        v = "v "+x.__str__()+" "+y.__str__()+" "+z.__str__()
    else:
        v = h1+" "+h2+" "+h3
 
    """
    if (v == 'v 0.0 0.0 0.0'):
        a = 1
        out.close()
    else:
        print v
        out.write(v+"\n")
    """
 
    print v
    out.write(v+"\n")

this includes a switch which displays between the hex or the converted decimal
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
hey Milun...
IDK for sure...
but I was looking at your page and well...

that hex you found...
(the distrbed group of '00' with the occational row of 'FF')

I'm thinking that might be the V-Group data.
if not..., then my 2nd guess would have to be bone data.
 

revel8n

New member
Oops. that may be my fault, heh. Forgot i changed things to read in text mode when i was messing with the python code. Not sure if this is it but change the open mode from 'r' back to 'rb'. Didn't fully understand what you were talking about earlier, so hopefully this might help. Though i am not even sure if that would make a difference in python. i will try out the code in a little bit. i am making some finding on my end, will have to see where they lead.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
so that's the differance between 'r' and 'rb'...
KK I think I get it

again amature here... :down:
but yea it worked perfectly =]

and it was probably my fault for not pointing you in the right direction earlier...
 
OP
Tcll

Tcll

Complexity == Fun >:3
I wanted to mention something too...

in brawl:
the animation is in a separate file...
FitCharname00.pac = model
FitCharnameMotion.pac = animation

well...
Melee has the same thing.
Pl**Nr.dat = model
IDK what the anamation data is named...
 

Top