2 from struct
import unpack
6 return s
[p
:p
+s
[p
:].find ("\x00")]
11 minmax
= [["none", "none", -1e9
, 1e9
],
12 ["none", "none", -1e9
, 1e9
],
13 ["none", "none", -1e9
, 1e9
],
14 ["none", "none", -1e9
, 1e9
],
15 ["none", "none", -1e9
, 1e9
],
16 ["none", "none", -1e9
, 1e9
],
17 ["none", "none", -1e9
, 1e9
],
18 ["none", "none", -1e9
, 1e9
],
19 ["none", "none", -1e9
, 1e9
]]
23 for (nmax
, nmin
, vmax
, vmin
) in minmax
:
24 print "[%d] min % f %-15s" % (j
, vmin
, nmin
),
25 print "max % f %s" % (vmax
, nmax
)
29 return math
.sqrt (reduce (lambda a
,b
:b
*b
+a
, F
,0))
33 ## return math.sqrt (x*x+y*y+z*z)
36 def rt (self
, pos
, t
):
37 buf
= self
.data
[pos
:pos
+64]
38 D1
= unpack ("<3I", buf
[0:12])
39 F1
= unpack ("<9f", buf
[12:48])
41 H1
= unpack ("<6H", buf
[48:60])
43 H1
= unpack ("<3i", buf
[48:60])
44 F2
= unpack ("<f", buf
[60:64])
45 return (D1
, F1
, H1
, F2
)
47 def rt1 (self
, data
, tup
):
48 t1
= self
.rt (tup
[0], False)
50 name
= cstr (self
.data
[self
.strtab1
:], D
[0])
52 if F
[j
] > minmax
[j
][2]:
55 if F
[j
] < minmax
[j
][3]:
62 pos
= self
.off2
+ n
*64
63 self
.t2
.append (self
.rt (pos
, True))
65 def __init__ (self
, file, xff
):
66 rodata
= xff
.sections
[1]
68 self
.roff
= rodata
[1][7]
70 data
= file.read ()#rodata[1][2])
73 print "hdr at %08x" % (xff
.off_sign
+ self
.roff
)
74 hdr
= data
[xff
.off_sign
:]
76 D1
= unpack ("<4I", hdr
[:16])
77 D2
= unpack ("<3I", hdr
[32:44])
90 print "%d" % len (data
)
91 for i
in range (self
.count1
+ 3):
92 tup
= unpack ("<2I", hdr
[pos
:pos
+8])
93 self
.data1
.append (tup
)
96 self
.Unk1
= unpack ("<2I4fI", subs (data
, self
.data1
[self
.count1
][0], 7*4))
97 self
.Unk2
= unpack ("<I", subs (data
, self
.data1
[self
.count1
+ 1][0], 4))[0]
98 self
.Unk3
= unpack ("<I", subs (data
, self
.data1
[self
.count1
+ 2][0], 4))[0]
101 for i
in range (self
.count1
):
102 self
.rt1 (data
, self
.data1
[i
])
105 for i
in range (self
.count2
):
109 for i
in range (self
.count1
):
110 tup
= unpack ("<II", hdr
[pos
:pos
+8])
112 raise "Whoopsie daisy", hex (pos
+ self
.roff
)
113 name
= cstr (data
, tup
[0] + self
.strtab1
)
114 self
.names
.append (name
)
117 def prt (self
, t
, taboff
, defval
):
122 print "[%2d] %s at %08x" % (i
,
123 cstr (self
.data
[taboff
:], D1
[0]),
124 self
.data1
[i
][0] + self
.roff
)
127 print "!D1[1] %08x (%d)" % (D1
[1], D1
[1])
129 print "!D1[2] %08x (%d)" % (D1
[2], D1
[2])
131 print " V0 (% f, % f, % f)" % (F1
[0], F1
[1], F1
[2])
132 print " V1 (% f, % f, % f)" % (F1
[3], F1
[4], F1
[5])
133 print " V2 (% f, % f, % f)" % (F1
[6], F1
[7], F1
[8])
136 # l57 = magn (F1[5:8])
137 # l68 = magn (F1[6:])
139 print " %f %f" % (l13
, l58
)
143 print " H1[%d] %04x (%d)" % (j
, H1
[j
], H1
[j
])
146 print " H1[%d] % d" % (j
, H1
[j
])
149 print "!F2 % f" % F2
[0]
154 print "one %d" % self
.one
156 print "count1 %d" % self
.count1
157 print "off1 %08x" % (self
.off1
+ self
.roff
)
158 print "strtab1 %08x" % (self
.strtab1
+ self
.roff
)
160 print "count2 %d" % self
.count2
161 print "off2 %08x" % (self
.off2
+ self
.roff
)
162 print "strtab2 %08x" % (self
.strtab2
+ self
.roff
)
164 print "Unk1[0] %08x(%08x) %d" % (self
.Unk1
[0],
165 self
.Unk1
[0] + self
.roff
,
167 print " [1] %08x %d" % (self
.Unk1
[1], self
.Unk1
[1])
169 print " [%d] % f" % (j
+2, self
.Unk1
[j
+2])
170 print " [6] %08x(%08x) %d" % (self
.Unk1
[6],
171 self
.Unk1
[6] + self
.roff
,
178 for elem1
in self
.data1
:
179 off
= elem1
[0] + self
.roff
180 if i
< len (self
.names
):
184 print "[%2d] %-15s %08x(%08x), %08x(%d)" % (i
, name
,
185 elem1
[0], off
, elem1
[1], elem1
[1])
188 self
.prt (self
.t1
, self
.strtab1
, 0xffffffff)
189 self
.prt (self
.t2
, self
.strtab2
, 0x00000000)
192 f
= open (sys
.argv
[1], "rb")