What's new

Melee Arcive Viewer (MAV) in development project.

Myuutsuu

forever.
Wow, you all're making some excellent progress... in the span of a few pages, no less! It's always exciting to see the news here; Keep it up! :)
 
OP
Tcll

Tcll

Complexity == Fun >:3
what's the math required to do a T-fan??

once I get that, I should have no prob getting the rest of the stuff...
 
OP
Tcll

Tcll

Complexity == Fun >:3
I finally have a progress image:



yea... it's not pretty...
but it's good for a code test.
 
Last edited:

Milun

New member
I'm sorry...

I guess I should have been a little more clear on how the DNA strip sequence works...
it starts out with a selection of 3 face offsets
Code:
|06 46|
|06 47|
|06 48|
 06 3A
 06 48 
 06 3B
 06 48
 06 3C
then checks to make sure the offsets are valad (no duplicate data)
if the offset is valad, the face is logged to a temporary file "faces.txt"
if the offset is invalad, the face is skipped...
then the offset is moved down by 1 (or 4)
Code:
 06 46
|06 47|
|06 48|
|06 3A|
 06 48 
 06 3B
 06 48
 06 3C
then that face is checked...

Hm... that's actually quite different to what I did. Mine would have went like this:

|06 46|
|06 47|
06 46
|06 3A|
06 48
06 3B
06 48
06 3C

The only way to prove if this works would be to check your (awesome discovery btw!) 98 ** ** method and see which is right.

Also, Revel8n, your post was really helpful (and it explained why my Mario converter messed up halfway through).

Now lemme see if I can put this in my program.

Also, nice convert. You got significantly less face gibberish than I did.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
yea...
I guess what you were doing was reading triangle strips "98" which most of the mario model contained.

Pikachu, I found out contained:
triangles
triangle strips
triangle fans
and quads

so... yea...
a little tougher...

if you wan't, I can give you my test code (from the image below)...
(or mabe above for you)
it would probably help you out alot more...

-----------------------------------------------------------------
but yea, that's what I ment by DNA...
(the code is read like DNA)
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
I still can't wrap my mind around what that code I colored magenta does...
 

Milun

New member
Hm... I have a thought (not related to the magenta though, sorry).

Since these models use the triangle conventions, maybe exporting to a .obj isn't the best idea, as it doesn't take advantage of the shortcuts. If we find a model type that uses the whole 'triangle strip, fan etc.' method, then not only would it shorten the export time, but it would also make importing back into Melee a lot easier, because it would automatically shorten the file with triangle strips and whatnot. Whatd'ya think?

Currently I'm trying to recreate my program in a C++. You're probably going to finish your before I do, the only reason I'm doing it is for use in future researching.

Edit: Well, while waiting for Visual Studio to download, I managed to fix my GM code to be near flawless (I use the term loosely).

What I found out is that duplicate values work like this ($ is one face, & is another):

06 46 $
06 47 $
06 46
06 3A $&
06 48 &
06 3B &
06 49

Notice that despite the first face taking up an extra space, face 2 still acts as if no duplicate occurred.

I'm pretty confident in this, but I'll have to test it further to be sure.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
that next format would be collada(.dae)
it works in the XML format.

but this is the format for exporting brawl models
collada is harder to work with however... (in my opinion)

and directx(.x) while the models and bones may be in text, the animation is still in hex.

amything else I can think of would be in hex

-----------------------------------------------------------------
I'm sticking to obj though

I just have to find a way to log all the faces into the obj

then that should do it.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
here is my (Ty) version.
the (Pl) version still exports quite a mess
I did manage to get alot if the faces worked out in the (Pl) version however. :)
anyways..., here's the code for the (Ty) version:
Code:
import struct as S
dat = open("import.dat", 'rb')
obj = open("export.obj", 'w')
#mtl = open("export.mtl", 'w')
def HexToDec(h):
    return float(S.unpack("<h", S.pack("<H", int((h.encode('hex')), 16)))[0])
def vert(v): 
    return (HexToDec(v)* 0.01).__str__()
