pgtools 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +25 -0
  3. data/bin/bxm_decoder +2 -0
  4. data/bin/bxm_encoder +2 -0
  5. data/bin/clh_convert +2 -0
  6. data/bin/clp_convert +2 -0
  7. data/bin/clw_convert +2 -0
  8. data/bin/dat_creator +2 -0
  9. data/bin/dat_extractor +2 -0
  10. data/bin/dat_ls +2 -0
  11. data/bin/eff_idd_creator +2 -0
  12. data/bin/eff_idd_extractor +2 -0
  13. data/bin/exp_convert_wiiu_pc +2 -0
  14. data/bin/exp_tool +2 -0
  15. data/bin/mot_convert_wiiu_pc +2 -0
  16. data/bin/mot_tool +2 -0
  17. data/bin/pkz_extractor +2 -0
  18. data/bin/scr_creator +2 -0
  19. data/bin/scr_extractor +2 -0
  20. data/bin/wmb_cleanup +2 -0
  21. data/bin/wmb_common_bones +2 -0
  22. data/bin/wmb_convert_pc_switch +2 -0
  23. data/bin/wmb_convert_wiiu_pc +2 -0
  24. data/bin/wmb_export_assimp +2 -0
  25. data/bin/wmb_get_bone_map +2 -0
  26. data/bin/wmb_import_assimp +2 -0
  27. data/bin/wmb_import_nier +2 -0
  28. data/bin/wmb_import_wiiu +2 -0
  29. data/bin/wtb_convert_wiiu_pc +2 -0
  30. data/bin/wtx_creator +2 -0
  31. data/bin/wtx_extractor +2 -0
  32. data/lib/bayonetta/alignment.rb +14 -0
  33. data/lib/bayonetta/bone.rb +55 -0
  34. data/lib/bayonetta/bxm.rb +180 -0
  35. data/lib/bayonetta/clh.rb +159 -0
  36. data/lib/bayonetta/clp.rb +212 -0
  37. data/lib/bayonetta/clw.rb +166 -0
  38. data/lib/bayonetta/dat.rb +261 -0
  39. data/lib/bayonetta/eff.rb +314 -0
  40. data/lib/bayonetta/endianness.rb +53 -0
  41. data/lib/bayonetta/exp.rb +768 -0
  42. data/lib/bayonetta/linalg.rb +416 -0
  43. data/lib/bayonetta/material_database.yaml +2581 -0
  44. data/lib/bayonetta/mot.rb +763 -0
  45. data/lib/bayonetta/pkz.rb +63 -0
  46. data/lib/bayonetta/scr.rb +393 -0
  47. data/lib/bayonetta/tools/bxm_decoder.rb +23 -0
  48. data/lib/bayonetta/tools/bxm_encoder.rb +37 -0
  49. data/lib/bayonetta/tools/clh_convert.rb +60 -0
  50. data/lib/bayonetta/tools/clp_convert.rb +70 -0
  51. data/lib/bayonetta/tools/clw_convert.rb +60 -0
  52. data/lib/bayonetta/tools/dat_creator.rb +57 -0
  53. data/lib/bayonetta/tools/dat_extractor.rb +94 -0
  54. data/lib/bayonetta/tools/dat_ls.rb +106 -0
  55. data/lib/bayonetta/tools/eff_idd_creator.rb +66 -0
  56. data/lib/bayonetta/tools/eff_idd_extractor.rb +73 -0
  57. data/lib/bayonetta/tools/exp_convert_wiiu_pc.rb +33 -0
  58. data/lib/bayonetta/tools/exp_tool.rb +48 -0
  59. data/lib/bayonetta/tools/mot_convert_wiiu_pc.rb +33 -0
  60. data/lib/bayonetta/tools/mot_tool.rb +60 -0
  61. data/lib/bayonetta/tools/pkz_extractor.rb +75 -0
  62. data/lib/bayonetta/tools/scr_creator.rb +63 -0
  63. data/lib/bayonetta/tools/scr_extractor.rb +78 -0
  64. data/lib/bayonetta/tools/wmb_cleanup.rb +250 -0
  65. data/lib/bayonetta/tools/wmb_common_bones.rb +45 -0
  66. data/lib/bayonetta/tools/wmb_convert_pc_switch.rb +35 -0
  67. data/lib/bayonetta/tools/wmb_convert_wiiu_pc.rb +33 -0
  68. data/lib/bayonetta/tools/wmb_export_assimp.rb +479 -0
  69. data/lib/bayonetta/tools/wmb_get_bone_map.rb +50 -0
  70. data/lib/bayonetta/tools/wmb_import_assimp.rb +735 -0
  71. data/lib/bayonetta/tools/wmb_import_geometry_wiiu_pc.rb +472 -0
  72. data/lib/bayonetta/tools/wmb_import_nier.rb +309 -0
  73. data/lib/bayonetta/tools/wtb_convert_wiiu_pc.rb +95 -0
  74. data/lib/bayonetta/tools/wtb_import_textures.rb +103 -0
  75. data/lib/bayonetta/tools/wtx_creator.rb +69 -0
  76. data/lib/bayonetta/tools/wtx_extractor.rb +85 -0
  77. data/lib/bayonetta/vertex_types.yaml +213 -0
  78. data/lib/bayonetta/vertex_types2.yaml +164 -0
  79. data/lib/bayonetta/vertex_types_nier.yaml +145 -0
  80. data/lib/bayonetta/wmb.rb +2443 -0
  81. data/lib/bayonetta/wmb3.rb +759 -0
  82. data/lib/bayonetta/wtb.rb +481 -0
  83. data/lib/bayonetta.rb +60 -0
  84. metadata +254 -0
