pgtools 1.0.0 → 1.0.2

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 +474 -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/clp.rb CHANGED
@@ -1,212 +1,212 @@
1
- module Bayonetta
2
-
3
- class CLPFile < LibBin::Structure
4
-
5
- class FVector < LibBin::Structure
6
- float :x
7
- float :y
8
- float :z
9
-
10
- def from_bxm_vector(v)
11
- @x, @y, @z = v.split(" ").collect(&:to_f)
12
- self
13
- end
14
-
15
- def self.from_bxm_vector(v)
16
- nv = self::new
17
- nv.from_bxm_vector(v)
18
- nv
19
- end
20
-
21
- end
22
-
23
- class Header < LibBin::Structure
24
- int32 :num
25
- float :limit_spring_rate
26
- float :spd_rate
27
- float :stretchy
28
- int16 :bundle_num
29
- int16 :bundle_num_2
30
- float :thick
31
- register_field :gravity_vec, FVector
32
- int32 :gravity_parts_no
33
- float :first_bundle_rate
34
- register_field :wind_vec, FVector
35
- int32 :wind_parts_no
36
- register_field :wind_offset, FVector
37
- float :wind_sin
38
- float :hit_adjust_rate
39
-
40
- def from_bxm_header(h)
41
- @num = h.at_css("m_Num").content.to_i
42
- @limit_spring_rate = h.at_css("m_LimitSpringRate").content.to_f
43
- @spd_rate = h.at_css("m_SpdRate").content.to_f
44
- @stretchy = h.at_css("m_Stretchy").content.to_f
45
- @bundle_num = h.at_css("m_BundleNum").content.to_i
46
- @bundle_num_2 = h.at_css("m_BundleNum2").content.to_i
47
- @thick = h.at_css("m_Thick").content.to_f
48
- @gravity_vec = FVector.from_bxm_vector(h.at_css("m_GravityVec").content)
49
- @gravity_parts_no = h.at_css("m_GravityPartsNo").content.to_i
50
- @first_bundle_rate = h.at_css("m_FirstBundleRate").content.to_f
51
- @wind_vec = FVector.from_bxm_vector(h.at_css("m_WindVec").content)
52
- @wind_parts_no = h.at_css("m_WindPartsNo").content.to_i
53
- @wind_offset = FVector.from_bxm_vector(h.at_css("m_WindOffset").content)
54
- @wind_sin = h.at_css("m_WindSin").content.to_f
55
- @hit_adjust_rate = h.at_css("m_HitAdjustRate").content.to_f
56
- self
57
- end
58
-
59
- def self.from_bxm_header(h)
60
- nh = self::new
61
- nh.from_bxm_header(h)
62
- nh
63
- end
64
-
65
- end
66
-
67
- class Cloth < LibBin::Structure
68
- int16 :no
69
- int16 :no_up
70
- int16 :no_down
71
- int16 :no_side
72
- int16 :no_poly
73
- int16 :no_fix
74
- float :rot_limit
75
- register_field :offset, FVector
76
-
77
- def from_bxm_cloth(h)
78
- @no = h.at_css("no").content.to_i
79
- @no_up = h.at_css("noUp").content.to_i
80
- @no_down = h.at_css("noDown").content.to_i
81
- @no_side = h.at_css("noSide").content.to_i
82
- @no_poly = h.at_css("noPoly").content.to_i
83
- @no_fix = h.at_css("noFix").content.to_i
84
- @rot_limit = h.at_css("rotLimit").content.to_f
85
- @offset = FVector.from_bxm_vector(h.at_css("offset").content)
86
- self
87
- end
88
-
89
- def self.from_bxm_cloth(c)
90
- cl = self::new
91
- cl.from_bxm_cloth(c)
92
- cl
93
- end
94
-
95
- def remap(map, poly = true, fix = true)
96
- @no = check_and_remap_bone(map, @no)
97
- @no_up = check_and_remap_bone(map, @no_up)
98
- @no_down = check_and_remap_bone(map, @no_down)
99
- @no_side = check_and_remap_bone(map, @no_side)
100
- @no_poly = ( poly ? check_and_remap_bone(map, @no_poly) : 4095 )
101
- @no_fix = ( fix ? check_and_remap_bone(map, @no_fix) : 4095 )
102
- end
103
-
104
- private
105
- def check_and_remap_bone(map, no)
106
- tmp = map[no]
107
- raise "No bone found in map for #{no}!" unless tmp
108
- tmp
109
- end
110
-
111
- end
112
-
113
- register_field :header, Header
114
- register_field :cloth, Cloth, count: 'header\num'
115
-
116
- def was_big?
117
- @__was_big
118
- end
119
-
120
- def remap(map, poly = true, fix = true)
121
- @cloth.each { |c|
122
- c.remap(map, poly, fix)
123
- }
124
- end
125
-
126
- def self.load_bxm(input_name)
127
- bxm = BXMFile::load(input_name)
128
- clp = self::new
129
-
130
- doc = bxm.to_xml
131
- h = doc.at_css("//CLOTH//CLOTH_HEADER")
132
- clp.header = Header.from_bxm_header(h)
133
-
134
- clp.cloth = doc.css("//CLOTH//CLOTH_WK").collect { |c|
135
- Cloth.from_bxm_cloth(c)
136
- }
137
- clp
138
- end
139
-
140
- def self.is_big?(f)
141
- f.rewind
142
- f.size
143
- block = lambda { |int|
144
- num = f.read(4).unpack(int).first
145
- ( num >= 0 ) && ( num < 256 )
146
- }
147
- big = block.call("l>")
148
- f.rewind
149
- small = block.call("l<")
150
- f.rewind
151
- raise "Invalid data!" unless big ^ small
152
- return big
153
- end
154
-
155
- def self.convert(input_name, output_name, output_big = false)
156
- if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
157
- input = input_name
158
- else
159
- input = File.open(input_name, "rb")
160
- end
161
- input_big = is_big?(input)
162
-
163
- if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
164
- output = output_name
165
- else
166
- output = File.open(output_name, "wb")
167
- end
168
- output.rewind
169
-
170
- clp = self::new
171
- clp.instance_variable_set(:@__was_big, input_big)
172
- clp.__convert(input, output, input_big, output_big)
173
-
174
- input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
175
- output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
176
- clp
177
- end
178
-
179
- def self.load(input_name)
180
- if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
181
- input = input_name
182
- else
183
- input = File.open(input_name, "rb")
184
- end
185
- input_big = is_big?(input)
186
-
187
- clp = self::new
188
- clp.instance_variable_set(:@__was_big, input_big)
189
- clp.__load(input, input_big)
190
- input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
191
- clp
192
- end
193
-
194
- def dump(output_name, output_big = false)
195
- if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
196
- output = output_name
197
- else
198
- output = File.open(output_name, "wb")
199
- end
200
- output.rewind
201
-
202
- __set_dump_state(output, output_big, nil, nil)
203
- __dump_fields
204
- __unset_dump_state
205
-
206
- output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
207
- self
208
- end
209
-
210
- end
211
-
212
- end
1
+ module Bayonetta
2
+
3
+ class CLPFile < LibBin::Structure
4
+
5
+ class FVector < LibBin::Structure
6
+ float :x
7
+ float :y
8
+ float :z
9
+
10
+ def from_bxm_vector(v)
11
+ @x, @y, @z = v.split(" ").collect(&:to_f)
12
+ self
13
+ end
14
+
15
+ def self.from_bxm_vector(v)
16
+ nv = self::new
17
+ nv.from_bxm_vector(v)
18
+ nv
19
+ end
20
+
21
+ end
22
+
23
+ class Header < LibBin::Structure
24
+ int32 :num
25
+ float :limit_spring_rate
26
+ float :spd_rate
27
+ float :stretchy
28
+ int16 :bundle_num
29
+ int16 :bundle_num_2
30
+ float :thick
31
+ register_field :gravity_vec, FVector
32
+ int32 :gravity_parts_no
33
+ float :first_bundle_rate
34
+ register_field :wind_vec, FVector
35
+ int32 :wind_parts_no
36
+ register_field :wind_offset, FVector
37
+ float :wind_sin
38
+ float :hit_adjust_rate
39
+
40
+ def from_bxm_header(h)
41
+ @num = h.at_css("m_Num").content.to_i
42
+ @limit_spring_rate = h.at_css("m_LimitSpringRate").content.to_f
43
+ @spd_rate = h.at_css("m_SpdRate").content.to_f
44
+ @stretchy = h.at_css("m_Stretchy").content.to_f
45
+ @bundle_num = h.at_css("m_BundleNum").content.to_i
46
+ @bundle_num_2 = h.at_css("m_BundleNum2").content.to_i
47
+ @thick = h.at_css("m_Thick").content.to_f
48
+ @gravity_vec = FVector.from_bxm_vector(h.at_css("m_GravityVec").content)
49
+ @gravity_parts_no = h.at_css("m_GravityPartsNo").content.to_i
50
+ @first_bundle_rate = h.at_css("m_FirstBundleRate").content.to_f
51
+ @wind_vec = FVector.from_bxm_vector(h.at_css("m_WindVec").content)
52
+ @wind_parts_no = h.at_css("m_WindPartsNo").content.to_i
53
+ @wind_offset = FVector.from_bxm_vector(h.at_css("m_WindOffset").content)
54
+ @wind_sin = h.at_css("m_WindSin").content.to_f
55
+ @hit_adjust_rate = h.at_css("m_HitAdjustRate").content.to_f
56
+ self
57
+ end
58
+
59
+ def self.from_bxm_header(h)
60
+ nh = self::new
61
+ nh.from_bxm_header(h)
62
+ nh
63
+ end
64
+
65
+ end
66
+
67
+ class Cloth < LibBin::Structure
68
+ int16 :no
69
+ int16 :no_up
70
+ int16 :no_down
71
+ int16 :no_side
72
+ int16 :no_poly
73
+ int16 :no_fix
74
+ float :rot_limit
75
+ register_field :offset, FVector
76
+
77
+ def from_bxm_cloth(h)
78
+ @no = h.at_css("no").content.to_i
79
+ @no_up = h.at_css("noUp").content.to_i
80
+ @no_down = h.at_css("noDown").content.to_i
81
+ @no_side = h.at_css("noSide").content.to_i
82
+ @no_poly = h.at_css("noPoly").content.to_i
83
+ @no_fix = h.at_css("noFix").content.to_i
84
+ @rot_limit = h.at_css("rotLimit").content.to_f
85
+ @offset = FVector.from_bxm_vector(h.at_css("offset").content)
86
+ self
87
+ end
88
+
89
+ def self.from_bxm_cloth(c)
90
+ cl = self::new
91
+ cl.from_bxm_cloth(c)
92
+ cl
93
+ end
94
+
95
+ def remap(map, poly = true, fix = true)
96
+ @no = check_and_remap_bone(map, @no)
97
+ @no_up = check_and_remap_bone(map, @no_up)
98
+ @no_down = check_and_remap_bone(map, @no_down)
99
+ @no_side = check_and_remap_bone(map, @no_side)
100
+ @no_poly = ( poly ? check_and_remap_bone(map, @no_poly) : 4095 )
101
+ @no_fix = ( fix ? check_and_remap_bone(map, @no_fix) : 4095 )
102
+ end
103
+
104
+ private
105
+ def check_and_remap_bone(map, no)
106
+ tmp = map[no]
107
+ raise "No bone found in map for #{no}!" unless tmp
108
+ tmp
109
+ end
110
+
111
+ end
112
+
113
+ register_field :header, Header
114
+ register_field :cloth, Cloth, count: 'header\num'
115
+
116
+ def was_big?
117
+ @__was_big
118
+ end
119
+
120
+ def remap(map, poly = true, fix = true)
121
+ @cloth.each { |c|
122
+ c.remap(map, poly, fix)
123
+ }
124
+ end
125
+
126
+ def self.load_bxm(input_name)
127
+ bxm = BXMFile::load(input_name)
128
+ clp = self::new
129
+
130
+ doc = bxm.to_xml
131
+ h = doc.at_css("//CLOTH//CLOTH_HEADER")
132
+ clp.header = Header.from_bxm_header(h)
133
+
134
+ clp.cloth = doc.css("//CLOTH//CLOTH_WK").collect { |c|
135
+ Cloth.from_bxm_cloth(c)
136
+ }
137
+ clp
138
+ end
139
+
140
+ def self.is_big?(f)
141
+ f.rewind
142
+ f.size
143
+ block = lambda { |int|
144
+ num = f.read(4).unpack(int).first
145
+ ( num >= 0 ) && ( num < 256 )
146
+ }
147
+ big = block.call("l>")
148
+ f.rewind
149
+ small = block.call("l<")
150
+ f.rewind
151
+ raise "Invalid data!" unless big ^ small
152
+ return big
153
+ end
154
+
155
+ def self.convert(input_name, output_name, output_big = false)
156
+ if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
157
+ input = input_name
158
+ else
159
+ input = File.open(input_name, "rb")
160
+ end
161
+ input_big = is_big?(input)
162
+
163
+ if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
164
+ output = output_name
165
+ else
166
+ output = File.open(output_name, "wb")
167
+ end
168
+ output.rewind
169
+
170
+ clp = self::new
171
+ clp.instance_variable_set(:@__was_big, input_big)
172
+ clp.__convert(input, output, input_big, output_big)
173
+
174
+ input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
175
+ output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
176
+ clp
177
+ end
178
+
179
+ def self.load(input_name)
180
+ if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
181
+ input = input_name
182
+ else
183
+ input = File.open(input_name, "rb")
184
+ end
185
+ input_big = is_big?(input)
186
+
187
+ clp = self::new
188
+ clp.instance_variable_set(:@__was_big, input_big)
189
+ clp.__load(input, input_big)
190
+ input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
191
+ clp
192
+ end
193
+
194
+ def dump(output_name, output_big = false)
195
+ if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
196
+ output = output_name
197
+ else
198
+ output = File.open(output_name, "wb")
199
+ end
200
+ output.rewind
201
+
202
+ __set_dump_state(output, output_big, nil, nil)
203
+ __dump_fields
204
+ __unset_dump_state
205
+
206
+ output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
207
+ self
208
+ end
209
+
210
+ end
211
+
212
+ end