def face(f):
    return int(HexToDec(f)+1).__str__()+"/"
def UV(uv):
    return int(HexToDec(uv)+1).__str__()+"/"
def normal(nor):
    return +int(HexToDec(nor)/32767).__str__()
t0 = dat.read(32)#header
a = 0
while (a == 0):
    v = "v "+vert(dat.read(2))+" "+vert(dat.read(2))+" "+vert(dat.read(2))
    if (v == 'v 0.0 0.0 0.0'):
        a = 1#main loop
        while (a == 1):
            h = dat.read(1).encode('hex')+dat.read(1).encode('hex')
            if (h == 'B800' or h == 'A800' or h == 'B000' or h == '9000' or h == '9800' or h == 'A000' or h == '8000'):
                a = 2
                s = dat.seek(-1,1)
                index = HexToDec(dat.read(2))#index count
                while (a == 2):
                    if (h == 'B800'): #point
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            index = index - 1
                            print "f "+f0+uv0+"1"
                            obj.write("f "+f0+uv0+"1"+"\n")
                        a = 1
 
                    if (h == 'A800'): #line
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            index = index - 2
                            print "f "+f0+uv0+"1 "+f1+uv1+"1"
                            obj.write("f "+f0+uv0+"1 "+f1+uv1+"1"+"\n")
                        a = 1
                    if (h == 'B000'): #line strip
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            index = index - 2
                            seek = dat.seek(-10,1)
                            index = index + 1
                            print "f "+f0+uv0+"1 "+f1+uv1+"1"
                            obj.write("f "+f0+uv0+"1 "+f1+uv1+"1"+"\n")
                        a = 1
 
                    if (h == '9000'): #triangle
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            f2 = face(dat.read(2))
                            uv2 = UV(dat.read(2))
                            nor2 = dat.read(2)#normal(dat.read(2))
 
                            index = index - 3
                            print "f "+f0+uv0+"1 "+f1+uv1+"1 "+f2+uv2+"1"
                            obj.write("f "+f0+uv0+"1 "+f1+uv1+"1 "+f2+uv2+"1"+"\n")
                        a = 1
                    if (h == '9800'): #triangle strip
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            f2 = face(dat.read(2))
                            uv2 = UV(dat.read(2))
                            nor2 = dat.read(2)#normal(dat.read(2))
                            index = index - 3
                            seek = dat.seek(-15,1)
                            index = index + 2
                            print "f "+f0+uv0+"1 "+f1+uv1+"1 "+f2+uv2+"1"
                            obj.write("f "+f0+uv0+"1 "+f1+uv1+"1 "+f2+uv2+"1"+"\n")
                        a = 1
 
                    if (h == 'A000'): #triangle fan
                        while (index > 0):
                            index = 0
                        a = 1
 
                    if (h == '8000'): #quad
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            f2 = face(dat.read(2))
                            uv2 = UV(dat.read(2))
                            nor2 = dat.read(2)#normal(dat.read(2))
                            f3 = face(dat.read(2))
                            uv3 = UV(dat.read(2))
                            nor3 = dat.read(2)#normal(dat.read(2))
                            index = index - 4
                            print "f "+f0+uv0+"1 "+f1+uv1+"1 "+f2+uv2+"1 "+f3+uv3+"1"
                            obj.write("f "+f0+uv0+"1 "+f1+uv1+"1 "+f2+uv2+"1 "+f3+uv3+"1"+"\n")
                        a = 1
 
 
    else:
        #print v
        obj.write(v+"\n")
I don't have the triangle fan finished yet.
but it mostly works...

test this on your mario model (Ty****.dat)

This code is definatly bound to improve.
I plan on having only 1 version later on instead of 2...
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
this is my idea from yours :)
this is for triangle strips btw...

06 46 0
06 47 $0
06 46 x$0
06 3A &x$
06 48 1&x
06 3B 1&
06 49 1

face 0 would be invalad:

06 46 0
06 47 $0
06 46 x$0

so this face is skipped.

I know it looks a little confusing...
but it started out fron yours

