MMDPmxParser.h 16 KB

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