pgtools 1.0.0 → 1.0.1

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 +4 -4
  2. data/LICENSE +25 -25
  3. data/bin/bxm_decoder +2 -2
  4. data/bin/bxm_encoder +2 -2
  5. data/bin/clh_convert +2 -2
  6. data/bin/clp_convert +2 -2
  7. data/bin/clw_convert +2 -2
  8. data/bin/dat_creator +2 -2
  9. data/bin/dat_extractor +2 -2
  10. data/bin/dat_ls +2 -2
  11. data/bin/eff_idd_creator +2 -2
  12. data/bin/eff_idd_extractor +2 -2
  13. data/bin/exp_convert_wiiu_pc +2 -2
  14. data/bin/exp_tool +2 -2
  15. data/bin/mot_convert_wiiu_pc +2 -2
  16. data/bin/mot_tool +2 -2
  17. data/bin/pkz_extractor +2 -2
  18. data/bin/scr_creator +2 -2
  19. data/bin/scr_extractor +2 -2
  20. data/bin/wmb_cleanup +2 -2
  21. data/bin/wmb_common_bones +2 -2
  22. data/bin/wmb_convert_pc_switch +2 -2
  23. data/bin/wmb_convert_wiiu_pc +2 -2
  24. data/bin/wmb_export_assimp +2 -2
  25. data/bin/wmb_get_bone_map +2 -2
  26. data/bin/wmb_import_assimp +2 -2
  27. data/bin/wmb_import_nier +2 -2
  28. data/bin/wmb_import_wiiu +2 -2
  29. data/bin/wtb_convert_wiiu_pc +2 -2
  30. data/bin/wtx_creator +2 -2
  31. data/bin/wtx_extractor +2 -2
  32. data/lib/bayonetta/alignment.rb +0 -0
  33. data/lib/bayonetta/bone.rb +0 -0
  34. data/lib/bayonetta/bxm.rb +180 -180
  35. data/lib/bayonetta/clh.rb +159 -159
  36. data/lib/bayonetta/clp.rb +212 -212
  37. data/lib/bayonetta/clw.rb +166 -166
  38. data/lib/bayonetta/dat.rb +261 -261
  39. data/lib/bayonetta/eff.rb +314 -314
  40. data/lib/bayonetta/endianness.rb +0 -0
  41. data/lib/bayonetta/exp.rb +768 -768
  42. data/lib/bayonetta/linalg.rb +416 -416
  43. data/lib/bayonetta/material_database.yaml +2581 -2581
  44. data/lib/bayonetta/mot.rb +763 -763
  45. data/lib/bayonetta/pkz.rb +63 -63
  46. data/lib/bayonetta/scr.rb +0 -0
  47. data/lib/bayonetta/tools/bxm_decoder.rb +23 -23
  48. data/lib/bayonetta/tools/bxm_encoder.rb +37 -37
  49. data/lib/bayonetta/tools/clh_convert.rb +60 -60
  50. data/lib/bayonetta/tools/clp_convert.rb +70 -70
  51. data/lib/bayonetta/tools/clw_convert.rb +60 -60
  52. data/lib/bayonetta/tools/dat_creator.rb +57 -57
  53. data/lib/bayonetta/tools/dat_extractor.rb +94 -94
  54. data/lib/bayonetta/tools/dat_ls.rb +106 -106
  55. data/lib/bayonetta/tools/eff_idd_creator.rb +66 -66
  56. data/lib/bayonetta/tools/eff_idd_extractor.rb +73 -73
  57. data/lib/bayonetta/tools/exp_convert_wiiu_pc.rb +33 -33
  58. data/lib/bayonetta/tools/exp_tool.rb +48 -48
  59. data/lib/bayonetta/tools/mot_convert_wiiu_pc.rb +33 -33
  60. data/lib/bayonetta/tools/mot_tool.rb +0 -0
  61. data/lib/bayonetta/tools/pkz_extractor.rb +75 -75
  62. data/lib/bayonetta/tools/scr_creator.rb +63 -63
  63. data/lib/bayonetta/tools/scr_extractor.rb +78 -78
  64. data/lib/bayonetta/tools/wmb_cleanup.rb +250 -250
  65. data/lib/bayonetta/tools/wmb_common_bones.rb +45 -45
  66. data/lib/bayonetta/tools/wmb_convert_pc_switch.rb +35 -35
  67. data/lib/bayonetta/tools/wmb_convert_wiiu_pc.rb +33 -33
  68. data/lib/bayonetta/tools/wmb_export_assimp.rb +479 -479
  69. data/lib/bayonetta/tools/wmb_get_bone_map.rb +50 -50
  70. data/lib/bayonetta/tools/wmb_import_assimp.rb +735 -735
  71. data/lib/bayonetta/tools/wmb_import_geometry_wiiu_pc.rb +472 -472
  72. data/lib/bayonetta/tools/wmb_import_nier.rb +309 -309
  73. data/lib/bayonetta/tools/wtb_convert_wiiu_pc.rb +95 -95
  74. data/lib/bayonetta/tools/wtb_import_textures.rb +103 -103
  75. data/lib/bayonetta/tools/wtx_creator.rb +69 -69
  76. data/lib/bayonetta/tools/wtx_extractor.rb +85 -85
  77. data/lib/bayonetta/vertex_types.yaml +0 -0
  78. data/lib/bayonetta/vertex_types2.yaml +0 -0
  79. data/lib/bayonetta/vertex_types_nier.yaml +145 -145
  80. data/lib/bayonetta/wmb.rb +2455 -2443
  81. data/lib/bayonetta/wmb3.rb +759 -759
  82. data/lib/bayonetta/wtb.rb +481 -481
  83. data/lib/bayonetta.rb +60 -60
  84. metadata +2 -2