06 46 moved this face value (differant face(face 0))
06 47 $
06 46 $ to here (same data)
06 3A $&
06 48 &
06 3B &
06 49

so you see...
it's using somewhat of the same concept.

tip: when you ignore data, that data is lost
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
hey revel8n...
you wanna talk about board...

look what I'm doing:

click on the image to get a better look

I'm going to find that triangle fan data..., help or no help
hey... sombodies gotta do it...
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
I'm being really dumb...
you know what 1 inportant thing is that I forgot to do...

I forgot to check if the triangle strip was valad... DX< (FACEPALM)
easy fix, but I mean really!... (FACEPALM)(FACEPALM)

I even mentioned it before too... XD
that was rediculus... utterly the most dumb thing I did just now...
 

revel8n

New member
Triangle fans are similar to how triangle strips are handled, except that the first index is always used, along with the previous/last index and the current index.

0 1 2 3 4 5 6
becomes
[0 1 2] [0 2 3] [0 3 4] [0 4 5] [0 5 6]

i am currently looking into various flag values associated with the internal data structures of this format. Once those are deciphered the data should be a bit more manageable as the actual type and intended sizes will be known. A lot of the vertex data in Pl*.dat file will not always appear correctly until the joint data within the file is handled properly (which can also be indexed as well, though i am not sure if this format makes use of it yet, but probably).

i'll post more when i have more meaningful results for the things i am investigating. Slow process but hopefully something will come of it.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
Triangle fans are similar to how triangle strips are handled, except that the first index is always used, along with the previous/last index and the current index.

0 1 2 3 4 5 6
becomes
[0 1 2] [0 2 3] [0 3 4] [0 4 5] [0 5 6]
thax alot :)
that answers my Q.
i am currently looking into various flag values associated with the internal data structures of this format. Once those are deciphered the data should be a bit more manageable as the actual type and intended sizes will be known. A lot of the vertex data in Pl*.dat file will not always appear correctly until the joint data within the file is handled properly (which can also be indexed as well, though i am not sure if this format makes use of it yet, but probably).
that's why I asked about bone data earlier... :p
 
OP
Tcll

Tcll

Complexity == Fun >:3
Finally!... D:>

I got the fans importing.
now to work on a better code.
 
OP
Tcll

Tcll

