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
No matter what I do, It keeps giving me errors on the 'print' command.
And about your UV, your best bet would be to manually extract a texture for Pichu with Dolphin, and UV map it to the model yourself. Then you can check through your extracted UV for matches.
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)).__str__()
def f():
f = face(dat.read(2))
nor = normal(dat.read(2))
uv = UV(dat.read(2))
if (int(f, 10) >= 0):
return f+"/"+uv+"/"+nor
g = 0
t0 = dat.read(32)#header
a = 0
while (a == 0):#verts
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
while (a == 1):
s = dat.read(1).encode('hex')
if (s =='ff'):
dat.seek(-1,1)
a = 2
while (a == 2):#UV's
vt = "vt "+vert(dat.read(2))+" "+vert(dat.read(2))
if (vt == 'vt 0.0 0.0'):
a = 3
obj.write("\n")
while (a == 3):#faces
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 = 4
s = dat.seek(-2,1)
pos = dat.tell()
print pos.__str__()+": "+h
while (a == 4):
pos = dat.tell()
h = 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'):
index = HexToDec(dat.read(2))
if (h == 'B8'): #point
while (index > 0):
f0 = f()
index = index - 1
print "f "+f0
obj.write("f "+f0+"\n")
elif (h == 'A8'): #line
while (index > 1):
f0 = f()
f1 = f()
index = index - 2
print "f "+f0+' '+f1
obj.write("f "+f0+' '+f1+"\n")
elif (h == 'B0'): #line strip
while (index > 1):
f0 = f()
f1 = f()
index = index - 1
if (index > 1):
seek = dat.seek(-6,1)
if (f0 != f1):
print "f "+f0+' '+f1
obj.write("f "+f0+' '+f1+"\n")
elif (h == '90'): #triangle
while (index > 2):
f0 = f()
f1 = f()
f2 = f()
index = index - 3
print "f "+f0+' '+f1+' '+f2
obj.write("f "+f0+' '+f1+' '+f2+"\n")
elif (h == '98'): #triangle strip
flip = 1
while (index > 2):
f0 = f()
f1 = f()
f2 = f()
index = index - 1
if (index > 2):
seek = dat.seek(-12,1)
if (f0 != f1 and f1 != f2 and f2 != f0):
if (flip):
print "f "+f0+' '+f2+' '+f1
obj.write("f "+f0+' '+f2+' '+f1+"\n")
else:
print "f "+f0+' '+f1+' '+f2
obj.write("f "+f0+' '+f1+' '+f2+"\n")
flip = 1 - flip
elif (h == 'A0'): #triangle fan
f0 = f()
index = index - 1
while (index > 1):
f1 = f()
f2 = f()
index = index - 1
if (index > 1):
seek = dat.seek(-6,1)
if (f0 != f1 and f1 != f2 and f2 != f0):
print "f "+f0+' '+f1+' '+f2
obj.write("f "+f0+' '+f1+' '+f2+"\n")
elif (h == '80'): #quad
while (index > 3):
f0 = f()
f1 = f()
f2 = f()
f3 = f()
index = index - 4
print "f "+f0+' '+f1+' '+f2+' '+f3
obj.write("f "+f0+' '+f1+' '+f2++' '+f3+"\n")
else:
a = 4
else:
# backtrack over invalid primitive type bytes
a = 3
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 vt
obj.write(vt+"\n")
else:
print v
obj.write(v+"\n")
"Invalid syntax" and it highlights 'print'.
I'm using Python Shell to compile it. Sorry I'm such a bother, but I really haven't the faintest of clues on how Python works.
The data you listed in hex as color information (What file is that from by the way?), if i am looking at it correctly, is actually a set of file offsets to various data within the file as well as some of the unknown flag data i have been mentioning that i am working on deciphering.