data/lib/bayonetta/pkz.rb CHANGED
@@ -1,63 +1,63 @@
1
- module Bayonetta
2
-
3
- class PKZFile < LibBin::Structure
4
-
5
- class FileDescriptor < LibBin::Structure
6
- uint32 :offset_name
7
- uint32 :offset_compression
8
- uint64 :size
9
- uint64 :offset
10
- uint64 :compressed_size
11
- string :name, offset: 'offset_name + ..\header.offset_file_descriptors + ..\header.num_files * 0x20'
12
- string :compression, offset: 'offset_compression + ..\header.offset_file_descriptors + ..\header.num_files * 0x20'
13
- end
14
-
15
- class Header < LibBin::Structure
16
- uint32 :id
17
- int32 :unknown
18
- uint64 :size
19
- uint32 :num_files
20
- uint32 :offset_file_descriptors
21
- uint32 :length_file_name_table
22
- uint32 :unknown
23
- end
24
-
25
- register_field :header, Header
26
- register_field :file_descriptors, FileDescriptor, count: 'header.num_files',
27
- offset: 'header.offset_file_descriptors + __iterator * 0x20', sequence: true
28
-
29
- def self.is_big?(f)
30
- f.rewind
31
- block = lambda { |int64|
32
- id = f.read(4)
33
- raise "Invalid id #{id.inspect}!" if id != "pkzl".b
34
- f.read(4)
35
- size = f.read(8).unpack(int64).first
36
- size == f.size
37
- }
38
- big = block.call("q>")
39
- f.rewind
40
- small = block.call("q<")
41
- f.rewind
42
- raise "Invalid data!" unless big ^ small
43
- return big
44
- end
45
-
46
- def self.load(input_name)
47
- if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
48
- input = input_name
49
- else
50
- input = File.open(input_name, "rb")
51
- end
52
- input_big = is_big?(input)
53
- pkz = self::new
54
- pkz.instance_variable_set(:@__was_big, input_big)
55
- pkz.__load(input, input_big)
56
- input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
57
-
58
- pkz
59
- end
60
-
61
- end
62
-
63
- end
1
+ module Bayonetta
2
+
3
+ class PKZFile < LibBin::Structure
4
+
5
+ class FileDescriptor < LibBin::Structure
6
+ uint32 :offset_name
7
+ uint32 :offset_compression
8
+ uint64 :size
9
+ uint64 :offset
10
+ uint64 :compressed_size
11
+ string :name, offset: 'offset_name + ..\header.offset_file_descriptors + ..\header.num_files * 0x20'
12
+ string :compression, offset: 'offset_compression + ..\header.offset_file_descriptors + ..\header.num_files * 0x20'
13
+ end
14
+
15
+ class Header < LibBin::Structure
16
+ uint32 :id
17
+ int32 :unknown
18
+ uint64 :size
19
+ uint32 :num_files
20
+ uint32 :offset_file_descriptors
21
+ uint32 :length_file_name_table
22
+ uint32 :unknown
23
+ end
24
+
25
+ register_field :header, Header
26
+ register_field :file_descriptors, FileDescriptor, count: 'header.num_files',
27
+ offset: 'header.offset_file_descriptors + __iterator * 0x20', sequence: true
28
+
29
+ def self.is_big?(f)
30
+ f.rewind
31
+ block = lambda { |int64|
32
+ id = f.read(4)
33
+ raise "Invalid id #{id.inspect}!" if id != "pkzl".b
34
+ f.read(4)
35
+ size = f.read(8).unpack(int64).first
36
+ size == f.size
37
+ }
38
+ big = block.call("q>")
39
+ f.rewind
40
+ small = block.call("q<")
41
+ f.rewind
42
+ raise "Invalid data!" unless big ^ small
43
+ return big
44
+ end
45
+
46
+ def self.load(input_name)
47
+ if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
48
+ input = input_name
49
+ else
50
+ input = File.open(input_name, "rb")
51
+ end
52
+ input_big = is_big?(input)
53
+ pkz = self::new
54
+ pkz.instance_variable_set(:@__was_big, input_big)
55
+ pkz.__load(input, input_big)
56
+ input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
57
+
58
+ pkz
59
+ end
60
+
61
+ end
62
+
63
+ end
data/lib/bayonetta/scr.rb CHANGED
File without changes
@@ -1,23 +1,23 @@
1
- require 'optparse'
2
- require_relative '../../bayonetta'
3
- include Bayonetta
4
-
5
- OptionParser.new do |opts|
6
- opts.banner = <<EOF
7
- Usage: bxm_decoder target_file
8
- Decode the target bxm file into xml
9
-
10
- EOF
11
- opts.on("-h", "--help", "Prints this help") do
12
- puts opts
13
- exit
14
- end
15
-
16
- end.parse!
17
-
18
- input_file = ARGV[0]
19
-
20
- File::open(input_file, "rb") { |f|
21
- bxm = BXMFile::load(f)
22
- print bxm.to_xml
23
- }
1
+ require 'optparse'
2
+ require_relative '../../bayonetta'
3
+ include Bayonetta
4
+
5
+ OptionParser.new do |opts|
6
+ opts.banner = <<EOF
7
+ Usage: bxm_decoder target_file
8
+ Decode the target bxm file into xml
9
+
10
+ EOF
11
+ opts.on("-h", "--help", "Prints this help") do
12
+ puts opts
13
+ exit
14
+ end
15
+
16
+ end.parse!
17
+
18
+ input_file = ARGV[0]
19
+
20
+ File::open(input_file, "rb") { |f|
21
+ bxm = BXMFile::load(f)
22
+ print bxm.to_xml
23
+ }
@@ -1,37 +1,37 @@
1
- require 'optparse'
2
- require 'nokogiri'
3
- require_relative '../../bayonetta'
4
- include Bayonetta
5
-
6
- options = {
7
- tag: :BXM,
8
- output: nil
9
- }
10
-
11
- opts = OptionParser.new do |parser|
12
- parser.banner = <<EOF
13
- Usage: bxm_encoder [options] [XML_FILE]
14
- Encode the pecified xml file int binary xml format. Unlessspecified
15
- output will be along with the original file with a bxm extension.
16
- If no file is given use stdin, but --output must be specified.
17
- EOF
18
- parser.on("-t", "--tag TAG", [:XML, :BXM], "Select tag to use (BXM, XML) default BXM")
19
- parser.on("-o", "--output filename", "Select output file name")
20
- end
21
- opts.parse!(into: options)
22
-
23
- tag = (options[:tag].to_s + "\0").b
24
-
25
- output_name = options[:output]
26
- if ARGV[0]
27
- ouput_name = File.join(File.dirname(ARGV[0]), File.basename(ARGV[0], File.extname(ARGV[0])))+".bxm" unless output_name
28
- input_file = File::open(ARGV[0], "rb")
29
- else
30
- raise "unspecified output file" unless output_name
31
- input_file = $stdin
32
- end
33
-
34
- bxm = BXMFile::from_xml(Nokogiri::XML(input_file.read), tag)
35
- bxm.dump(output_name)
36
-
37
- input_file.close if ARGV[0]
1
+ require 'optparse'
2
+ require 'nokogiri'
3
+ require_relative '../../bayonetta'
4
+ include Bayonetta
5
+
6
+ options = {
7
+ tag: :BXM,
8
+ output: nil
9
+ }
10
+
11
+ opts = OptionParser.new do |parser|
12
+ parser.banner = <<EOF
13
+ Usage: bxm_encoder [options] [XML_FILE]
14
+ Encode the pecified xml file int binary xml format. Unlessspecified
15
+ output will be along with the original file with a bxm extension.
16
+ If no file is given use stdin, but --output must be specified.
17
+ EOF
18
+ parser.on("-t", "--tag TAG", [:XML, :BXM], "Select tag to use (BXM, XML) default BXM")
19
+ parser.on("-o", "--output filename", "Select output file name")
20
+ end
21
+ opts.parse!(into: options)
22
+
23
+ tag = (options[:tag].to_s + "\0").b
24
+
25
+ output_name = options[:output]
26
+ if ARGV[0]
27
+ ouput_name = File.join(File.dirname(ARGV[0]), File.basename(ARGV[0], File.extname(ARGV[0])))+".bxm" unless output_name
28
+ input_file = File::open(ARGV[0], "rb")
29
+ else
30
+ raise "unspecified output file" unless output_name
31
+ input_file = $stdin
32
+ end
33
+
34
+ bxm = BXMFile::from_xml(Nokogiri::XML(input_file.read), tag)
35
+ bxm.dump(output_name)
36
+
37
+ input_file.close if ARGV[0]
@@ -1,60 +1,60 @@
1
- require 'optparse'
2
- require_relative '../../bayonetta'
3
- require 'yaml'
4
- include Bayonetta
5
- $bone_map = { }
6
- $options = {
7
- remap_bones: false,
8
- output: nil
9
- }
10
- OptionParser.new do |opts|
11
- opts.banner = <<EOF
12
- Usage: clh_convert target_file [options]
13
- Convert a Bayonetta 2 _clh.bxm file to bayonetta format, optionally
14
- remapping the bones, or remap a Bayonetta 1 clh file. By default
15
- output will be in the ./clx_output folder.
16
- EOF
17
-
18
- opts.on("-r", "--remap-bones=BONELISTS", "Remap specified bones, either lists separated by / or a yaml hash table") do |bone_lists|
19
- $options[:remap_bones] = true
20
- if File::exist?(bone_lists)
21
- $bone_map.merge! YAML::load_file(bone_lists)
22
- else
23
- lists = bone_lists.split("/")
24
- p input_list = eval(lists.first).to_a
25
- p output_list = eval(lists.last).to_a
26
- $bone_map.merge! input_list.zip(output_list).to_h
27
- end
28
- end
29
-
30
- opts.on("-o", "--output=filename", "file to output result") do |name|
31
- $options[:output] = name
32
- end
33
-
34
- opts.on("-h", "--help", "Prints this help") do
35
- puts opts
36
- exit
37
- end
38
-
39
- end.parse!
40
-
41
- $bone_map.merge!( { 4095 => 4095 } )
42
-
43
- Dir.mkdir("clx_output") unless Dir.exist?("clx_output")
44
-
45
- input_file = ARGV[0]
46
- raise "Invalid file #{input_file}" unless input_file && File::file?(input_file)
47
-
48
- output_file = $options[:output]
49
-
50
- if File.extname(ARGV[0]) == ".bxm"
51
- raise "Invalid clh file #{input_file}" unless File.basename(ARGV[0]).end_with?("_clh.bxm")
52
- output_file = File.join("clx_output", File.basename(ARGV[0]).gsub("_clh.bxm",".clh")) unless output_file
53
- clh = CLHFile::load_bxm(input_file)
54
- else
55
- raise "Invalid clh file #{input_file}" unless File.basename(ARGV[0]).end_with?(".clh")
56
- output_file = File.join("clx_output", File.basename(ARGV[0])) unless output_file
57
- clh = CLHFile::load(input_file)
58
- end
59
- clh.remap($bone_map) if $options[:remap_bones]
60
- clh.dump(output_file)
1
+ require 'optparse'
2
+ require_relative '../../bayonetta'
3
+ require 'yaml'
4
+ include Bayonetta
5
+ $bone_map = { }
6
+ $options = {
7
+ remap_bones: false,
8
+ output: nil
9
+ }
10
+ OptionParser.new do |opts|
11
+ opts.banner = <<EOF
12
+ Usage: clh_convert target_file [options]
13
+ Convert a Bayonetta 2 _clh.bxm file to bayonetta format, optionally
14
+ remapping the bones, or remap a Bayonetta 1 clh file. By default
15
+ output will be in the ./clx_output folder.
16
+ EOF
17
+
18
+ opts.on("-r", "--remap-bones=BONELISTS", "Remap specified bones, either lists separated by / or a yaml hash table") do |bone_lists|
19
+ $options[:remap_bones] = true
20
+ if File::exist?(bone_lists)
21
+ $bone_map.merge! YAML::load_file(bone_lists)
22
+ else
23
+ lists = bone_lists.split("/")
24
+ p input_list = eval(lists.first).to_a
25
+ p output_list = eval(lists.last).to_a
26
+ $bone_map.merge! input_list.zip(output_list).to_h
27
+ end
28
+ end
29
+
30
+ opts.on("-o", "--output=filename", "file to output result") do |name|
31
+ $options[:output] = name
32
+ end
33
+
34
+ opts.on("-h", "--help", "Prints this help") do
35
+ puts opts
36
+ exit
37
+ end
38
+
39
+ end.parse!
40
+
41
+ $bone_map.merge!( { 4095 => 4095 } )
42
+
43
+ Dir.mkdir("clx_output") unless Dir.exist?("clx_output")
44
+
45
+ input_file = ARGV[0]
46
+ raise "Invalid file #{input_file}" unless input_file && File::file?(input_file)
47
+
48
+ output_file = $options[:output]
49
+
50
+ if File.extname(ARGV[0]) == ".bxm"
51
+ raise "Invalid clh file #{input_file}" unless File.basename(ARGV[0]).end_with?("_clh.bxm")
52
+ output_file = File.join("clx_output", File.basename(ARGV[0]).gsub("_clh.bxm",".clh")) unless output_file
53
+ clh = CLHFile::load_bxm(input_file)
54
+ else
55
+ raise "Invalid clh file #{input_file}" unless File.basename(ARGV[0]).end_with?(".clh")
56
+ output_file = File.join("clx_output", File.basename(ARGV[0])) unless output_file
57
+ clh = CLHFile::load(input_file)
58
+ end
59
+ clh.remap($bone_map) if $options[:remap_bones]
60
+ clh.dump(output_file)
@@ -1,70 +1,70 @@
1
- require 'optparse'
2
- require_relative '../../bayonetta'
3
- require 'yaml'
4
- include Bayonetta
5
- $bone_map = { }
6
- $options = {
7
- remap_bones: false,
8
- fix: true,
9
- poly: true,
10
- output: nil
11
- }
12
- OptionParser.new do |opts|
13
- opts.banner = <<EOF
14
- Usage: clp_convert target_file [options]
15
- Convert a Bayonetta 2 _clp.bxm file to bayonetta format, optionally
16
- remapping the bones, or remap a Bayonetta 1 clp file. By default
17
- output will be in the ./clx_output folder.
18
- EOF
19
-
20
- opts.on("-r", "--remap-bones=BONELISTS", "Remap specified bones, either lists separated by / or a yaml hash table") do |bone_lists|
21
- $options[:remap_bones] = true
22
- if File::exist?(bone_lists)
23
- $bone_map.merge! YAML::load_file(bone_lists)
24
- else
25
- lists = bone_lists.split("/")
26
- p input_list = eval(lists.first).to_a
27
- p output_list = eval(lists.last).to_a
28
- $bone_map.merge! input_list.zip(output_list).to_h
29
- end
30
- end
31
-
32
- opts.on("-f", "--[no-]fix", "Map no_fix values (default true)") do |fix|
33
- $options[:fix] = fix
34
- end
35
-
36
- opts.on("-p", "--[no-]poly", "Map no_poly values (default true)") do |poly|
37
- $options[:poly] = poly
38
- end
39
-
40
- opts.on("-o", "--output=filename", "file to output result") do |name|
41
- $options[:output] = name
42
- end
43
-
44
- opts.on("-h", "--help", "Prints this help") do
45
- puts opts
46
- exit
47
- end
48
-
49
- end.parse!
50
-
51
- $bone_map.merge!( { 4095 => 4095 } )
52
-
53
- Dir.mkdir("clx_output") unless Dir.exist?("clx_output")
54
-
55
- input_file = ARGV[0]
56
- raise "Invalid file #{input_file}" unless input_file && File::file?(input_file)
57
-
58
- output_file = $options[:output]
59
-
60
- if File.extname(ARGV[0]) == ".bxm"
61
- raise "Invalid clp file #{input_file}" unless File.basename(ARGV[0]).end_with?("_clp.bxm")
62
- output_file = File.join("clx_output", File.basename(ARGV[0]).gsub("_clp.bxm",".clp")) unless output_file
63
- clp = CLPFile::load_bxm(input_file)
64
- else
65
- raise "Invalid clp file #{input_file}" unless File.basename(ARGV[0]).end_with?(".clp")
66
- output_file = File.join("clx_output", File.basename(ARGV[0])) unless output_file
67
- clp = CLPFile::load(input_file)
68
- end
69
- clp.remap($bone_map, $options[:poly], $options[:fix]) if $options[:remap_bones]
70
- clp.dump(output_file)
1
+ require 'optparse'
2
+ require_relative '../../bayonetta'
3
+ require 'yaml'
4
+ include Bayonetta
5
+ $bone_map = { }
6
+ $options = {
7
+ remap_bones: false,
8
+ fix: true,
9
+ poly: true,
10
+ output: nil
11
+ }
12
+ OptionParser.new do |opts|
13
+ opts.banner = <<EOF
14
+ Usage: clp_convert target_file [options]
15
+ Convert a Bayonetta 2 _clp.bxm file to bayonetta format, optionally
16
+ remapping the bones, or remap a Bayonetta 1 clp file. By default
17
+ output will be in the ./clx_output folder.
18
+ EOF
19
+
20
+ opts.on("-r", "--remap-bones=BONELISTS", "Remap specified bones, either lists separated by / or a yaml hash table") do |bone_lists|
21
+ $options[:remap_bones] = true
22
+ if File::exist?(bone_lists)
23
+ $bone_map.merge! YAML::load_file(bone_lists)
24
+ else
25
+ lists = bone_lists.split("/")
26
+ p input_list = eval(lists.first).to_a
27
+ p output_list = eval(lists.last).to_a
28
+ $bone_map.merge! input_list.zip(output_list).to_h
29
+ end
30
+ end
31
+
32
+ opts.on("-f", "--[no-]fix", "Map no_fix values (default true)") do |fix|
33
+ $options[:fix] = fix
34
+ end
35
+
36
+ opts.on("-p", "--[no-]poly", "Map no_poly values (default true)") do |poly|
37
+ $options[:poly] = poly
38
+ end
39
+
40
+ opts.on("-o", "--output=filename", "file to output result") do |name|
41
+ $options[:output] = name
42
+ end
43
+
44
+ opts.on("-h", "--help", "Prints this help") do
45
+ puts opts
46
+ exit
47
+ end
48
+
49
+ end.parse!
50
+
51
+ $bone_map.merge!( { 4095 => 4095 } )
52
+
53
+ Dir.mkdir("clx_output") unless Dir.exist?("clx_output")
54
+
55
+ input_file = ARGV[0]
56
+ raise "Invalid file #{input_file}" unless input_file && File::file?(input_file)
57
+
58
+ output_file = $options[:output]
59
+
60
+ if File.extname(ARGV[0]) == ".bxm"
61
+ raise "Invalid clp file #{input_file}" unless File.basename(ARGV[0]).end_with?("_clp.bxm")
62
+ output_file = File.join("clx_output", File.basename(ARGV[0]).gsub("_clp.bxm",".clp")) unless output_file
63
+ clp = CLPFile::load_bxm(input_file)
64
+ else
65
+ raise "Invalid clp file #{input_file}" unless File.basename(ARGV[0]).end_with?(".clp")
66
+ output_file = File.join("clx_output", File.basename(ARGV[0])) unless output_file
67
+ clp = CLPFile::load(input_file)
68
+ end
69
+ clp.remap($bone_map, $options[:poly], $options[:fix]) if $options[:remap_bones]
70
+ clp.dump(output_file)
@@ -1,60 +1,60 @@
1
- require 'optparse'
2
- require_relative '../../bayonetta'
3
- require 'yaml'
4
- include Bayonetta
5
- $bone_map = { }
6
- $options = {
7
- remap_bones: false,
8
- output: nil
9
- }
10
- OptionParser.new do |opts|
11
- opts.banner = <<EOF
12
- Usage: clw_convert target_file [options]
13
- Convert a Bayonetta 2 _clw.bxm file to bayonetta format, optionally
14
- remapping the bones, or remap a Bayonetta 1 clw file. By default
15
- output will be in the ./clx_output folder.
16
- EOF
17
-
18
- opts.on("-r", "--remap-bones=BONELISTS", "Remap specified bones, either lists separated by / or a yaml hash table") do |bone_lists|
19
- $options[:remap_bones] = true
20
- if File::exist?(bone_lists)
21
- $bone_map.merge! YAML::load_file(bone_lists)
22
- else
23
- lists = bone_lists.split("/")
24
- p input_list = eval(lists.first).to_a
25
- p output_list = eval(lists.last).to_a
26
- $bone_map.merge! input_list.zip(output_list).to_h
27
- end
28
- end
29
-
30
- opts.on("-o", "--output=filename", "file to output result") do |name|
31
- $options[:output] = name
32
- end
33
-
34
- opts.on("-h", "--help", "Prints this help") do
35
- puts opts
36
- exit
37
- end
38
-
39
- end.parse!
40
-
41
- $bone_map.merge!( { -1 => -1 } )
42
-
43
- Dir.mkdir("clx_output") unless Dir.exist?("clx_output")
44
-
45
- input_file = ARGV[0]
46
- raise "Invalid file #{input_file}" unless input_file && File::file?(input_file)
47
-
48
- output_file = $options[:output]
49
-
50
- if File.extname(ARGV[0]) == ".bxm"
51
- raise "Invalid clw file #{input_file}" unless File.basename(ARGV[0]).end_with?("_clw.bxm")
52
- output_file = File.join("clx_output", File.basename(ARGV[0]).gsub("_clw.bxm",".clw")) unless output_file
53
- clw = CLWFile::load_bxm(input_file)
54
- else
55
- raise "Invalid clw file #{input_file}" unless File.basename(ARGV[0]).end_with?(".clw")
56
- output_file = File.join("clx_output", File.basename(ARGV[0])) unless output_file
57
- clw = CLWFile::load(input_file)
58
- end
59
- clw.remap($bone_map) if $options[:remap_bones]
60
- clw.dump(output_file)
1
+ require 'optparse'
2
+ require_relative '../../bayonetta'
3
+ require 'yaml'
4
+ include Bayonetta
5
+ $bone_map = { }
6
+ $options = {
7
+ remap_bones: false,
8
+ output: nil
9
+ }
10
+ OptionParser.new do |opts|
11
+ opts.banner = <<EOF
12
+ Usage: clw_convert target_file [options]
13
+ Convert a Bayonetta 2 _clw.bxm file to bayonetta format, optionally
14
+ remapping the bones, or remap a Bayonetta 1 clw file. By default
15
+ output will be in the ./clx_output folder.
16
+ EOF
17
+
18
+ opts.on("-r", "--remap-bones=BONELISTS", "Remap specified bones, either lists separated by / or a yaml hash table") do |bone_lists|
19
+ $options[:remap_bones] = true
20
+ if File::exist?(bone_lists)
21
+ $bone_map.merge! YAML::load_file(bone_lists)
22
+ else
23
+ lists = bone_lists.split("/")
24
+ p input_list = eval(lists.first).to_a
25
+ p output_list = eval(lists.last).to_a
26
+ $bone_map.merge! input_list.zip(output_list).to_h
27
+ end
28
+ end
29
+
30
+ opts.on("-o", "--output=filename", "file to output result") do |name|
31
+ $options[:output] = name
32
+ end
33
+
34
+ opts.on("-h", "--help", "Prints this help") do
35
+ puts opts
36
+ exit
37
+ end
38
+
39
+ end.parse!
40
+
41
+ $bone_map.merge!( { -1 => -1 } )
42
+
43
+ Dir.mkdir("clx_output") unless Dir.exist?("clx_output")
44
+
45
+ input_file = ARGV[0]
46
+ raise "Invalid file #{input_file}" unless input_file && File::file?(input_file)
47
+
48
+ output_file = $options[:output]
49
+
50
+ if File.extname(ARGV[0]) == ".bxm"
51
+ raise "Invalid clw file #{input_file}" unless File.basename(ARGV[0]).end_with?("_clw.bxm")
52
+ output_file = File.join("clx_output", File.basename(ARGV[0]).gsub("_clw.bxm",".clw")) unless output_file
53
+ clw = CLWFile::load_bxm(input_file)
54
+ else
55
+ raise "Invalid clw file #{input_file}" unless File.basename(ARGV[0]).end_with?(".clw")
56
+ output_file = File.join("clx_output", File.basename(ARGV[0])) unless output_file
57
+ clw = CLWFile::load(input_file)
58
+ end
59
+ clw.remap($bone_map) if $options[:remap_bones]
60
+ clw.dump(output_file)