Complexity == Fun >:3
alright...
here's a small comparison.
who's would you say is better??
(I'd say both(in their own way))

here's mine:


and here's jahra!n's:


and if so...
could anyone tellme what this bug is with the faces..., or where it is (if I supply the code)??

I just can't seem to figure it out... :(
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
scratch that...
I just made a few minor adjustments to the code and got these:

test sample 1:


test sample 2:


still needs a little more work though...
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
hey revel8n...
you think you can help??
I know your not a py programmer but you did quite well last time.

I can't get it to import any better than below...
or maybe above for you...

anyways, here's the code:
Code:
import struct as S
dat = open("import.dat", 'rb')
obj = open("export.obj", 'w')
#mtl = open("export.mtl", 'w')
def HexToDec(h):
    return float(S.unpack("<h", S.pack("<H", int((h.encode('hex')), 16)))[0])
def vert(v): 
    return (HexToDec(v)* 0.01).__str__()
def face(f):
    return int(HexToDec(f)+1).__str__()+"/"
def UV(uv):
    return int(HexToDec(uv)+1).__str__()+"/"
def normal(nor):
    return int(HexToDec(nor)/32767).__str__()
t0 = dat.read(32)#header
a = 0
while (a == 0):
    v = "v "+vert(dat.read(2))+" "+vert(dat.read(2))+" "+vert(dat.read(2))
    if (v == 'v 0.0 0.0 0.0'):
        a = 1#main loop
        obj.write("\n")
        while (a == 1):
            h = dat.read(1).encode('hex')+dat.read(1).encode('hex')
            if (h == 'B800' or h == 'A800' or h == 'B000' or h == '9000' or h == '9800' or h == 'A000' or h == '8000'):
                a = 2
                s = dat.seek(-1,1)
                index = HexToDec(dat.read(2))#index count
                while (a == 2):
                    if (h == 'B800'): #point
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            
                            index = index - 1
                            print "f "+f0+uv0+"1"
                            obj.write("f "+f0+uv0+"1"+"\n")
                                            
                    if (h == 'A800'): #line
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            
                            index = index - 2
                            print "f "+f0+uv0+"1"+' '+f1+uv1+"1"
                            obj.write("f "+f0+uv0+"1"+' '+f1+uv1+"1"+"\n")
                        
                    if (h == 'B000'): #line strip
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            index = index - 1
                            seek = dat.seek(-6,1)
                            if (f0 != f1 or f1 != '00'):
                                print "f "+f0+uv0+"1"+' '+f1+uv1+"1"
                                obj.write("f "+f0+uv0+"1"+' '+f1+uv1+"1"+"\n")
                        
                            
                    if (h == '9000'): #triangle
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            f2 = face(dat.read(2))
                            uv2 = UV(dat.read(2))
                            nor2 = dat.read(2)#normal(dat.read(2))
                        
                            index = index - 3
                            print "f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"
                            obj.write("f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"+"\n")
                        
                    if (h == '9800'): #triangle strip
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            f2 = face(dat.read(2))
                            uv2 = UV(dat.read(2))
                            nor2 = dat.read(2)#normal(dat.read(2))
                            index = index - 1
                            seek = dat.seek(-12,1)
                            if (f0 != f1 and f1 != f2 and f2 != f0 or f2 != '00'):
                                print "f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"
                                obj.write("f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"+"\n")
                        
                        
                    if (h == 'A000'): #triangle fan
                        f0 = face(dat.read(2))
                        uv0 = UV(dat.read(2))
                        nor0 = dat.read(2)#normal(dat.read(2))
                        
                        while (index > 0):
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            f2 = face(dat.read(2))
                            uv2 = UV(dat.read(2))
                            nor2 = dat.read(2)#normal(dat.read(2))
                            index = index - 1
                            seek = dat.seek(-6,1)
                            
                            if (f0 != f1 and f1 != f2 and f2 != f0 or f2 != '00'):
                                print "f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"
                                obj.write("f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"+"\n")
                        
                    if (h == '8000'): #quad
                        while (index > 0):
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            f1 = face(dat.read(2))
                            uv1 = UV(dat.read(2))
                            nor1 = dat.read(2)#normal(dat.read(2))
                            f2 = face(dat.read(2))
                            uv2 = UV(dat.read(2))
                            nor2 = dat.read(2)#normal(dat.read(2))
                            f3 = face(dat.read(2))
                            uv3 = UV(dat.read(2))
                            nor3 = dat.read(2)#normal(dat.read(2))
                            index = index - 4
                            print "f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"+' '+f3+uv3+"1"
                            obj.write("f "+f0+uv0+"1"+' '+f1+uv1+"1"+' '+f2+uv2+"1"+' '+f3+uv3+"1"+"\n")
                    a = 1
                    
        
    else:
        #print v
        obj.write(v+"\n")

just see what you can come up with... =]
if anything at all.
 

revel8n

New member
Now i remember why i disliked python. Determining scope based on indentation is a pain in the ass.

Try it out and let me know your results. Should work for most files that conform to the basis that they contain 16-bit indices for vertex, normal, and uv. More or less index values, or index values that are not 16-bit will not work correctly.

Unfortunately this brute-forcing will not work in cases where there are more than 256 indices in the initial group, but that can be overcome by changing the initial check that is currently commented out and relevant backtrack offset. Although there are other cases were the current assumptions are validate as check for '9800' and the like explicitly has the potential to return too many false positives.

Still need add end of file detection so that the script will exit cleanly.

Let me know if you have any questions on the things i changed. Hopefully i can find the last bits of data that will alleviate the need for this type of scanning.

Hope it helps.

Code:
import struct as S
dat = open("import.dat", 'rb')
obj = open("export.obj", 'w')
#mtl = open("export.mtl", 'w')
def HexToDec(h):
    return float(S.unpack("<h", S.pack("<H", int((h.encode('hex')), 16)))[0])
