pgtools 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +25 -25
- data/bin/bxm_decoder +2 -2
- data/bin/bxm_encoder +2 -2
- data/bin/clh_convert +2 -2
- data/bin/clp_convert +2 -2
- data/bin/clw_convert +2 -2
- data/bin/dat_creator +2 -2
- data/bin/dat_extractor +2 -2
- data/bin/dat_ls +2 -2
- data/bin/eff_idd_creator +2 -2
- data/bin/eff_idd_extractor +2 -2
- data/bin/exp_convert_wiiu_pc +2 -2
- data/bin/exp_tool +2 -2
- data/bin/mot_convert_wiiu_pc +2 -2
- data/bin/mot_tool +2 -2
- data/bin/pkz_extractor +2 -2
- data/bin/scr_creator +2 -2
- data/bin/scr_extractor +2 -2
- data/bin/wmb_cleanup +2 -2
- data/bin/wmb_common_bones +2 -2
- data/bin/wmb_convert_pc_switch +2 -2
- data/bin/wmb_convert_wiiu_pc +2 -2
- data/bin/wmb_export_assimp +2 -2
- data/bin/wmb_get_bone_map +2 -2
- data/bin/wmb_import_assimp +2 -2
- data/bin/wmb_import_nier +2 -2
- data/bin/wmb_import_wiiu +2 -2
- data/bin/wtb_convert_wiiu_pc +2 -2
- data/bin/wtx_creator +2 -2
- data/bin/wtx_extractor +2 -2
- data/lib/bayonetta/alignment.rb +0 -0
- data/lib/bayonetta/bone.rb +0 -0
- data/lib/bayonetta/bxm.rb +180 -180
- data/lib/bayonetta/clh.rb +159 -159
- data/lib/bayonetta/clp.rb +212 -212
- data/lib/bayonetta/clw.rb +166 -166
- data/lib/bayonetta/dat.rb +261 -261
- data/lib/bayonetta/eff.rb +314 -314
- data/lib/bayonetta/endianness.rb +0 -0
- data/lib/bayonetta/exp.rb +768 -768
- data/lib/bayonetta/linalg.rb +416 -416
- data/lib/bayonetta/material_database.yaml +2581 -2581
- data/lib/bayonetta/mot.rb +763 -763
- data/lib/bayonetta/pkz.rb +63 -63
- data/lib/bayonetta/scr.rb +0 -0
- data/lib/bayonetta/tools/bxm_decoder.rb +23 -23
- data/lib/bayonetta/tools/bxm_encoder.rb +37 -37
- data/lib/bayonetta/tools/clh_convert.rb +60 -60
- data/lib/bayonetta/tools/clp_convert.rb +70 -70
- data/lib/bayonetta/tools/clw_convert.rb +60 -60
- data/lib/bayonetta/tools/dat_creator.rb +57 -57
- data/lib/bayonetta/tools/dat_extractor.rb +94 -94
- data/lib/bayonetta/tools/dat_ls.rb +106 -106
- data/lib/bayonetta/tools/eff_idd_creator.rb +66 -66
- data/lib/bayonetta/tools/eff_idd_extractor.rb +73 -73
- data/lib/bayonetta/tools/exp_convert_wiiu_pc.rb +33 -33
- data/lib/bayonetta/tools/exp_tool.rb +48 -48
- data/lib/bayonetta/tools/mot_convert_wiiu_pc.rb +33 -33
- data/lib/bayonetta/tools/mot_tool.rb +0 -0
- data/lib/bayonetta/tools/pkz_extractor.rb +75 -75
- data/lib/bayonetta/tools/scr_creator.rb +63 -63
- data/lib/bayonetta/tools/scr_extractor.rb +78 -78
- data/lib/bayonetta/tools/wmb_cleanup.rb +250 -250
- data/lib/bayonetta/tools/wmb_common_bones.rb +45 -45
- data/lib/bayonetta/tools/wmb_convert_pc_switch.rb +35 -35
- data/lib/bayonetta/tools/wmb_convert_wiiu_pc.rb +33 -33
- data/lib/bayonetta/tools/wmb_export_assimp.rb +479 -479
- data/lib/bayonetta/tools/wmb_get_bone_map.rb +50 -50
- data/lib/bayonetta/tools/wmb_import_assimp.rb +735 -735
- data/lib/bayonetta/tools/wmb_import_geometry_wiiu_pc.rb +472 -472
- data/lib/bayonetta/tools/wmb_import_nier.rb +309 -309
- data/lib/bayonetta/tools/wtb_convert_wiiu_pc.rb +95 -95
- data/lib/bayonetta/tools/wtb_import_textures.rb +103 -103
- data/lib/bayonetta/tools/wtx_creator.rb +69 -69
- data/lib/bayonetta/tools/wtx_extractor.rb +85 -85
- data/lib/bayonetta/vertex_types.yaml +0 -0
- data/lib/bayonetta/vertex_types2.yaml +0 -0
- data/lib/bayonetta/vertex_types_nier.yaml +145 -145
- data/lib/bayonetta/wmb.rb +2455 -2443
- data/lib/bayonetta/wmb3.rb +759 -759
- data/lib/bayonetta/wtb.rb +481 -481
- data/lib/bayonetta.rb +60 -60
- metadata +2 -2
@@ -1,78 +1,78 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'yaml'
|
3
|
-
require_relative '../../bayonetta'
|
4
|
-
|
5
|
-
$options = {
|
6
|
-
output: nil
|
7
|
-
}
|
8
|
-
|
9
|
-
OptionParser.new do |opts|
|
10
|
-
opts.banner = <<EOF
|
11
|
-
Usage: scr_extractor file
|
12
|
-
EOF
|
13
|
-
opts.on("-h", "--help", "Prints this help") do
|
14
|
-
puts opts
|
15
|
-
exit
|
16
|
-
end
|
17
|
-
|
18
|
-
opts.on("-o", "--output=dirname", "directory to output result") do |name|
|
19
|
-
$options[:output] = name
|
20
|
-
end
|
21
|
-
|
22
|
-
end.parse!
|
23
|
-
|
24
|
-
save_pwd = Dir.pwd
|
25
|
-
|
26
|
-
raise "Invalid output directory #{$options[:output]}" if $options[:output] && !Dir.exist?($options[:output])
|
27
|
-
|
28
|
-
filename = ARGV[0]
|
29
|
-
raise "Invalid file: #{filename}!" unless filename && File.exist?(filename)
|
30
|
-
directory = File.dirname(filename)
|
31
|
-
name = File.basename(filename)
|
32
|
-
ext_name = File.extname(name)
|
33
|
-
|
34
|
-
raise "Invalid file: #{filename}!" unless ext_name == ".scr"
|
35
|
-
|
36
|
-
f = File::open(filename, "rb")
|
37
|
-
|
38
|
-
if $options[:output]
|
39
|
-
Dir.chdir(save_pwd)
|
40
|
-
Dir.chdir($options[:output])
|
41
|
-
else
|
42
|
-
Dir.chdir(directory)
|
43
|
-
end
|
44
|
-
dir_name = File.basename(name, ext_name) + "#{ext_name.gsub(".","_")}"
|
45
|
-
Dir.mkdir(dir_name) unless Dir.exist?(dir_name)
|
46
|
-
Dir.chdir(dir_name)
|
47
|
-
|
48
|
-
scr = Bayonetta::SCRFile::load(f)
|
49
|
-
|
50
|
-
scr.each_model.each_with_index { |f1, i|
|
51
|
-
File::open("%03d.wmb" % [i] , "wb") { |f2|
|
52
|
-
f1.rewind
|
53
|
-
f2.write(f1.read)
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
f1 = scr.textures
|
58
|
-
if f1
|
59
|
-
File::open("000.wtb", "wb") { |f2|
|
60
|
-
f1.rewind
|
61
|
-
f2.write(f1.read)
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
Dir.mkdir(".metadata") unless Dir.exist?(".metadata")
|
66
|
-
Dir.chdir(".metadata")
|
67
|
-
File::open("models_metadata.yaml", "w") { |fl|
|
68
|
-
fl.print YAML::dump( scr.models_metadata )
|
69
|
-
}
|
70
|
-
File::open("big.yaml","w") { |fl|
|
71
|
-
fl.print YAML::dump( scr.big )
|
72
|
-
}
|
73
|
-
File::open("bayo2.yaml","w") { |fl|
|
74
|
-
fl.print YAML::dump( scr.bayo2? )
|
75
|
-
}
|
76
|
-
File::open("unknown.yaml", "w") { |fl|
|
77
|
-
fl.print YAML::dump( scr.unknown )
|
78
|
-
}
|
1
|
+
require 'optparse'
|
2
|
+
require 'yaml'
|
3
|
+
require_relative '../../bayonetta'
|
4
|
+
|
5
|
+
$options = {
|
6
|
+
output: nil
|
7
|
+
}
|
8
|
+
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = <<EOF
|
11
|
+
Usage: scr_extractor file
|
12
|
+
EOF
|
13
|
+
opts.on("-h", "--help", "Prints this help") do
|
14
|
+
puts opts
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on("-o", "--output=dirname", "directory to output result") do |name|
|
19
|
+
$options[:output] = name
|
20
|
+
end
|
21
|
+
|
22
|
+
end.parse!
|
23
|
+
|
24
|
+
save_pwd = Dir.pwd
|
25
|
+
|
26
|
+
raise "Invalid output directory #{$options[:output]}" if $options[:output] && !Dir.exist?($options[:output])
|
27
|
+
|
28
|
+
filename = ARGV[0]
|
29
|
+
raise "Invalid file: #{filename}!" unless filename && File.exist?(filename)
|
30
|
+
directory = File.dirname(filename)
|
31
|
+
name = File.basename(filename)
|
32
|
+
ext_name = File.extname(name)
|
33
|
+
|
34
|
+
raise "Invalid file: #{filename}!" unless ext_name == ".scr"
|
35
|
+
|
36
|
+
f = File::open(filename, "rb")
|
37
|
+
|
38
|
+
if $options[:output]
|
39
|
+
Dir.chdir(save_pwd)
|
40
|
+
Dir.chdir($options[:output])
|
41
|
+
else
|
42
|
+
Dir.chdir(directory)
|
43
|
+
end
|
44
|
+
dir_name = File.basename(name, ext_name) + "#{ext_name.gsub(".","_")}"
|
45
|
+
Dir.mkdir(dir_name) unless Dir.exist?(dir_name)
|
46
|
+
Dir.chdir(dir_name)
|
47
|
+
|
48
|
+
scr = Bayonetta::SCRFile::load(f)
|
49
|
+
|
50
|
+
scr.each_model.each_with_index { |f1, i|
|
51
|
+
File::open("%03d.wmb" % [i] , "wb") { |f2|
|
52
|
+
f1.rewind
|
53
|
+
f2.write(f1.read)
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
f1 = scr.textures
|
58
|
+
if f1
|
59
|
+
File::open("000.wtb", "wb") { |f2|
|
60
|
+
f1.rewind
|
61
|
+
f2.write(f1.read)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
Dir.mkdir(".metadata") unless Dir.exist?(".metadata")
|
66
|
+
Dir.chdir(".metadata")
|
67
|
+
File::open("models_metadata.yaml", "w") { |fl|
|
68
|
+
fl.print YAML::dump( scr.models_metadata )
|
69
|
+
}
|
70
|
+
File::open("big.yaml","w") { |fl|
|
71
|
+
fl.print YAML::dump( scr.big )
|
72
|
+
}
|
73
|
+
File::open("bayo2.yaml","w") { |fl|
|
74
|
+
fl.print YAML::dump( scr.bayo2? )
|
75
|
+
}
|
76
|
+
File::open("unknown.yaml", "w") { |fl|
|
77
|
+
fl.print YAML::dump( scr.unknown )
|
78
|
+
}
|
@@ -1,250 +1,250 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'yaml'
|
3
|
-
require_relative '../../bayonetta'
|
4
|
-
include Bayonetta
|
5
|
-
|
6
|
-
$options = {
|
7
|
-
:vertexes => false,
|
8
|
-
:bones => false,
|
9
|
-
:remap_bones => false,
|
10
|
-
:textures => false,
|
11
|
-
:cleanup_mat => false,
|
12
|
-
:cleanup_mat_sizes => false,
|
13
|
-
:maximize_mat_sizes => false,
|
14
|
-
:delete_bones => nil,
|
15
|
-
:offsets => false,
|
16
|
-
:fix => false,
|
17
|
-
:swap => nil,
|
18
|
-
:swap_meshes => nil,
|
19
|
-
:move_meshes => nil,
|
20
|
-
:delete_meshes => nil,
|
21
|
-
:delete_batches => nil,
|
22
|
-
:merge_meshes => nil,
|
23
|
-
:overwrite => nil
|
24
|
-
}
|
25
|
-
|
26
|
-
OptionParser.new do |opts|
|
27
|
-
opts.banner = "Usage: wmb_cleanup.rb target_file [options]"
|
28
|
-
|
29
|
-
opts.on("--[no-]bone-refs", "Cleanup bone refs in batches") do |bone_refs|
|
30
|
-
$options[:bone_refs] = bone_refs
|
31
|
-
end
|
32
|
-
|
33
|
-
opts.on("--[no-]add-parents-bone-refs", "Add ancestry to bone refs and sort them") do |bone_refs|
|
34
|
-
$options[:submodel_bone_refs] = bone_refs
|
35
|
-
end
|
36
|
-
|
37
|
-
opts.on("--[no-]add-previous-bone-refs", "Add all previous bones to bone refs and sort them") do |bone_refs|
|
38
|
-
$options[:previous_bone_refs] = bone_refs
|
39
|
-
end
|
40
|
-
|
41
|
-
opts.on("-b", "--[no-]bones", "Cleanup bones") do |bones|
|
42
|
-
$options[:bones] = bones
|
43
|
-
end
|
44
|
-
|
45
|
-
opts.on("--remap-bones=BONEMAP", "Remaps specified local bones to global bone indexes") do |bone_map|
|
46
|
-
if File.exist?(bone_map)
|
47
|
-
$options[:remap_bones] = YAML::load_file(bone_map)
|
48
|
-
else
|
49
|
-
$options[:remap_bones] = eval(bone_map).to_h
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
opts.on("--[no-]order-bones", "Order bones in their global numbering if possible") do |order_bones|
|
54
|
-
$options[:order_bones] = order_bones
|
55
|
-
end
|
56
|
-
|
57
|
-
opts.on("-v", "--[no-]vertexes", "Cleanup vertexes") do |vertexes|
|
58
|
-
$options[:vertexes] = vertexes
|
59
|
-
end
|
60
|
-
|
61
|
-
opts.on("--[no-]remove_duplicate_vertexes", "Ensure no vertex is used more than once") do |rdv|
|
62
|
-
$options[:remove_duplicate_vertexes] = rdv
|
63
|
-
end
|
64
|
-
|
65
|
-
opts.on("--[no-]normalize-vertex-usage", "Ensure no vertex is used in more than 1 batch") do |nvu|
|
66
|
-
$options[:normalize_vertex_usage] = nvu
|
67
|
-
end
|
68
|
-
|
69
|
-
opts.on("-o", "--[no-]remove-batch-offsets", "Remove batch vertex offsets") do |o|
|
70
|
-
$options[:offsets] = o
|
71
|
-
end
|
72
|
-
|
73
|
-
opts.on("--[no-]check-normals", "Try to detect wide normals (Switch)") do |cn|
|
74
|
-
$options[:check_normals] = cn
|
75
|
-
end
|
76
|
-
|
77
|
-
opts.on("-f", "--[no-]fix-ex-data", "Put normal map u v in ex data") do |fix|
|
78
|
-
$options[:fix] = fix
|
79
|
-
end
|
80
|
-
|
81
|
-
opts.on("--copy-uv1to2=MESHLIST", "Copy the first UV mapping to the second one") do |copy_uv|
|
82
|
-
$options[:copy_uv] = eval(copy_uv).to_a
|
83
|
-
end
|
84
|
-
|
85
|
-
opts.on("--[no-]remove-triangle-strips", "Remove triangle strips and replace by triangles") do |strips|
|
86
|
-
$options[:strips] = strips
|
87
|
-
end
|
88
|
-
|
89
|
-
opts.on("--revert-triangles=MESHLIST", "Revert traiangle faces") do |revert|
|
90
|
-
$options[:revert] = eval(revert).to_a
|
91
|
-
end
|
92
|
-
|
93
|
-
opts.on("-e", "--swap-endianness", "Swap endianness") do |swap|
|
94
|
-
$options[:swap] = swap
|
95
|
-
end
|
96
|
-
|
97
|
-
opts.on("--duplicate-meshes=MESHLIST", "Duplicate specified meshes") do |mesh_list|
|
98
|
-
$options[:duplicate_meshes] = eval(mesh_list).to_a
|
99
|
-
end
|
100
|
-
|
101
|
-
opts.on("-s", "--swap-meshes=MESHHASH", "Swap specified meshes") do |mesh_hash|
|
102
|
-
$options[:swap_meshes] = eval(mesh_hash).to_h
|
103
|
-
end
|
104
|
-
|
105
|
-
opts.on("--merge-meshes=MESHHASH", "Merge specified meshes") do |mesh_hash|
|
106
|
-
$options[:merge_meshes] = eval(mesh_hash).to_h
|
107
|
-
end
|
108
|
-
|
109
|
-
opts.on("--move-meshes=MESHHASH", "Move the specified meshes to the specified positions") do |mesh_positions|
|
110
|
-
$options[:move_meshes] = eval(mesh_positions).to_h
|
111
|
-
end
|
112
|
-
|
113
|
-
opts.on("-m", "--delete-meshes=MESHLIST", "Delete specified meshes") do |mesh_list|
|
114
|
-
$options[:delete_meshes] = eval(mesh_list).to_a
|
115
|
-
end
|
116
|
-
|
117
|
-
opts.on("--delete-batches=BATCHLIST", "Delete specified batch list (WMB3) or { mesh => batch list } hash") do |batch_list|
|
118
|
-
$options[:delete_batches] = eval(batch_list).to_a
|
119
|
-
end
|
120
|
-
|
121
|
-
opts.on("--dummy=MESHHLIST", "Replace a given meshes by dummy mesh with one dummy batch") do |mesh_list|
|
122
|
-
$options[:dummy_meshes] = eval(mesh_list).to_a
|
123
|
-
end
|
124
|
-
|
125
|
-
opts.on("--split-meshes=MESHLIST", "Split the selected meshes into meshes containing only one batch") do |split_meshes|
|
126
|
-
$options[:split_meshes] = eval(split_meshes).to_a
|
127
|
-
end
|
128
|
-
|
129
|
-
opts.on("-d", "--delete-bones=BONELIST", "Delete specified bones") do |bone_list|
|
130
|
-
$options[:delete_bones] = eval(bone_list).to_a
|
131
|
-
end
|
132
|
-
|
133
|
-
opts.on("-t", "--[no-]textures", "Cleanup textures") do |textures|
|
134
|
-
$options[:textures] = textures
|
135
|
-
end
|
136
|
-
|
137
|
-
opts.on("-c", "--cleanup-materials", "Cleanup materials") do |cleanup_mat|
|
138
|
-
$options[:cleanup_mat] = cleanup_mat
|
139
|
-
end
|
140
|
-
|
141
|
-
opts.on("--cleanup-material-sizes", "Cleanup material sizes") do |cleanup_mat_sizes|
|
142
|
-
$options[:cleanup_mat_sizes] = cleanup_mat_sizes
|
143
|
-
end
|
144
|
-
|
145
|
-
opts.on("--maximize-material-sizes", "Maximize material sizes") do |maximize_mat_sizes|
|
146
|
-
$options[:maximize_mat_sizes] = maximize_mat_sizes
|
147
|
-
end
|
148
|
-
|
149
|
-
opts.on("--overwrite", "Overwrite input file") do |overwrite|
|
150
|
-
$options[:overwrite] = overwrite
|
151
|
-
end
|
152
|
-
|
153
|
-
opts.on("--scale=SCALE", "Scales the model by a factor") do |scale|
|
154
|
-
$options[:scale] = scale.to_f
|
155
|
-
end
|
156
|
-
|
157
|
-
opts.on("--shift=SHIFT_VECTOR", "Shifts the model") do |shift|
|
158
|
-
$options[:shift] = eval(shift).to_a
|
159
|
-
end
|
160
|
-
|
161
|
-
opts.on("--reverse-tangents-byte-order=MESH_LIST", "Fixes the tangents import that was buggy, only use on bayo 2 imported meshes...") do |tan|
|
162
|
-
$options[:reverse_tangents] = eval(tan).to_a
|
163
|
-
end
|
164
|
-
|
165
|
-
opts.on("--[no-]recompute-relative-positions", "Recomputes relative bone positions...") do |recomp|
|
166
|
-
$options[:recompute_relative_positions] = recomp
|
167
|
-
end
|
168
|
-
|
169
|
-
opts.on("--set-pose=POSE_FILE", "Set model to the given pose") do |pose|
|
170
|
-
$options[:set_pose] = YAML::load_file(pose)
|
171
|
-
end
|
172
|
-
|
173
|
-
opts.on("--[no-]set-t-pose", "Set the model to a t pose (WMB3)") do |tpose|
|
174
|
-
$options[:set_tpose] = tpose
|
175
|
-
end
|
176
|
-
|
177
|
-
opts.on("--rotate=ROTATE_INFO", "Rotates the model.",
|
178
|
-
" ROTATE_INFO is either:",
|
179
|
-
" [rx, ry, rz] rotation (in radian) respectively around the x, y and z axis (in this order)",
|
180
|
-
" [[rx, ry, rz], [x, y, z]] with the center of the rotation specified" ) do |rotate|
|
181
|
-
$options[:rotate] = eval(rotate).to_a
|
182
|
-
end
|
183
|
-
|
184
|
-
opts.on("-h", "--help", "Prints this help") do
|
185
|
-
puts opts
|
186
|
-
exit
|
187
|
-
end
|
188
|
-
|
189
|
-
end.parse!
|
190
|
-
|
191
|
-
|
192
|
-
input_file = ARGV[0]
|
193
|
-
|
194
|
-
raise "Invalid file: #{input_file}" unless input_file && File::file?(input_file)
|
195
|
-
Dir.mkdir("wmb_output") unless Dir.exist?("wmb_output")
|
196
|
-
Dir.mkdir("wtb_output") unless Dir.exist?("wtb_output")
|
197
|
-
wmb = WMBFile::load(input_file)
|
198
|
-
wmb.check_normals if $options[:check_normals]
|
199
|
-
wmb.scale($options[:scale]) if $options[:scale]
|
200
|
-
wmb.rotate(*($options[:rotate])) if $options[:rotate]
|
201
|
-
wmb.shift(*($options[:shift])) if $options[:shift]
|
202
|
-
wmb.delete_batches($options[:delete_batches]) if $options[:delete_batches]
|
203
|
-
wmb.split_meshes($options[:split_meshes]) if $options[:split_meshes]
|
204
|
-
wmb.duplicate_meshes($options[:duplicate_meshes]) if $options[:duplicate_meshes]
|
205
|
-
wmb.move_meshes($options[:move_meshes]) if $options[:move_meshes]
|
206
|
-
wmb.swap_meshes($options[:swap_meshes]) if $options[:swap_meshes]
|
207
|
-
wmb.merge_meshes($options[:merge_meshes]) if $options[:merge_meshes]
|
208
|
-
wmb.dummy_meshes($options[:dummy_meshes]) if $options[:dummy_meshes]
|
209
|
-
wmb.delete_meshes($options[:delete_meshes]) if $options[:delete_meshes]
|
210
|
-
wmb.cleanup_bone_refs if $options[:bone_refs]
|
211
|
-
wmb.add_ancestors_bone_refs if $options[:submodel_bone_refs]
|
212
|
-
wmb.add_previous_bone_refs if $options[:previous_bone_refs]
|
213
|
-
wmb.cleanup_bones if $options[:bones]
|
214
|
-
wmb.recompute_relative_positions if $options[:recompute_relative_positions]
|
215
|
-
wmb.remove_duplicate_vertexes if $options[:remove_duplicate_vertexes]
|
216
|
-
wmb.normalize_vertex_usage if $options[:normalize_vertex_usage]
|
217
|
-
wmb.remove_triangle_strips if $options[:strips]
|
218
|
-
wmb.revert_triangles($options[:revert]) if $options[:revert]
|
219
|
-
wmb.cleanup_vertexes if $options[:vertexes]
|
220
|
-
wmb.remove_batch_vertex_offsets if $options[:offsets]
|
221
|
-
wmb.fix_ex_data if $options[:fix]
|
222
|
-
wmb.copy_uv12($options[:copy_uv]) if $options[:copy_uv]
|
223
|
-
wmb.reverse_tangents_byte_order($options[:reverse_tangents]) if $options[:reverse_tangents]
|
224
|
-
if $options[:set_pose]
|
225
|
-
exp_name = input_file.gsub(".wmb", ".exp")
|
226
|
-
exp = nil
|
227
|
-
if File::file?(exp_name)
|
228
|
-
exp = EXPFile::load(exp_name)
|
229
|
-
end
|
230
|
-
wmb.set_pose($options[:set_pose], exp)
|
231
|
-
end
|
232
|
-
if $options[:set_tpose]
|
233
|
-
wmb.set_tpose
|
234
|
-
end
|
235
|
-
wmb.delete_bones($options[:delete_bones]) if $options[:delete_bones]
|
236
|
-
wmb.remap_bones($options[:remap_bones]) if $options[:remap_bones]
|
237
|
-
wmb.order_bones if $options[:order_bones]
|
238
|
-
wmb.cleanup_materials if $options[:cleanup_mat]
|
239
|
-
wmb.cleanup_material_sizes if $options[:cleanup_mat_sizes]
|
240
|
-
wmb.maximize_material_sizes if $options[:maximize_mat_sizes]
|
241
|
-
wmb.cleanup_textures(input_file, $options[:overwrite]) if $options[:textures]
|
242
|
-
unless wmb.class == WMB3File
|
243
|
-
wmb.renumber_batches
|
244
|
-
end
|
245
|
-
wmb.recompute_layout
|
246
|
-
if $options[:overwrite]
|
247
|
-
wmb.dump(input_file, $options[:swap] ? !wmb.was_big? : wmb.was_big? )
|
248
|
-
else
|
249
|
-
wmb.dump("wmb_output/"+File.basename(input_file), $options[:swap] ? !wmb.was_big? : wmb.was_big? )
|
250
|
-
end
|
1
|
+
require 'optparse'
|
2
|
+
require 'yaml'
|
3
|
+
require_relative '../../bayonetta'
|
4
|
+
include Bayonetta
|
5
|
+
|
6
|
+
$options = {
|
7
|
+
:vertexes => false,
|
8
|
+
:bones => false,
|
9
|
+
:remap_bones => false,
|
10
|
+
:textures => false,
|
11
|
+
:cleanup_mat => false,
|
12
|
+
:cleanup_mat_sizes => false,
|
13
|
+
:maximize_mat_sizes => false,
|
14
|
+
:delete_bones => nil,
|
15
|
+
:offsets => false,
|
16
|
+
:fix => false,
|
17
|
+
:swap => nil,
|
18
|
+
:swap_meshes => nil,
|
19
|
+
:move_meshes => nil,
|
20
|
+
:delete_meshes => nil,
|
21
|
+
:delete_batches => nil,
|
22
|
+
:merge_meshes => nil,
|
23
|
+
:overwrite => nil
|
24
|
+
}
|
25
|
+
|
26
|
+
OptionParser.new do |opts|
|
27
|
+
opts.banner = "Usage: wmb_cleanup.rb target_file [options]"
|
28
|
+
|
29
|
+
opts.on("--[no-]bone-refs", "Cleanup bone refs in batches") do |bone_refs|
|
30
|
+
$options[:bone_refs] = bone_refs
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("--[no-]add-parents-bone-refs", "Add ancestry to bone refs and sort them") do |bone_refs|
|
34
|
+
$options[:submodel_bone_refs] = bone_refs
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("--[no-]add-previous-bone-refs", "Add all previous bones to bone refs and sort them") do |bone_refs|
|
38
|
+
$options[:previous_bone_refs] = bone_refs
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-b", "--[no-]bones", "Cleanup bones") do |bones|
|
42
|
+
$options[:bones] = bones
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("--remap-bones=BONEMAP", "Remaps specified local bones to global bone indexes") do |bone_map|
|
46
|
+
if File.exist?(bone_map)
|
47
|
+
$options[:remap_bones] = YAML::load_file(bone_map)
|
48
|
+
else
|
49
|
+
$options[:remap_bones] = eval(bone_map).to_h
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on("--[no-]order-bones", "Order bones in their global numbering if possible") do |order_bones|
|
54
|
+
$options[:order_bones] = order_bones
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on("-v", "--[no-]vertexes", "Cleanup vertexes") do |vertexes|
|
58
|
+
$options[:vertexes] = vertexes
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on("--[no-]remove_duplicate_vertexes", "Ensure no vertex is used more than once") do |rdv|
|
62
|
+
$options[:remove_duplicate_vertexes] = rdv
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on("--[no-]normalize-vertex-usage", "Ensure no vertex is used in more than 1 batch") do |nvu|
|
66
|
+
$options[:normalize_vertex_usage] = nvu
|
67
|
+
end
|
68
|
+
|
69
|
+
opts.on("-o", "--[no-]remove-batch-offsets", "Remove batch vertex offsets") do |o|
|
70
|
+
$options[:offsets] = o
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on("--[no-]check-normals", "Try to detect wide normals (Switch)") do |cn|
|
74
|
+
$options[:check_normals] = cn
|
75
|
+
end
|
76
|
+
|
77
|
+
opts.on("-f", "--[no-]fix-ex-data", "Put normal map u v in ex data") do |fix|
|
78
|
+
$options[:fix] = fix
|
79
|
+
end
|
80
|
+
|
81
|
+
opts.on("--copy-uv1to2=MESHLIST", "Copy the first UV mapping to the second one") do |copy_uv|
|
82
|
+
$options[:copy_uv] = eval(copy_uv).to_a
|
83
|
+
end
|
84
|
+
|
85
|
+
opts.on("--[no-]remove-triangle-strips", "Remove triangle strips and replace by triangles") do |strips|
|
86
|
+
$options[:strips] = strips
|
87
|
+
end
|
88
|
+
|
89
|
+
opts.on("--revert-triangles=MESHLIST", "Revert traiangle faces") do |revert|
|
90
|
+
$options[:revert] = eval(revert).to_a
|
91
|
+
end
|
92
|
+
|
93
|
+
opts.on("-e", "--swap-endianness", "Swap endianness") do |swap|
|
94
|
+
$options[:swap] = swap
|
95
|
+
end
|
96
|
+
|
97
|
+
opts.on("--duplicate-meshes=MESHLIST", "Duplicate specified meshes") do |mesh_list|
|
98
|
+
$options[:duplicate_meshes] = eval(mesh_list).to_a
|
99
|
+
end
|
100
|
+
|
101
|
+
opts.on("-s", "--swap-meshes=MESHHASH", "Swap specified meshes") do |mesh_hash|
|
102
|
+
$options[:swap_meshes] = eval(mesh_hash).to_h
|
103
|
+
end
|
104
|
+
|
105
|
+
opts.on("--merge-meshes=MESHHASH", "Merge specified meshes") do |mesh_hash|
|
106
|
+
$options[:merge_meshes] = eval(mesh_hash).to_h
|
107
|
+
end
|
108
|
+
|
109
|
+
opts.on("--move-meshes=MESHHASH", "Move the specified meshes to the specified positions") do |mesh_positions|
|
110
|
+
$options[:move_meshes] = eval(mesh_positions).to_h
|
111
|
+
end
|
112
|
+
|
113
|
+
opts.on("-m", "--delete-meshes=MESHLIST", "Delete specified meshes") do |mesh_list|
|
114
|
+
$options[:delete_meshes] = eval(mesh_list).to_a
|
115
|
+
end
|
116
|
+
|
117
|
+
opts.on("--delete-batches=BATCHLIST", "Delete specified batch list (WMB3) or { mesh => batch list } hash") do |batch_list|
|
118
|
+
$options[:delete_batches] = eval(batch_list).to_a
|
119
|
+
end
|
120
|
+
|
121
|
+
opts.on("--dummy=MESHHLIST", "Replace a given meshes by dummy mesh with one dummy batch") do |mesh_list|
|
122
|
+
$options[:dummy_meshes] = eval(mesh_list).to_a
|
123
|
+
end
|
124
|
+
|
125
|
+
opts.on("--split-meshes=MESHLIST", "Split the selected meshes into meshes containing only one batch") do |split_meshes|
|
126
|
+
$options[:split_meshes] = eval(split_meshes).to_a
|
127
|
+
end
|
128
|
+
|
129
|
+
opts.on("-d", "--delete-bones=BONELIST", "Delete specified bones") do |bone_list|
|
130
|
+
$options[:delete_bones] = eval(bone_list).to_a
|
131
|
+
end
|
132
|
+
|
133
|
+
opts.on("-t", "--[no-]textures", "Cleanup textures") do |textures|
|
134
|
+
$options[:textures] = textures
|
135
|
+
end
|
136
|
+
|
137
|
+
opts.on("-c", "--cleanup-materials", "Cleanup materials") do |cleanup_mat|
|
138
|
+
$options[:cleanup_mat] = cleanup_mat
|
139
|
+
end
|
140
|
+
|
141
|
+
opts.on("--cleanup-material-sizes", "Cleanup material sizes") do |cleanup_mat_sizes|
|
142
|
+
$options[:cleanup_mat_sizes] = cleanup_mat_sizes
|
143
|
+
end
|
144
|
+
|
145
|
+
opts.on("--maximize-material-sizes", "Maximize material sizes") do |maximize_mat_sizes|
|
146
|
+
$options[:maximize_mat_sizes] = maximize_mat_sizes
|
147
|
+
end
|
148
|
+
|
149
|
+
opts.on("--overwrite", "Overwrite input file") do |overwrite|
|
150
|
+
$options[:overwrite] = overwrite
|
151
|
+
end
|
152
|
+
|
153
|
+
opts.on("--scale=SCALE", "Scales the model by a factor") do |scale|
|
154
|
+
$options[:scale] = scale.to_f
|
155
|
+
end
|
156
|
+
|
157
|
+
opts.on("--shift=SHIFT_VECTOR", "Shifts the model") do |shift|
|
158
|
+
$options[:shift] = eval(shift).to_a
|
159
|
+
end
|
160
|
+
|
161
|
+
opts.on("--reverse-tangents-byte-order=MESH_LIST", "Fixes the tangents import that was buggy, only use on bayo 2 imported meshes...") do |tan|
|
162
|
+
$options[:reverse_tangents] = eval(tan).to_a
|
163
|
+
end
|
164
|
+
|
165
|
+
opts.on("--[no-]recompute-relative-positions", "Recomputes relative bone positions...") do |recomp|
|
166
|
+
$options[:recompute_relative_positions] = recomp
|
167
|
+
end
|
168
|
+
|
169
|
+
opts.on("--set-pose=POSE_FILE", "Set model to the given pose") do |pose|
|
170
|
+
$options[:set_pose] = YAML::load_file(pose)
|
171
|
+
end
|
172
|
+
|
173
|
+
opts.on("--[no-]set-t-pose", "Set the model to a t pose (WMB3)") do |tpose|
|
174
|
+
$options[:set_tpose] = tpose
|
175
|
+
end
|
176
|
+
|
177
|
+
opts.on("--rotate=ROTATE_INFO", "Rotates the model.",
|
178
|
+
" ROTATE_INFO is either:",
|
179
|
+
" [rx, ry, rz] rotation (in radian) respectively around the x, y and z axis (in this order)",
|
180
|
+
" [[rx, ry, rz], [x, y, z]] with the center of the rotation specified" ) do |rotate|
|
181
|
+
$options[:rotate] = eval(rotate).to_a
|
182
|
+
end
|
183
|
+
|
184
|
+
opts.on("-h", "--help", "Prints this help") do
|
185
|
+
puts opts
|
186
|
+
exit
|
187
|
+
end
|
188
|
+
|
189
|
+
end.parse!
|
190
|
+
|
191
|
+
|
192
|
+
input_file = ARGV[0]
|
193
|
+
|
194
|
+
raise "Invalid file: #{input_file}" unless input_file && File::file?(input_file)
|
195
|
+
Dir.mkdir("wmb_output") unless Dir.exist?("wmb_output")
|
196
|
+
Dir.mkdir("wtb_output") unless Dir.exist?("wtb_output")
|
197
|
+
wmb = WMBFile::load(input_file)
|
198
|
+
wmb.check_normals if $options[:check_normals]
|
199
|
+
wmb.scale($options[:scale]) if $options[:scale]
|
200
|
+
wmb.rotate(*($options[:rotate])) if $options[:rotate]
|
201
|
+
wmb.shift(*($options[:shift])) if $options[:shift]
|
202
|
+
wmb.delete_batches($options[:delete_batches]) if $options[:delete_batches]
|
203
|
+
wmb.split_meshes($options[:split_meshes]) if $options[:split_meshes]
|
204
|
+
wmb.duplicate_meshes($options[:duplicate_meshes]) if $options[:duplicate_meshes]
|
205
|
+
wmb.move_meshes($options[:move_meshes]) if $options[:move_meshes]
|
206
|
+
wmb.swap_meshes($options[:swap_meshes]) if $options[:swap_meshes]
|
207
|
+
wmb.merge_meshes($options[:merge_meshes]) if $options[:merge_meshes]
|
208
|
+
wmb.dummy_meshes($options[:dummy_meshes]) if $options[:dummy_meshes]
|
209
|
+
wmb.delete_meshes($options[:delete_meshes]) if $options[:delete_meshes]
|
210
|
+
wmb.cleanup_bone_refs if $options[:bone_refs]
|
211
|
+
wmb.add_ancestors_bone_refs if $options[:submodel_bone_refs]
|
212
|
+
wmb.add_previous_bone_refs if $options[:previous_bone_refs]
|
213
|
+
wmb.cleanup_bones if $options[:bones]
|
214
|
+
wmb.recompute_relative_positions if $options[:recompute_relative_positions]
|
215
|
+
wmb.remove_duplicate_vertexes if $options[:remove_duplicate_vertexes]
|
216
|
+
wmb.normalize_vertex_usage if $options[:normalize_vertex_usage]
|
217
|
+
wmb.remove_triangle_strips if $options[:strips]
|
218
|
+
wmb.revert_triangles($options[:revert]) if $options[:revert]
|
219
|
+
wmb.cleanup_vertexes if $options[:vertexes]
|
220
|
+
wmb.remove_batch_vertex_offsets if $options[:offsets]
|
221
|
+
wmb.fix_ex_data if $options[:fix]
|
222
|
+
wmb.copy_uv12($options[:copy_uv]) if $options[:copy_uv]
|
223
|
+
wmb.reverse_tangents_byte_order($options[:reverse_tangents]) if $options[:reverse_tangents]
|
224
|
+
if $options[:set_pose]
|
225
|
+
exp_name = input_file.gsub(".wmb", ".exp")
|
226
|
+
exp = nil
|
227
|
+
if File::file?(exp_name)
|
228
|
+
exp = EXPFile::load(exp_name)
|
229
|
+
end
|
230
|
+
wmb.set_pose($options[:set_pose], exp)
|
231
|
+
end
|
232
|
+
if $options[:set_tpose]
|
233
|
+
wmb.set_tpose
|
234
|
+
end
|
235
|
+
wmb.delete_bones($options[:delete_bones]) if $options[:delete_bones]
|
236
|
+
wmb.remap_bones($options[:remap_bones]) if $options[:remap_bones]
|
237
|
+
wmb.order_bones if $options[:order_bones]
|
238
|
+
wmb.cleanup_materials if $options[:cleanup_mat]
|
239
|
+
wmb.cleanup_material_sizes if $options[:cleanup_mat_sizes]
|
240
|
+
wmb.maximize_material_sizes if $options[:maximize_mat_sizes]
|
241
|
+
wmb.cleanup_textures(input_file, $options[:overwrite]) if $options[:textures]
|
242
|
+
unless wmb.class == WMB3File
|
243
|
+
wmb.renumber_batches
|
244
|
+
end
|
245
|
+
wmb.recompute_layout
|
246
|
+
if $options[:overwrite]
|
247
|
+
wmb.dump(input_file, $options[:swap] ? !wmb.was_big? : wmb.was_big? )
|
248
|
+
else
|
249
|
+
wmb.dump("wmb_output/"+File.basename(input_file), $options[:swap] ? !wmb.was_big? : wmb.was_big? )
|
250
|
+
end
|