mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 06:10:56 +00:00
can now convert v3 models to v6
This commit is contained in:
parent
067405b461
commit
d7a3608943
2 changed files with 69 additions and 2 deletions
|
@ -6,7 +6,7 @@ model = open(sys.argv[1],"rb").read()
|
||||||
m = unpack ("4s l 3f 3f f 3f i i i i i i i", model[:76])
|
m = unpack ("4s l 3f 3f f 3f i i i i i i i", model[:76])
|
||||||
model = model[76:]
|
model = model[76:]
|
||||||
m = m[0:2] + (m[2:5],) + (m[5:8],) + m[8:9] + (m[9:12],) + m[12:20]
|
m = m[0:2] + (m[2:5],) + (m[5:8],) + m[8:9] + (m[9:12],) + m[12:20]
|
||||||
if m[2] == 6:
|
if m[1] == 6:
|
||||||
m = m + unpack ("i f", model[:8])
|
m = m + unpack ("i f", model[:8])
|
||||||
model = model[8:]
|
model = model[8:]
|
||||||
pprint (m)
|
pprint (m)
|
||||||
|
@ -22,6 +22,7 @@ for i in range(m[6]):
|
||||||
else:
|
else:
|
||||||
n = unpack ("l", model[:4])[0]
|
n = unpack ("l", model[:4])[0]
|
||||||
model = model [4:]
|
model = model [4:]
|
||||||
|
print n
|
||||||
k = (n, unpack (`n`+"f", model[:n*4]), [])
|
k = (n, unpack (`n`+"f", model[:n*4]), [])
|
||||||
model = model [n*4:]
|
model = model [n*4:]
|
||||||
for j in range (n):
|
for j in range (n):
|
||||||
|
@ -49,7 +50,7 @@ for i in range (m[11]):
|
||||||
t = unpack ("l", model[:4])[0]
|
t = unpack ("l", model[:4])[0]
|
||||||
model = model[4:]
|
model = model[4:]
|
||||||
if t==0:
|
if t==0:
|
||||||
if m[2] == 6:
|
if m[1] == 6:
|
||||||
f = (t, unpack ("3B B 3B B 16s", model[:24]), [])
|
f = (t, unpack ("3B B 3B B 16s", model[:24]), [])
|
||||||
model = model[24:]
|
model = model[24:]
|
||||||
else:
|
else:
|
||||||
|
|
66
tools/misc/mdlconv.py
Normal file
66
tools/misc/mdlconv.py
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
from struct import *
|
||||||
|
from pprint import *
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
def convert (fname):
|
||||||
|
f = open (fname, "rb")
|
||||||
|
model = f.read ()
|
||||||
|
f.close ()
|
||||||
|
if len (model) < 8 or model[:4] != "IDPO" or unpack ("<I", model[4:8])[0] != 3:
|
||||||
|
print fname, "is not a v3 mdl file";
|
||||||
|
return
|
||||||
|
os.rename (fname, fname + ".bak")
|
||||||
|
f = open (fname, "wb")
|
||||||
|
f.write (model[:4] + pack ("<I", 6) + model[8:76])
|
||||||
|
f.write ('\0' * 8)
|
||||||
|
numskins, skinwidth, skinheight, numverts, numtris, numframes = unpack("<IIIIII", model[48:72])
|
||||||
|
model = model[76:]
|
||||||
|
|
||||||
|
size = skinwidth * skinheight
|
||||||
|
for i in range (numskins):
|
||||||
|
type = unpack ("<I", model[:4])[0]
|
||||||
|
f.write (model[:4])
|
||||||
|
model = model[4:]
|
||||||
|
if not type:
|
||||||
|
f.write (model[:size])
|
||||||
|
model = model [size:]
|
||||||
|
else:
|
||||||
|
num = unpack ("<I", model[:4])[0]
|
||||||
|
f.write (model[:4])
|
||||||
|
model = model[4:]
|
||||||
|
f.write (model[:num * 4])
|
||||||
|
model = model[num * 4:]
|
||||||
|
f.write (model[:size * num])
|
||||||
|
model = model[size * num:]
|
||||||
|
|
||||||
|
for i in range (numverts):
|
||||||
|
s = model[:12]
|
||||||
|
model = model[12:]
|
||||||
|
fl = unpack("<I", s[:4])[0] << 5
|
||||||
|
s = pack("<I", fl) + s[4:]
|
||||||
|
f.write (s)
|
||||||
|
|
||||||
|
|
||||||
|
f.write (model[:numtris * 16])
|
||||||
|
model = model[numtris * 16:]
|
||||||
|
|
||||||
|
for i in range (numframes):
|
||||||
|
type = unpack ("<I", model[:4])[0]
|
||||||
|
f.write (model[:4])
|
||||||
|
model = model[4:]
|
||||||
|
if not type:
|
||||||
|
f.write (model[:8])
|
||||||
|
model = model [8:]
|
||||||
|
f.write ('\0' * 16)
|
||||||
|
f.write (model[:numverts * 4])
|
||||||
|
model = model [numverts * 4:]
|
||||||
|
else:
|
||||||
|
print "don't know frame groups yet"
|
||||||
|
sys.exit (1)
|
||||||
|
|
||||||
|
f.close ()
|
||||||
|
|
||||||
|
for f in sys.argv[1:]:
|
||||||
|
print f
|
||||||
|
convert (f)
|
Loading…
Reference in a new issue