@@ -0,0 +1,481 @@
1
+ require 'stringio'
2
+ require 'zlib'
3
+
4
+ module Bayonetta
5
+
6
+ class WTBFile
7
+ include Endianness
8
+
9
+ attr_accessor :unknown
10
+ attr_accessor :texture_flags
11
+ attr_accessor :texture_idx
12
+ attr_accessor :texture_infos
13
+ attr_reader :big
14
+ attr_reader :game
15
+ ALIGNMENTS = {
16
+ '.dds' => 0x1000,
17
+ '.gtx' => 0x2000,
18
+ '.bntx' => 0x2000,
19
+ '.xt1' => 0x1000
20
+ }
21
+ ALIGNMENTS.default = 0x20
22
+
23
+
24
+ def initialize(f = nil, big = false, wtp = nil, game: nil, platform: nil)
25
+ @game = nil
26
+ if f
27
+ f.rewind
28
+ @wtp = wtp
29
+ @id = f.read(4)
30
+ case @id
31
+ when "WTB\0".b
32
+ texture_type = ".dds"
33
+ if @wtp
34
+ tex_id = @wtp.read(4)
35
+ if tex_id == "BNTX"
36
+ texture_type = ".bntx"
37
+ end
38
+ end
39
+ @big = false
40
+ when "\0BTW".b
41
+ texture_type = ".gtx"
42
+ @big = true
43
+ else
44
+ "Invalid file type #{@id}!"
45
+ end
46
+ uint = get_uint
47
+ @total_size = f.size
48
+ @unknown = f.read(4).unpack(uint).first
49
+ @num_tex = f.read(4).unpack(uint).first
50
+ @offset_texture_offsets = f.read(4).unpack(uint).first
51
+ @offset_texture_sizes = f.read(4).unpack(uint).first
52
+ @offset_texture_flags = f.read(4).unpack(uint).first
53
+ @offset_texture_idx = f.read(4).unpack(uint).first
54
+ @offset_texture_infos = f.read(4).unpack(uint).first
55
+ if @offset_texture_infos != 0 && @num_tex > 0
56
+ off = f.tell
57
+ f.seek(@offset_texture_infos)
58
+ if f.read(4) == "XT1\0".b
59
+ texture_type = ".xt1"
60
+ end
61
+ f.seek(off)
62
+ end
63
+ if @wtp && @big
64
+ @offset_mipmap_offsets = f.read(4).unpack(uint).first
65
+ if @offset_mipmap_offsets != 0
66
+ f.seek(@offset_mipmap_offsets)
67
+ @mipmap_offsets = f.read(4*@num_tex).unpack("#{uint}*")
68
+ end
69
+ end
70
+
71
+ f.seek(@offset_texture_offsets)
72
+ @texture_offsets = f.read(4*@num_tex).unpack("#{uint}*")
73
+
74
+ if @offset_texture_sizes != 0
75
+ f.seek(@offset_texture_sizes)
76
+ @texture_sizes = f.read(4*@num_tex).unpack("#{uint}*")
77
+ end
78
+
79
+ if @offset_texture_flags != 0
80
+ f.seek(@offset_texture_flags)
81
+ @texture_flags = f.read(4*@num_tex).unpack("#{uint}*")
82
+ end
83
+
84
+ if @offset_texture_idx != 0
85
+ f.seek(@offset_texture_idx)
86
+ @texture_idx = f.read(4*@num_tex).unpack("#{uint}*")
87
+ else
88
+ @texture_idx = []
89
+ end
90
+
91
+ @texture_infos = []
92
+
93
+ if !@wtp && texture_type == ".dds" && @offset_texture_offsets != 0 && @offset_texture_sizes != 0
94
+ @texture_offsets.each_with_index { |off, i|
95
+ if @texture_sizes[i] > 4
96
+ f.seek(off)
97
+ tex_id = f.read(4)
98
+ if tex_id == "BNTX"
99
+ texture_type = ".bntx"
100
+ break
101
+ end
102
+ end
103
+ }
104
+ end
105
+
106
+ if !@wtp && texture_type == ".xt1" # Astral Chain Switch
107
+ @textures = @texture_offsets.each_with_index.collect { |off, i|
108
+ f.seek(@offset_texture_infos + i*0x38)
109
+ tex_header = f.read( 0x38 )
110
+ f.seek(off)
111
+ StringIO::new( tex_header << f.read(@texture_sizes[i]), "rb" )
112
+ }
113
+ elsif @wtp && texture_type == ".xt1" # Astral Chain Switch
114
+ @textures = @texture_offsets.each_with_index.collect { |off, i|
115
+ f.seek(@offset_texture_infos + i*0x38)
116
+ @wtp.seek(off)
117
+ StringIO::new( f.read( 0x38 ) + @wtp.read(@texture_sizes[i]), "rb" )
118
+ }
119
+ @wtp = true
120
+ elsif !@wtp && @offset_texture_offsets != 0 && @offset_texture_sizes != 0
121
+ @textures = @texture_offsets.each_with_index.collect { |off, i|
122
+ f.seek( off )
123
+ StringIO::new( f.read( @texture_sizes[i] ), "rb" )
124
+ }
125
+ elsif @wtp && @big && @offset_texture_offsets != 0 && @offset_texture_sizes != 0 # Bayo 2 WiiU
126
+ @wtp.rewind
127
+ @data_length = []
128
+ @mipmap_length = []
129
+ @textures = @texture_offsets.each_with_index.collect { |off, i|
130
+ of = StringIO::new("", "w+b")
131
+ f.seek(@offset_texture_infos + i*0xc0)
132
+ gx2 = f.read(0x9c)
133
+ num_mipmap = gx2[0x10...0x14].unpack(uint).first
134
+ data_length = gx2[0x20...0x24].unpack(uint).first
135
+ mipmap_length = gx2[0x28...0x2c].unpack(uint).first
136
+ @data_length.push data_length
137
+ @mipmap_length.push mipmap_length
138
+ of.write("\x47\x66\x78\x32\x00\x00\x00\x20\x00\x00\x00\x07\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
139
+ of.write("\x42\x4C\x4B\x7B\x00\x00\x00\x20\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x0B\x00\x00\x00\x9C\x00\x00\x00\x00\x00\x00\x00\x00")
140
+ of.write(gx2)
141
+ of.write("\x42\x4C\x4B\x7B\x00\x00\x00\x20\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x0C")
142
+ of.write(gx2[0x20...0x24])
143
+ of.write("\x00\x00\x00\x00\x00\x00\x00\x00")
144
+ @wtp.seek(off)
145
+ of.write( @wtp.read(data_length) )
146
+ if num_mipmap > 1
147
+ of.write("\x42\x4C\x4B\x7B\x00\x00\x00\x20\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x0D")
148
+ of.write(gx2[0x28...0x2c])
149
+ of.write("\x00\x00\x00\x00\x00\x00\x00\x00")
150
+ @wtp.seek(@mipmap_offsets[i])
151
+ of.write( @wtp.read(mipmap_length) )
152
+ end
153
+ of.write("\x42\x4C\x4B\x7B\x00\x00\x00\x20\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
154
+ of.close_write
155
+ of
156
+ }
157
+ @wtp = true
158
+ elsif @wtp && !@big && @offset_texture_offsets != 0 && @offset_texture_sizes != 0 # Nier PC
159
+ @wtp.rewind
160
+ @textures = @texture_offsets.each_with_index.collect { |off, i|
161
+ of = StringIO::new("", "w+b")
162
+ @wtp.seek(off)
163
+ of.write( @wtp.read(@texture_sizes[i]) )
164
+ of.close_write
165
+ of
166
+ }
167
+ if @offset_texture_infos != 0
168
+ f.seek(@offset_texture_infos)
169
+ @texture_infos = f.read(5*4*@num_tex).unpack("#{uint}*")
170
+ end
171
+ else
172
+ raise "Invalid texture data!"
173
+ end
174
+
175
+ @texture_types = [texture_type]*@num_tex
176
+
177
+ else
178
+ @big = big
179
+ @wtp = wtp
180
+ @id = "WTB\0".b
181
+ @id.reverse! if @big
182
+ @unknown = 0x1
183
+ @num_tex = 0
184
+ @offset_texture_offsets = 0x0
185
+ @offset_texture_sizes = 0x0
186
+ @offset_texture_flags = 0x0
187
+ @offset_texture_idx = 0x0
188
+ @offset_texture_infos = 0x0
189
+ if @wtp && @big
190
+ @offset_mipmap_offsets = 0x0
191
+ @mipmap_offsets = []
192
+ @mipmap_length = []
193
+ @data_length = []
194
+ end
195
+
196
+ @texture_offsets = []
197
+ @texture_sizes = []
198
+ @texture_flags = []
199
+ @texture_idx = []
200
+ @texture_infos = []
201
+
202
+ @textures = []
203
+ @texture_types = []
204
+ end
205
+ end
206
+
207
+ def invalidate_layout
208
+ @offset_texture_offsets = 0x0
209
+ @offset_texture_sizes = 0x0
210
+ @offset_texture_flags = 0x0
211
+ @offset_texture_idx = 0x0
212
+ @offset_texture_infos = 0x0
213
+ if @wtp && @big
214
+ @offset_mipmap_offsets = 0x0
215
+ @mipmap_offsets = []
216
+ end
217
+ @texture_offsets = []
218
+ end
219
+
220
+ def compute_layout
221
+ if @wtp && ( @big || ( @texture_types && @texture_types.size > 0 && @texture_types[0] == ".bntx" ) )
222
+ last_offset = @offset_texture_offsets = 0x40
223
+ else
224
+ last_offset = @offset_texture_offsets = 0x20
225
+ end
226
+ last_offset = @offset_texture_sizes = align(last_offset + 4*@num_tex, 0x20)
227
+ last_offset = @offset_texture_flags = align(last_offset + 4*@num_tex, 0x20)
228
+ if @texture_idx != []
229
+ last_offset = @offset_texture_idx = align(last_offset + 4*@num_tex, 0x20)
230
+ end
231
+ unless @wtp
232
+ last_offset = last_offset + 4*@num_tex
233
+ if @texture_types[0] == ".xt1" #Astral chain wtb
234
+ last_offset = @offset_texture_infos = align(last_offset, 0x20)
235
+ last_offset = align(last_offset + 0x38*@num_tex, 0x10)
236
+ end
237
+ @texture_offsets = @num_tex.times.collect { |i|
238
+ tmp = align(last_offset, ALIGNMENTS[@texture_types[i]])
239
+ last_offset = align(tmp + @texture_sizes[i], ALIGNMENTS[@texture_types[i]])
240
+ tmp
241
+ }
242
+ @total_size = last_offset
243
+ else
244
+ unless @texture_types && @texture_types.size > 0 && @texture_types[0] == ".bntx" #Bayo 2 Switch
245
+ last_offset = @offset_texture_infos = align(last_offset + 4*@num_tex, 0x20)
246
+ if @big
247
+ last_offset = @offset_mipmap_offsets = align(last_offset + 0xc0*@num_tex, 0x20)
248
+ last_offset = align(last_offset + 4*@num_tex, 0x20)
249
+ elsif @texture_types[0] == ".xt1" #Astral chain
250
+ last_offset = align(last_offset + 0x38*@num_tex, 0x10)
251
+ else #Nier
252
+ last_offset = align(last_offset + 5*4*@num_tex, 0x20)
253
+ end
254
+ else
255
+ last_offset = align(last_offset + 4*@num_tex, 0x20)
256
+ end
257
+ @total_size = last_offset
258
+
259
+ offset_wtp = 0x0
260
+ if @big
261
+ @texture_offsets = @num_tex.times.collect { |i|
262
+ tmp = align(offset_wtp, ALIGNMENTS[@texture_types[i]])
263
+ offset_wtp = align(tmp + @data_length[i], ALIGNMENTS[@texture_types[i]])
264
+ tmp
265
+ }
266
+ @mipmap_offsets = @num_tex.times.collect { |i|
267
+ if @mipmap_length[i] != 0
268
+ tmp = align(offset_wtp, ALIGNMENTS[@texture_types[i]])
269
+ offset_wtp = align(tmp + @mipmap_length[i], ALIGNMENTS[@texture_types[i]])
270
+ tmp
271
+ else
272
+ 0
273
+ end
274
+ }
275
+ elsif @texture_types[0] == ".xt1" #Astral chain wta
276
+ @texture_offsets = @num_tex.times.collect { |i|
277
+ tmp = align(offset_wtp, ALIGNMENTS[@texture_types[i]])
278
+ offset_wtp = align(tmp + @texture_sizes[i], ALIGNMENTS[@texture_types[i]])
279
+ tmp
280
+ }
281
+ else #Nier or Bayo 2 Switch
282
+ @texture_offsets = @num_tex.times.collect { |i|
283
+ tmp = align(offset_wtp, ALIGNMENTS[@texture_types[i]])
284
+ offset_wtp = align(tmp + @texture_sizes[i], ALIGNMENTS[@texture_types[i]])
285
+ tmp
286
+ }
287
+ end
288
+ @total_size_wtp = offset_wtp
289
+ end
290
+ end
291
+
292
+ def push(file, flag = 0x0, idx = nil)
293
+ id = file.read(4)
294
+ file.rewind
295
+ case id
296
+ when "XT1\0".b
297
+ @texture_types.push( ".xt1" )
298
+ when "Gfx2".b
299
+ @texture_types.push( ".gtx" )
300
+ when "DDS ".b
301
+ @texture_types.push( ".dds" )
302
+ when "BNTX".b
303
+ @texture_types.push( ".bntx" )
304
+ else
305
+ begin
306
+ warn "Determining type by extension!"
307
+ p = file.path
308
+ case File.extname(p).downcase
309
+ when ".dds"
310
+ @texture_types.push( ".dds" )
311
+ when ".gtx"
312
+ @texture_types.push( ".gtx" )
313
+ when ".bntx"
314
+ @texture_types.push( ".bntx" )
315
+ when ".xt1"
316
+ @texture_types.push( ".xt1" )
317
+ else
318
+ raise "Unsupported texture type! #{File.extname(p)}"
319
+ end
320
+ rescue
321
+ raise "Unsupported texture type! #{id}"
322
+ end
323
+ end
324
+ invalidate_layout
325
+ uint = get_uint
326
+ flag = 0x60000020 if @wtp && flag == 0x0
327
+ @texture_sizes.push( file.size )
328
+ @textures.push( file )
329
+ @texture_flags.push( flag )
330
+ @texture_idx.push if idx
331
+ if @wtp && @big
332
+ unless idx
333
+ @texture_idx.push Zlib.crc32(file.read,0)
334
+ file.rewind
335
+ end
336
+ file.seek(0x20*2)
337
+ gx2 = file.read(0x9c)
338
+ num_mipmap = gx2[0x10...0x14].unpack(uint).first
339
+ data_length = gx2[0x20...0x24].unpack(uint).first
340
+ mipmap_length = gx2[0x28...0x2c].unpack(uint).first
341
+ @data_length.push( data_length )
342
+ if num_mipmap > 1
343
+ @mipmap_length.push( mipmap_length )
344
+ else
345
+ @mipmap_length.push( 0x0 )
346
+ end
347
+ elsif @texture_types.last == ".xt1"
348
+ @texture_sizes[-1] = file.size - 0x38
349
+ end
350
+ @num_tex += 1
351
+ self
352
+ end
353
+
354
+ def each
355
+ if block_given? then
356
+ @num_tex.times { |i|
357
+ yield [@texture_types[i], @texture_flags[i], @texture_idx[i]], @textures[i]
358
+ }
359
+ else
360
+ to_enum(:each)
361
+ end
362
+ end
363
+
364
+ def dump(name)
365
+ compute_layout
366
+ uint = get_uint
367
+ File.open(name,"wb") { |f|
368
+ f.write("\0"*@total_size)
369
+ f.rewind
370
+ f.write(@id)
371
+ f.write([@unknown].pack(uint))
372
+ f.write([@num_tex].pack(uint))
373
+ f.write([@offset_texture_offsets].pack(uint))
374
+ f.write([@offset_texture_sizes].pack(uint))
375
+ f.write([@offset_texture_flags].pack(uint))
376
+ f.write([@offset_texture_idx].pack(uint))
377
+ f.write([@offset_texture_infos].pack(uint))
378
+ f.write([@offset_mipmap_offsets].pack(uint)) if @wtp && @big
379
+
380
+
381
+ f.seek(@offset_texture_offsets)
382
+ f.write(@texture_offsets.pack("#{uint}*"))
383
+
384
+ if @offset_texture_sizes != 0
385
+ f.seek(@offset_texture_sizes)
386
+ f.write(@texture_sizes.pack("#{uint}*"))
387
+ end
388
+
389
+ if @offset_texture_flags != 0
390
+ f.seek(@offset_texture_flags)
391
+ f.write(@texture_flags.pack("#{uint}*"))
392
+ end
393
+
394
+ if @offset_texture_idx != 0
395
+ f.seek(@offset_texture_idx)
396
+ f.write(@texture_idx.pack("#{uint}*"))
397
+ end
398
+
399
+ unless @wtp
400
+ if @texture_types.first == ".xt1" #Astral Chain
401
+ @textures.each_with_index { |f_t, i|
402
+ f.seek(@offset_texture_infos + i*0x38)
403
+ f_t.rewind
404
+ f.write( f_t.read(0x38) )
405
+ f.seek(@texture_offsets[i])
406
+ f.write( f_t.read )
407
+ f_t.rewind
408
+ }
409
+
410
+ else
411
+ @texture_offsets.each_with_index { |off, i|
412
+ f.seek(off)
413
+ @textures[i].rewind
414
+ f.write( @textures[i].read )
415
+ @textures[i].rewind
416
+ }
417
+ end
418
+ else
419
+ if @big
420
+ @textures.each_with_index { |f_t, i|
421
+ f.seek(@offset_texture_infos + i*0xc0)
422
+ f_t.seek(0x20*2)
423
+ f.write( f_t.read(0x9c) )
424
+ }
425
+ if @offset_mipmap_offsets != 0
426
+ f.seek(@offset_mipmap_offsets)
427
+ f.write(@mipmap_offsets.pack("#{uint}*"))
428
+ end
429
+ elsif @texture_types.first == ".xt1" #Astral Chain
430
+ @textures.each_with_index { |f_t, i|
431
+ f.seek(@offset_texture_infos + i*0x38)
432
+ f_t.rewind
433
+ f.write( f_t.read(0x38) )
434
+ }
435
+ else #Nier or Bayo 2 Switch
436
+ if @offset_texture_infos != 0
437
+ f.seek(@offset_texture_infos)
438
+ f.write(@texture_infos.pack("#{uint}*"))
439
+ end
440
+ end
441
+ File.open(name.gsub(".wta", ".wtp"), "wb") { |f_wtp|
442
+ f_wtp.write("\x00"*@total_size_wtp)
443
+ f_wtp.rewind
444
+ if @big
445
+ @texture_offsets.each_with_index { |off, i|
446
+ f_wtp.seek(off)
447
+ @textures[i].seek(0x20*3+0x9c)
448
+ f_wtp.write(@textures[i].read(@data_length[i]))
449
+ }
450
+ @mipmap_offsets.each_with_index { |off, i|
451
+ if off != 0
452
+ f_wtp.seek(off)
453
+ @textures[i].seek(0x20*4+0x9c+@data_length[i])
454
+ f_wtp.write(@textures[i].read(@mipmap_length[i]))
455
+ end
456
+ }
457
+ elsif @texture_types.first == ".xt1" #Astral Chain
458
+ @texture_offsets.each_with_index { |off, i|
459
+ f_wtp.seek(off)
460
+ @textures[i].seek(0x38)
461
+ f_wtp.write( @textures[i].read )
462
+ @textures[i].rewind
463
+ }
464
+ else #Nier or Bayo 2 Switch
465
+ @texture_offsets.each_with_index { |off, i|
466
+ f_wtp.seek(off)
467
+ @textures[i].rewind
468
+ f_wtp.write( @textures[i].read )
469
+ @textures[i].rewind
470
+ }
471
+ end
472
+ }
473
+ end
474
+
475
+ }
476
+
477
+ end
478
+
479
+ end
480
+
481
+ end
data/lib/bayonetta.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'libbin'
2
+ require_relative 'bayonetta/linalg'
3
+ require_relative 'bayonetta/endianness'
4
+ require_relative 'bayonetta/alignment'
5
+ require_relative 'bayonetta/bone'
6
+ require_relative 'bayonetta/pkz'
7
+ require_relative 'bayonetta/dat'
8
+ require_relative 'bayonetta/eff'
9
+ require_relative 'bayonetta/wtb'
10
+ require_relative 'bayonetta/wmb'
11
+ require_relative 'bayonetta/wmb3'
12
+ require_relative 'bayonetta/bxm'
13
+ require_relative 'bayonetta/clp'
14
+ require_relative 'bayonetta/clh'
15
+ require_relative 'bayonetta/clw'
16
+ require_relative 'bayonetta/scr'
17
+ require_relative 'bayonetta/mot'
18
+ require_relative 'bayonetta/exp'
19
+
20
+ module Bayonetta
21
+ include Alignment
22
+
23
+ #Platforms
24
+ PC = 1
25
+ WIIU = 2
26
+ XBOX360 = 3
27
+ PS3 = 4
28
+ SWITCH = 5
29
+ PLATFORMS = {
30
+ pc: PC,
31
+ wiiu: WIIU,
32
+ xbox360: XBOX360,
33
+ ps3: PS3,
34
+ switch: SWITCH
35
+ }
36
+
37
+ #Games
38
+ BAYONETTA = 1
39
+ BAYONETTA2 = 2
40
+ NIERAUTOMATA = 3
41
+ VANQUISH = 4
42
+ ANARCHY = 5
43
+ GAMES = {
44
+ bayo: BAYONETTA,
45
+ bayo2: BAYONETTA2,
46
+ nier: NIERAUTOMATA,
47
+ vanquish: VANQUISH,
48
+ anarchy: ANARCHY
49
+ }
50
+
51
+ #Supported
52
+ SUPPORTED = {
53
+ [BAYONETTA, PC] => true,
54
+ [BAYONETTA, WIIU] => true,
55
+ [BAYONETTA2, WIIU] => true,
56
+ [NIERAUTOMATA, PC] => true,
57
+ [VANQUISH, PC] => true,
58
+ [ANARCHY, XBOX360] => true
59
+ }
60
+ end