/src/assimp/code/AssetLib/MMD/MMDPmxParser.h
Line | Count | Source |
1 | | /* |
2 | | Open Asset Import Library (assimp) |
3 | | ---------------------------------------------------------------------- |
4 | | |
5 | | Copyright (c) 2006-2026, assimp team |
6 | | |
7 | | All rights reserved. |
8 | | |
9 | | Redistribution and use of this software in source and binary forms, |
10 | | with or without modification, are permitted provided that the |
11 | | following conditions are met: |
12 | | |
13 | | * Redistributions of source code must retain the above |
14 | | copyright notice, this list of conditions and the |
15 | | following disclaimer. |
16 | | |
17 | | * Redistributions in binary form must reproduce the above |
18 | | copyright notice, this list of conditions and the |
19 | | following disclaimer in the documentation and/or other |
20 | | materials provided with the distribution. |
21 | | |
22 | | * Neither the name of the assimp team, nor the names of its |
23 | | contributors may be used to endorse or promote products |
24 | | derived from this software without specific prior |
25 | | written permission of the assimp team. |
26 | | |
27 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
28 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
29 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30 | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
31 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
32 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
33 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
34 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
35 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
36 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
37 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | | |
39 | | ---------------------------------------------------------------------- |
40 | | */ |
41 | | #pragma once |
42 | | |
43 | | #include <vector> |
44 | | #include <string> |
45 | | #include <iostream> |
46 | | #include <fstream> |
47 | | #include <memory> |
48 | | #include <assimp/types.h> |
49 | | #include "MMDCpp14.h" |
50 | | |
51 | | namespace pmx |
52 | | { |
53 | | class PmxSetting |
54 | | { |
55 | | public: |
56 | | PmxSetting() |
57 | 0 | : encoding(0) |
58 | 0 | , uv(0) |
59 | 0 | , vertex_index_size(0) |
60 | 0 | , texture_index_size(0) |
61 | 0 | , material_index_size(0) |
62 | 0 | , bone_index_size(0) |
63 | 0 | , morph_index_size(0) |
64 | 0 | , rigidbody_index_size(0) |
65 | 0 | {} |
66 | | |
67 | | uint8_t encoding; |
68 | | uint8_t uv; |
69 | | uint8_t vertex_index_size; |
70 | | uint8_t texture_index_size; |
71 | | uint8_t material_index_size; |
72 | | uint8_t bone_index_size; |
73 | | uint8_t morph_index_size; |
74 | | uint8_t rigidbody_index_size; |
75 | | void Read(std::istream *stream); |
76 | | }; |
77 | | |
78 | | enum class PmxVertexSkinningType : uint8_t |
79 | | { |
80 | | BDEF1 = 0, |
81 | | BDEF2 = 1, |
82 | | BDEF4 = 2, |
83 | | SDEF = 3, |
84 | | QDEF = 4, |
85 | | }; |
86 | | |
87 | | class PmxVertexSkinning |
88 | | { |
89 | | public: |
90 | | virtual void Read(std::istream *stream, PmxSetting *setting) = 0; |
91 | 0 | virtual ~PmxVertexSkinning() = default; |
92 | | }; |
93 | | |
94 | | class PmxVertexSkinningBDEF1 : public PmxVertexSkinning |
95 | | { |
96 | | public: |
97 | | PmxVertexSkinningBDEF1() |
98 | 0 | : bone_index(0) |
99 | 0 | {} |
100 | | |
101 | | int bone_index; |
102 | | void Read(std::istream *stresam, PmxSetting *setting); |
103 | | }; |
104 | | |
105 | | class PmxVertexSkinningBDEF2 : public PmxVertexSkinning |
106 | | { |
107 | | public: |
108 | | PmxVertexSkinningBDEF2() |
109 | 0 | : bone_index1(0) |
110 | 0 | , bone_index2(0) |
111 | 0 | , bone_weight(0.0f) |
112 | 0 | {} |
113 | | |
114 | | int bone_index1; |
115 | | int bone_index2; |
116 | | float bone_weight; |
117 | | void Read(std::istream *stresam, PmxSetting *setting); |
118 | | }; |
119 | | |
120 | | class PmxVertexSkinningBDEF4 : public PmxVertexSkinning |
121 | | { |
122 | | public: |
123 | | PmxVertexSkinningBDEF4() |
124 | 0 | : bone_index1(0) |
125 | 0 | , bone_index2(0) |
126 | 0 | , bone_index3(0) |
127 | 0 | , bone_index4(0) |
128 | 0 | , bone_weight1(0.0f) |
129 | 0 | , bone_weight2(0.0f) |
130 | 0 | , bone_weight3(0.0f) |
131 | 0 | , bone_weight4(0.0f) |
132 | 0 | {} |
133 | | |
134 | | int bone_index1; |
135 | | int bone_index2; |
136 | | int bone_index3; |
137 | | int bone_index4; |
138 | | float bone_weight1; |
139 | | float bone_weight2; |
140 | | float bone_weight3; |
141 | | float bone_weight4; |
142 | | void Read(std::istream *stresam, PmxSetting *setting); |
143 | | }; |
144 | | |
145 | | class PmxVertexSkinningSDEF : public PmxVertexSkinning |
146 | | { |
147 | | public: |
148 | | PmxVertexSkinningSDEF() |
149 | 0 | : bone_index1(0) |
150 | 0 | , bone_index2(0) |
151 | 0 | , bone_weight(0.0f) |
152 | 0 | { |
153 | 0 | for (int i = 0; i < 3; ++i) { |
154 | 0 | sdef_c[i] = 0.0f; |
155 | 0 | sdef_r0[i] = 0.0f; |
156 | 0 | sdef_r1[i] = 0.0f; |
157 | 0 | } |
158 | 0 | } |
159 | | |
160 | | int bone_index1; |
161 | | int bone_index2; |
162 | | float bone_weight; |
163 | | float sdef_c[3]; |
164 | | float sdef_r0[3]; |
165 | | float sdef_r1[3]; |
166 | | void Read(std::istream *stresam, PmxSetting *setting); |
167 | | }; |
168 | | |
169 | | class PmxVertexSkinningQDEF : public PmxVertexSkinning |
170 | | { |
171 | | public: |
172 | | PmxVertexSkinningQDEF() |
173 | 0 | : bone_index1(0) |
174 | 0 | , bone_index2(0) |
175 | 0 | , bone_index3(0) |
176 | 0 | , bone_index4(0) |
177 | 0 | , bone_weight1(0.0f) |
178 | 0 | , bone_weight2(0.0f) |
179 | 0 | , bone_weight3(0.0f) |
180 | 0 | , bone_weight4(0.0f) |
181 | 0 | {} |
182 | | |
183 | | int bone_index1; |
184 | | int bone_index2; |
185 | | int bone_index3; |
186 | | int bone_index4; |
187 | | float bone_weight1; |
188 | | float bone_weight2; |
189 | | float bone_weight3; |
190 | | float bone_weight4; |
191 | | void Read(std::istream *stresam, PmxSetting *setting); |
192 | | }; |
193 | | |
194 | | class PmxVertex |
195 | | { |
196 | | public: |
197 | | PmxVertex() |
198 | 0 | : edge(0.0f) |
199 | 0 | { |
200 | 0 | uv[0] = uv[1] = 0.0f; |
201 | 0 | for (int i = 0; i < 3; ++i) { |
202 | 0 | position[i] = 0.0f; |
203 | 0 | normal[i] = 0.0f; |
204 | 0 | } |
205 | 0 | for (int i = 0; i < 4; ++i) { |
206 | 0 | for (int k = 0; k < 4; ++k) { |
207 | 0 | uva[i][k] = 0.0f; |
208 | 0 | } |
209 | 0 | } |
210 | 0 | } |
211 | | |
212 | | float position[3]; |
213 | | float normal[3]; |
214 | | float uv[2]; |
215 | | float uva[4][4]; |
216 | | PmxVertexSkinningType skinning_type; |
217 | | std::unique_ptr<PmxVertexSkinning> skinning; |
218 | | float edge; |
219 | | void Read(std::istream *stream, PmxSetting *setting); |
220 | | }; |
221 | | |
222 | | class PmxMaterial |
223 | | { |
224 | | public: |
225 | | PmxMaterial() |
226 | 0 | : specularlity(0.0f) |
227 | 0 | , flag(0) |
228 | 0 | , edge_size(0.0f) |
229 | 0 | , diffuse_texture_index(0) |
230 | 0 | , sphere_texture_index(0) |
231 | 0 | , sphere_op_mode(0) |
232 | 0 | , common_toon_flag(0) |
233 | 0 | , toon_texture_index(0) |
234 | 0 | , index_count(0) |
235 | 0 | { |
236 | 0 | for (int i = 0; i < 3; ++i) { |
237 | 0 | specular[i] = 0.0f; |
238 | 0 | ambient[i] = 0.0f; |
239 | 0 | edge_color[i] = 0.0f; |
240 | 0 | } |
241 | 0 | for (int i = 0; i < 4; ++i) { |
242 | 0 | diffuse[i] = 0.0f; |
243 | 0 | } |
244 | 0 | } |
245 | | |
246 | | std::string material_name; |
247 | | std::string material_english_name; |
248 | | float diffuse[4]; |
249 | | float specular[3]; |
250 | | float specularlity; |
251 | | float ambient[3]; |
252 | | uint8_t flag; |
253 | | float edge_color[4]; |
254 | | float edge_size; |
255 | | int diffuse_texture_index; |
256 | | int sphere_texture_index; |
257 | | uint8_t sphere_op_mode; |
258 | | uint8_t common_toon_flag; |
259 | | int toon_texture_index; |
260 | | std::string memo; |
261 | | int index_count; |
262 | | void Read(std::istream *stream, PmxSetting *setting); |
263 | | }; |
264 | | |
265 | | class PmxIkLink |
266 | | { |
267 | | public: |
268 | | PmxIkLink() |
269 | 0 | : link_target(0) |
270 | 0 | , angle_lock(0) |
271 | 0 | { |
272 | 0 | for (int i = 0; i < 3; ++i) { |
273 | 0 | max_radian[i] = 0.0f; |
274 | 0 | min_radian[i] = 0.0f; |
275 | 0 | } |
276 | 0 | } |
277 | | |
278 | | int link_target; |
279 | | uint8_t angle_lock; |
280 | | float max_radian[3]; |
281 | | float min_radian[3]; |
282 | | void Read(std::istream *stream, PmxSetting *settingn); |
283 | | }; |
284 | | |
285 | | class PmxBone |
286 | | { |
287 | | public: |
288 | | PmxBone() |
289 | 0 | : parent_index(0) |
290 | 0 | , level(0) |
291 | 0 | , bone_flag(0) |
292 | 0 | , target_index(0) |
293 | 0 | , grant_parent_index(0) |
294 | 0 | , grant_weight(0.0f) |
295 | 0 | , key(0) |
296 | 0 | , ik_target_bone_index(0) |
297 | 0 | , ik_loop(0) |
298 | 0 | , ik_loop_angle_limit(0.0f) |
299 | 0 | , ik_link_count(0) |
300 | 0 | { |
301 | 0 | for (int i = 0; i < 3; ++i) { |
302 | 0 | position[i] = 0.0f; |
303 | 0 | offset[i] = 0.0f; |
304 | 0 | lock_axis_orientation[i] = 0.0f; |
305 | 0 | local_axis_x_orientation[i] = 0.0f; |
306 | 0 | local_axis_y_orientation[i] = 0.0f; |
307 | 0 | } |
308 | 0 | } |
309 | | |
310 | | std::string bone_name; |
311 | | std::string bone_english_name; |
312 | | float position[3]; |
313 | | int parent_index; |
314 | | int level; |
315 | | uint16_t bone_flag; |
316 | | float offset[3]; |
317 | | int target_index; |
318 | | int grant_parent_index; |
319 | | float grant_weight; |
320 | | float lock_axis_orientation[3]; |
321 | | float local_axis_x_orientation[3]; |
322 | | float local_axis_y_orientation[3]; |
323 | | int key; |
324 | | int ik_target_bone_index; |
325 | | int ik_loop; |
326 | | float ik_loop_angle_limit; |
327 | | int ik_link_count; |
328 | | std::unique_ptr<PmxIkLink []> ik_links; |
329 | | void Read(std::istream *stream, PmxSetting *setting); |
330 | | }; |
331 | | |
332 | | enum class MorphType : uint8_t |
333 | | { |
334 | | Group = 0, |
335 | | Vertex = 1, |
336 | | Bone = 2, |
337 | | UV = 3, |
338 | | AdditionalUV1 = 4, |
339 | | AdditionalUV2 = 5, |
340 | | AdditionalUV3 = 6, |
341 | | AdditionalUV4 = 7, |
342 | | Matrial = 8, |
343 | | Flip = 9, |
344 | | Implus = 10, |
345 | | }; |
346 | | |
347 | | enum class MorphCategory : uint8_t |
348 | | { |
349 | | ReservedCategory = 0, |
350 | | Eyebrow = 1, |
351 | | Eye = 2, |
352 | | Mouth = 3, |
353 | | Other = 4, |
354 | | }; |
355 | | |
356 | | class PmxMorphOffset |
357 | | { |
358 | | public: |
359 | | void virtual Read(std::istream *stream, PmxSetting *setting) = 0; |
360 | | |
361 | 0 | virtual ~PmxMorphOffset() = default; |
362 | | }; |
363 | | |
364 | | class PmxMorphVertexOffset : public PmxMorphOffset |
365 | | { |
366 | | public: |
367 | | PmxMorphVertexOffset() |
368 | 0 | : vertex_index(0) |
369 | 0 | { |
370 | 0 | for (int i = 0; i < 3; ++i) { |
371 | 0 | position_offset[i] = 0.0f; |
372 | 0 | } |
373 | 0 | } |
374 | | int vertex_index; |
375 | | float position_offset[3]; |
376 | | void Read(std::istream *stream, PmxSetting *setting); //override; |
377 | | }; |
378 | | |
379 | | class PmxMorphUVOffset : public PmxMorphOffset |
380 | | { |
381 | | public: |
382 | | PmxMorphUVOffset() |
383 | 0 | : vertex_index(0) |
384 | 0 | { |
385 | 0 | for (int i = 0; i < 4; ++i) { |
386 | 0 | uv_offset[i] = 0.0f; |
387 | 0 | } |
388 | 0 | } |
389 | | int vertex_index; |
390 | | float uv_offset[4]; |
391 | | void Read(std::istream *stream, PmxSetting *setting); //override; |
392 | | }; |
393 | | |
394 | | class PmxMorphBoneOffset : public PmxMorphOffset |
395 | | { |
396 | | public: |
397 | | PmxMorphBoneOffset() |
398 | 0 | : bone_index(0) |
399 | 0 | { |
400 | 0 | for (int i = 0; i < 3; ++i) { |
401 | 0 | translation[i] = 0.0f; |
402 | 0 | } |
403 | 0 | for (int i = 0; i < 4; ++i) { |
404 | 0 | rotation[i] = 0.0f; |
405 | 0 | } |
406 | 0 | } |
407 | | int bone_index; |
408 | | float translation[3]; |
409 | | float rotation[4]; |
410 | | void Read(std::istream *stream, PmxSetting *setting); //override; |
411 | | }; |
412 | | |
413 | | class PmxMorphMaterialOffset : public PmxMorphOffset |
414 | | { |
415 | | public: |
416 | | PmxMorphMaterialOffset() |
417 | 0 | : specularity(0.0f) |
418 | 0 | , edge_size(0.0f) |
419 | 0 | { |
420 | 0 | for (int i = 0; i < 3; ++i) { |
421 | 0 | specular[i] = 0.0f; |
422 | 0 | ambient[i] = 0.0f; |
423 | 0 | } |
424 | 0 | for (int i = 0; i < 4; ++i) { |
425 | 0 | diffuse[i] = 0.0f; |
426 | 0 | edge_color[i] = 0.0f; |
427 | 0 | texture_argb[i] = 0.0f; |
428 | 0 | sphere_texture_argb[i] = 0.0f; |
429 | 0 | toon_texture_argb[i] = 0.0f; |
430 | 0 | } |
431 | 0 | } |
432 | | int material_index; |
433 | | uint8_t offset_operation; |
434 | | float diffuse[4]; |
435 | | float specular[3]; |
436 | | float specularity; |
437 | | float ambient[3]; |
438 | | float edge_color[4]; |
439 | | float edge_size; |
440 | | float texture_argb[4]; |
441 | | float sphere_texture_argb[4]; |
442 | | float toon_texture_argb[4]; |
443 | | void Read(std::istream *stream, PmxSetting *setting); //override; |
444 | | }; |
445 | | |
446 | | class PmxMorphGroupOffset : public PmxMorphOffset |
447 | | { |
448 | | public: |
449 | | PmxMorphGroupOffset() |
450 | 0 | : morph_index(0) |
451 | 0 | , morph_weight(0.0f) |
452 | 0 | {} |
453 | | int morph_index; |
454 | | float morph_weight; |
455 | | void Read(std::istream *stream, PmxSetting *setting); //override; |
456 | | }; |
457 | | |
458 | | class PmxMorphFlipOffset : public PmxMorphOffset |
459 | | { |
460 | | public: |
461 | | PmxMorphFlipOffset() |
462 | | : morph_index(0) |
463 | | , morph_value(0.0f) |
464 | 0 | {} |
465 | | int morph_index; |
466 | | float morph_value; |
467 | | void Read(std::istream *stream, PmxSetting *setting); //override; |
468 | | }; |
469 | | |
470 | | class PmxMorphImplusOffset : public PmxMorphOffset |
471 | | { |
472 | | public: |
473 | | PmxMorphImplusOffset() |
474 | | : rigid_body_index(0) |
475 | | , is_local(0) |
476 | 0 | { |
477 | 0 | for (int i = 0; i < 3; ++i) { |
478 | 0 | velocity[i] = 0.0f; |
479 | 0 | angular_torque[i] = 0.0f; |
480 | 0 | } |
481 | 0 | } |
482 | | int rigid_body_index; |
483 | | uint8_t is_local; |
484 | | float velocity[3]; |
485 | | float angular_torque[3]; |
486 | | void Read(std::istream *stream, PmxSetting *setting); //override; |
487 | | }; |
488 | | |
489 | | class PmxMorph |
490 | | { |
491 | | public: |
492 | | PmxMorph() |
493 | 0 | : offset_count(0) |
494 | 0 | { |
495 | 0 | } |
496 | | std::string morph_name; |
497 | | std::string morph_english_name; |
498 | | MorphCategory category; |
499 | | MorphType morph_type; |
500 | | int offset_count; |
501 | | std::unique_ptr<PmxMorphVertexOffset []> vertex_offsets; |
502 | | std::unique_ptr<PmxMorphUVOffset []> uv_offsets; |
503 | | std::unique_ptr<PmxMorphBoneOffset []> bone_offsets; |
504 | | std::unique_ptr<PmxMorphMaterialOffset []> material_offsets; |
505 | | std::unique_ptr<PmxMorphGroupOffset []> group_offsets; |
506 | | std::unique_ptr<PmxMorphFlipOffset []> flip_offsets; |
507 | | std::unique_ptr<PmxMorphImplusOffset []> implus_offsets; |
508 | | void Read(std::istream *stream, PmxSetting *setting); |
509 | | }; |
510 | | |
511 | | class PmxFrameElement |
512 | | { |
513 | | public: |
514 | | PmxFrameElement() |
515 | 0 | : element_target(0) |
516 | 0 | , index(0) |
517 | 0 | { |
518 | 0 | } |
519 | | uint8_t element_target; |
520 | | int index; |
521 | | void Read(std::istream *stream, PmxSetting *setting); |
522 | | }; |
523 | | |
524 | | class PmxFrame |
525 | | { |
526 | | public: |
527 | | PmxFrame() |
528 | 0 | : frame_flag(0) |
529 | 0 | , element_count(0) |
530 | 0 | { |
531 | 0 | } |
532 | | std::string frame_name; |
533 | | std::string frame_english_name; |
534 | | uint8_t frame_flag; |
535 | | int element_count; |
536 | | std::unique_ptr<PmxFrameElement []> elements; |
537 | | void Read(std::istream *stream, PmxSetting *setting); |
538 | | }; |
539 | | |
540 | | class PmxRigidBody |
541 | | { |
542 | | public: |
543 | | PmxRigidBody() |
544 | 0 | : target_bone(0) |
545 | 0 | , group(0) |
546 | 0 | , mask(0) |
547 | 0 | , shape(0) |
548 | 0 | , mass(0.0f) |
549 | 0 | , move_attenuation(0.0f) |
550 | 0 | , rotation_attenuation(0.0f) |
551 | 0 | , repulsion(0.0f) |
552 | 0 | , friction(0.0f) |
553 | 0 | , physics_calc_type(0) |
554 | 0 | { |
555 | 0 | for (int i = 0; i < 3; ++i) { |
556 | 0 | size[i] = 0.0f; |
557 | 0 | position[i] = 0.0f; |
558 | 0 | orientation[i] = 0.0f; |
559 | 0 | } |
560 | 0 | } |
561 | | std::string girid_body_name; |
562 | | std::string girid_body_english_name; |
563 | | int target_bone; |
564 | | uint8_t group; |
565 | | uint16_t mask; |
566 | | uint8_t shape; |
567 | | float size[3]; |
568 | | float position[3]; |
569 | | float orientation[3]; |
570 | | float mass; |
571 | | float move_attenuation; |
572 | | float rotation_attenuation; |
573 | | float repulsion; |
574 | | float friction; |
575 | | uint8_t physics_calc_type; |
576 | | void Read(std::istream *stream, PmxSetting *setting); |
577 | | }; |
578 | | |
579 | | enum class PmxJointType : uint8_t |
580 | | { |
581 | | Generic6DofSpring = 0, |
582 | | Generic6Dof = 1, |
583 | | Point2Point = 2, |
584 | | ConeTwist = 3, |
585 | | Slider = 5, |
586 | | Hinge = 6 |
587 | | }; |
588 | | |
589 | | class PmxJointParam |
590 | | { |
591 | | public: |
592 | | PmxJointParam() |
593 | 0 | : rigid_body1(0) |
594 | 0 | , rigid_body2(0) |
595 | 0 | { |
596 | 0 | for (int i = 0; i < 3; ++i) { |
597 | 0 | position[i] = 0.0f; |
598 | 0 | orientaiton[i] = 0.0f; |
599 | 0 | move_limitation_min[i] = 0.0f; |
600 | 0 | move_limitation_max[i] = 0.0f; |
601 | 0 | rotation_limitation_min[i] = 0.0f; |
602 | 0 | rotation_limitation_max[i] = 0.0f; |
603 | 0 | spring_move_coefficient[i] = 0.0f; |
604 | 0 | spring_rotation_coefficient[i] = 0.0f; |
605 | 0 | } |
606 | 0 | } |
607 | | int rigid_body1; |
608 | | int rigid_body2; |
609 | | float position[3]; |
610 | | float orientaiton[3]; |
611 | | float move_limitation_min[3]; |
612 | | float move_limitation_max[3]; |
613 | | float rotation_limitation_min[3]; |
614 | | float rotation_limitation_max[3]; |
615 | | float spring_move_coefficient[3]; |
616 | | float spring_rotation_coefficient[3]; |
617 | | void Read(std::istream *stream, PmxSetting *setting); |
618 | | }; |
619 | | |
620 | | class PmxJoint |
621 | | { |
622 | | public: |
623 | | std::string joint_name; |
624 | | std::string joint_english_name; |
625 | | PmxJointType joint_type; |
626 | | PmxJointParam param; |
627 | | void Read(std::istream *stream, PmxSetting *setting); |
628 | | }; |
629 | | |
630 | | enum PmxSoftBodyFlag : uint8_t |
631 | | { |
632 | | BLink = 0x01, |
633 | | Cluster = 0x02, |
634 | | Link = 0x04 |
635 | | }; |
636 | | |
637 | | class PmxAncherRigidBody |
638 | | { |
639 | | public: |
640 | | PmxAncherRigidBody() |
641 | | : related_rigid_body(0) |
642 | | , related_vertex(0) |
643 | | , is_near(false) |
644 | 0 | {} |
645 | | int related_rigid_body; |
646 | | int related_vertex; |
647 | | bool is_near; |
648 | | void Read(std::istream *stream, PmxSetting *setting); |
649 | | }; |
650 | | |
651 | | class PmxSoftBody |
652 | | { |
653 | | public: |
654 | | PmxSoftBody() |
655 | | : shape(0) |
656 | | , target_material(0) |
657 | | , group(0) |
658 | | , mask(0) |
659 | | , blink_distance(0) |
660 | | , cluster_count(0) |
661 | | , mass(0.0) |
662 | | , collisioni_margin(0.0) |
663 | | , aero_model(0) |
664 | | , VCF(0.0f) |
665 | | , DP(0.0f) |
666 | | , DG(0.0f) |
667 | | , LF(0.0f) |
668 | | , PR(0.0f) |
669 | | , VC(0.0f) |
670 | | , DF(0.0f) |
671 | | , MT(0.0f) |
672 | | , CHR(0.0f) |
673 | | , KHR(0.0f) |
674 | | , SHR(0.0f) |
675 | | , AHR(0.0f) |
676 | | , SRHR_CL(0.0f) |
677 | | , SKHR_CL(0.0f) |
678 | | , SSHR_CL(0.0f) |
679 | | , SR_SPLT_CL(0.0f) |
680 | | , SK_SPLT_CL(0.0f) |
681 | | , SS_SPLT_CL(0.0f) |
682 | | , V_IT(0) |
683 | | , P_IT(0) |
684 | | , D_IT(0) |
685 | | , C_IT(0) |
686 | | , LST(0.0f) |
687 | | , AST(0.0f) |
688 | | , VST(0.0f) |
689 | | , anchor_count(0) |
690 | | , pin_vertex_count(0) |
691 | 0 | {} |
692 | | std::string soft_body_name; |
693 | | std::string soft_body_english_name; |
694 | | uint8_t shape; |
695 | | int target_material; |
696 | | uint8_t group; |
697 | | uint16_t mask; |
698 | | PmxSoftBodyFlag flag; |
699 | | int blink_distance; |
700 | | int cluster_count; |
701 | | float mass; |
702 | | float collisioni_margin; |
703 | | int aero_model; |
704 | | float VCF; |
705 | | float DP; |
706 | | float DG; |
707 | | float LF; |
708 | | float PR; |
709 | | float VC; |
710 | | float DF; |
711 | | float MT; |
712 | | float CHR; |
713 | | float KHR; |
714 | | float SHR; |
715 | | float AHR; |
716 | | float SRHR_CL; |
717 | | float SKHR_CL; |
718 | | float SSHR_CL; |
719 | | float SR_SPLT_CL; |
720 | | float SK_SPLT_CL; |
721 | | float SS_SPLT_CL; |
722 | | int V_IT; |
723 | | int P_IT; |
724 | | int D_IT; |
725 | | int C_IT; |
726 | | float LST; |
727 | | float AST; |
728 | | float VST; |
729 | | int anchor_count; |
730 | | std::unique_ptr<PmxAncherRigidBody []> anchers; |
731 | | int pin_vertex_count; |
732 | | std::unique_ptr<int []> pin_vertices; |
733 | | AI_WONT_RETURN void Read(std::istream *stream, PmxSetting *setting) AI_WONT_RETURN_SUFFIX; |
734 | | }; |
735 | | |
736 | | class PmxModel |
737 | | { |
738 | | public: |
739 | | PmxModel() |
740 | 0 | : version(0.0f) |
741 | 0 | , vertex_count(0) |
742 | 0 | , index_count(0) |
743 | 0 | , texture_count(0) |
744 | 0 | , material_count(0) |
745 | 0 | , bone_count(0) |
746 | 0 | , morph_count(0) |
747 | 0 | , frame_count(0) |
748 | 0 | , rigid_body_count(0) |
749 | 0 | , joint_count(0) |
750 | 0 | , soft_body_count(0) |
751 | 0 | {} |
752 | | |
753 | | float version; |
754 | | PmxSetting setting; |
755 | | std::string model_name; |
756 | | std::string model_english_name; |
757 | | std::string model_comment; |
758 | | std::string model_english_comment; |
759 | | int vertex_count; |
760 | | std::unique_ptr<PmxVertex []> vertices; |
761 | | int index_count; |
762 | | std::unique_ptr<int []> indices; |
763 | | int texture_count; |
764 | | std::unique_ptr< std::string []> textures; |
765 | | int material_count; |
766 | | std::unique_ptr<PmxMaterial []> materials; |
767 | | int bone_count; |
768 | | std::unique_ptr<PmxBone []> bones; |
769 | | int morph_count; |
770 | | std::unique_ptr<PmxMorph []> morphs; |
771 | | int frame_count; |
772 | | std::unique_ptr<PmxFrame [] > frames; |
773 | | int rigid_body_count; |
774 | | std::unique_ptr<PmxRigidBody []> rigid_bodies; |
775 | | int joint_count; |
776 | | std::unique_ptr<PmxJoint []> joints; |
777 | | int soft_body_count; |
778 | | std::unique_ptr<PmxSoftBody []> soft_bodies; |
779 | | void Init(); |
780 | | void Read(std::istream *stream); |
781 | | //static std::unique_ptr<PmxModel> ReadFromFile(const char *filename); |
782 | | //static std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream); |
783 | | }; |
784 | | } |