def vert(v): 
    return (HexToDec(v)* 0.01).__str__()
def face(f):
    return int(HexToDec(f)+1).__str__()
def UV(uv):
    return int(HexToDec(uv)+1).__str__()
def normal(nor):
    return int(HexToDec(nor)/32767).__str__()
t0 = dat.read(32)#header
a = 0
while (a == 0):
    v = "v "+vert(dat.read(2))+" "+vert(dat.read(2))+" "+vert(dat.read(2))
    if (v == 'v 0.0 0.0 0.0'):
        a = 1#main loop
        obj.write("\n")
        while (a == 1):
            # attempt to ensure processing starts at the beginning of a data section
            #h = dat.read(1).encode('hex')+dat.read(1).encode('hex')+dat.read(1).encode('hex')
            #if (h == '0000B8' or h == '0000A8' or h == '0000B0' or h == '000090' or h == '000098' or h == '0000A0' or h == '000080'):  #this may also work and find even more matches, need to update backtrack offset if used
            h = dat.read(1).encode('hex')+dat.read(1).encode('hex')+dat.read(1).encode('hex')+dat.read(1).encode('hex')
            if (h == '0000B800' or h == '0000A800' or h == '0000B000' or h == '00009000' or h == '00009800' or h == '0000A000' or h == '00008000'):
                a = 2
                s = dat.seek(-2,1)
                pos = dat.tell()
                print pos.__str__()+": "+h
                while (a == 2):
                    pos = dat.tell()
                    h = dat.read(1).encode('hex') #+dat.read(1).encode('hex')
                    print pos.__str__()+": "+h
                    if (h == 'B8' or h == 'A8' or h == 'B0' or h == '90' or h == '98' or h == 'A0' or h == '80'):
                        #s = dat.seek(-1,1)
                        index = HexToDec(dat.read(2))#index count
                        if (h == 'B8'): #point
                            while (index > 0):
                                f0 = face(dat.read(2))
                                uv0 = UV(dat.read(2))
                                nor0 = dat.read(2)#normal(dat.read(2))
                                
                                index = index - 1
                                print "f "+f0+"/"+uv0+"/"+"1"
                                obj.write("f "+f0+"/"+uv0+"/"+"1"+"\n")
                                                
                        elif (h == 'A8'): #line
                            while (index > 1):
                                f0 = face(dat.read(2))
                                uv0 = UV(dat.read(2))
                                nor0 = dat.read(2)#normal(dat.read(2))
                                
                                f1 = face(dat.read(2))
                                uv1 = UV(dat.read(2))
                                nor1 = dat.read(2)#normal(dat.read(2))
                                
                                index = index - 2
                                print "f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"
                                obj.write("f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+"\n")
                            
                        elif (h == 'B0'): #line strip
                            while (index > 1):
                                f0 = face(dat.read(2))
                                uv0 = UV(dat.read(2))
                                nor0 = dat.read(2)#normal(dat.read(2))
                                f1 = face(dat.read(2))
                                uv1 = UV(dat.read(2))
                                nor1 = dat.read(2)#normal(dat.read(2))
                                index = index - 1
                                if (index > 1):
                                    seek = dat.seek(-6,1)
                                if (f0 != f1):
                                    print "f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"
                                    obj.write("f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+"\n")
                            
                                
                        elif (h == '90'): #triangle
                            while (index > 2):
                                f0 = face(dat.read(2))
                                uv0 = UV(dat.read(2))
                                nor0 = dat.read(2)#normal(dat.read(2))
                                f1 = face(dat.read(2))
                                uv1 = UV(dat.read(2))
                                nor1 = dat.read(2)#normal(dat.read(2))
                                f2 = face(dat.read(2))
                                uv2 = UV(dat.read(2))
                                nor2 = dat.read(2)#normal(dat.read(2))
                            
                                index = index - 3
                                if (int(f0, 10) >= 0 and int(f1, 10) >= 0 and int(f2, 10) >= 0):
                                  print "f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"
                                  obj.write("f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"+"\n")
                            
                        elif (h == '98'): #triangle strip
                            flip = 1
                            while (index > 2):
                                f0 = face(dat.read(2))
                                uv0 = UV(dat.read(2))
                                nor0 = dat.read(2)#normal(dat.read(2))
                                f1 = face(dat.read(2))
                                uv1 = UV(dat.read(2))
                                nor1 = dat.read(2)#normal(dat.read(2))
                                f2 = face(dat.read(2))
                                uv2 = UV(dat.read(2))
                                nor2 = dat.read(2)#normal(dat.read(2))
                                index = index - 1
                                if (index > 2):
                                    seek = dat.seek(-12,1)
                                if (f0 != f1 and f1 != f2 and f2 != f0):
                                  if (int(f0, 10) >= 0 and int(f1, 10) >= 0 and int(f2, 10) >= 0):
                                    if (flip):
                                        print "f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"
                                        obj.write("f "+f0+"/"+uv0+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+"\n")
                                    else:
                                        print "f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"
                                        obj.write("f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"+"\n")
                                flip = 1 - flip
                            
                        elif (h == 'A0'): #triangle fan
                            f0 = face(dat.read(2))
                            uv0 = UV(dat.read(2))
                            nor0 = dat.read(2)#normal(dat.read(2))
                            index = index - 1
                            
                            while (index > 1):
                                f1 = face(dat.read(2))
                                uv1 = UV(dat.read(2))
                                nor1 = dat.read(2)#normal(dat.read(2))
                                f2 = face(dat.read(2))
                                uv2 = UV(dat.read(2))
                                nor2 = dat.read(2)#normal(dat.read(2))
                                index = index - 1
                                if (index > 1):
                                    seek = dat.seek(-6,1)
                                
                                if (f0 != f1 and f1 != f2 and f2 != f0):
                                  if (int(f0, 10) >= 0 and int(f1, 10) >= 0 and int(f2, 10) >= 0):
                                    print "f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"
                                    obj.write("f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"+"\n")
                            
                        elif (h == '80'): #quad
                            while (index > 3):
                                f0 = face(dat.read(2))
                                uv0 = UV(dat.read(2))
                                nor0 = dat.read(2)#normal(dat.read(2))
                                f1 = face(dat.read(2))
                                uv1 = UV(dat.read(2))
                                nor1 = dat.read(2)#normal(dat.read(2))
                                f2 = face(dat.read(2))
                                uv2 = UV(dat.read(2))
                                nor2 = dat.read(2)#normal(dat.read(2))
                                f3 = face(dat.read(2))
                                uv3 = UV(dat.read(2))
                                nor3 = dat.read(2)#normal(dat.read(2))
                                index = index - 4
                                if (int(f0, 10) >= 0 and int(f1, 10) >= 0 and int(f2, 10) >= 0 and int(f3, 10) >= 0):
                                  print "f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"+' '+f3+"/"+uv3+"/"+"1"
                                  obj.write("f "+f0+"/"+uv0+"/"+"1"+' '+f1+"/"+uv1+"/"+"1"+' '+f2+"/"+uv2+"/"+"1"+' '+f3+"/"+uv3+"/"+"1"+"\n")
                        else:
                            a = 1 # should no longer get here, but just in case...
                    else:
                        # backtrack over invalid primitive type bytes
                        a = 1
                        s = dat.seek(-1,1)
            else:        
			     #backtrack over trailing bytes so that
			     #the entire file is scanned a byte at a time
                 s = dat.seek(-3,1)
       
    else:
        #print v
        obj.write(v+"\n")
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
Still need add end of file detection so that the script will exit cleanly.
yea... I'll work on that later...

but thanx :)
and once again...
it worked perfectly :bouncy:


you must feel somewhat impressed of yourself now :p

and no...
I know exactly what you did,
but I could not... for the life of me figure out how to do that...
thanx again.

EDIT:btw...
it doesn't work on all of them...
but it does work better on those ones than before.
 
Last edited:

Top