MMDPmxParser.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. #pragma once
  2. #include <vector>
  3. #include <string>
  4. #include <iostream>
  5. #include <fstream>
  6. #include <memory>
  7. #include "MMDCpp14.h"
  8. namespace pmx
  9. {
  10. /// インデックス設定
  11. class PmxSetting
  12. {
  13. public:
  14. PmxSetting()
  15. : encoding(0)
  16. , uv(0)
  17. , vertex_index_size(0)
  18. , texture_index_size(0)
  19. , material_index_size(0)
  20. , bone_index_size(0)
  21. , morph_index_size(0)
  22. , rigidbody_index_size(0)
  23. {}
  24. /// エンコード方式
  25. uint8_t encoding;
  26. /// 追加UV数
  27. uint8_t uv;
  28. /// 頂点インデックスサイズ
  29. uint8_t vertex_index_size;
  30. /// テクスチャインデックスサイズ
  31. uint8_t texture_index_size;
  32. /// マテリアルインデックスサイズ
  33. uint8_t material_index_size;
  34. /// ボーンインデックスサイズ
  35. uint8_t bone_index_size;
  36. /// モーフインデックスサイズ
  37. uint8_t morph_index_size;
  38. /// 剛体インデックスサイズ
  39. uint8_t rigidbody_index_size;
  40. void Read(std::istream *stream);
  41. };
  42. /// 頂点スキニングタイプ
  43. enum class PmxVertexSkinningType : uint8_t
  44. {
  45. BDEF1 = 0,
  46. BDEF2 = 1,
  47. BDEF4 = 2,
  48. SDEF = 3,
  49. QDEF = 4,
  50. };
  51. /// 頂点スキニング
  52. class PmxVertexSkinning
  53. {
  54. public:
  55. virtual void Read(std::istream *stream, PmxSetting *setting) = 0;
  56. };
  57. class PmxVertexSkinningBDEF1 : public PmxVertexSkinning
  58. {
  59. public:
  60. PmxVertexSkinningBDEF1()
  61. : bone_index(0)
  62. {}
  63. int bone_index;
  64. void Read(std::istream *stresam, PmxSetting *setting);
  65. };
  66. class PmxVertexSkinningBDEF2 : public PmxVertexSkinning
  67. {
  68. public:
  69. PmxVertexSkinningBDEF2()
  70. : bone_index1(0)
  71. , bone_index2(0)
  72. , bone_weight(0.0f)
  73. {}
  74. int bone_index1;
  75. int bone_index2;
  76. float bone_weight;
  77. void Read(std::istream *stresam, PmxSetting *setting);
  78. };
  79. class PmxVertexSkinningBDEF4 : public PmxVertexSkinning
  80. {
  81. public:
  82. PmxVertexSkinningBDEF4()
  83. : bone_index1(0)
  84. , bone_index2(0)
  85. , bone_index3(0)
  86. , bone_index4(0)
  87. , bone_weight1(0.0f)
  88. , bone_weight2(0.0f)
  89. , bone_weight3(0.0f)
  90. , bone_weight4(0.0f)
  91. {}
  92. int bone_index1;
  93. int bone_index2;
  94. int bone_index3;
  95. int bone_index4;
  96. float bone_weight1;
  97. float bone_weight2;
  98. float bone_weight3;
  99. float bone_weight4;
  100. void Read(std::istream *stresam, PmxSetting *setting);
  101. };
  102. class PmxVertexSkinningSDEF : public PmxVertexSkinning
  103. {
  104. public:
  105. PmxVertexSkinningSDEF()
  106. : bone_index1(0)
  107. , bone_index2(0)
  108. , bone_weight(0.0f)
  109. {
  110. for (int i = 0; i < 3; ++i) {
  111. sdef_c[i] = 0.0f;
  112. sdef_r0[i] = 0.0f;
  113. sdef_r1[i] = 0.0f;
  114. }
  115. }
  116. int bone_index1;
  117. int bone_index2;
  118. float bone_weight;
  119. float sdef_c[3];
  120. float sdef_r0[3];
  121. float sdef_r1[3];
  122. void Read(std::istream *stresam, PmxSetting *setting);
  123. };
  124. class PmxVertexSkinningQDEF : public PmxVertexSkinning
  125. {
  126. public:
  127. PmxVertexSkinningQDEF()
  128. : bone_index1(0)
  129. , bone_index2(0)
  130. , bone_index3(0)
  131. , bone_index4(0)
  132. , bone_weight1(0.0f)
  133. , bone_weight2(0.0f)
  134. , bone_weight3(0.0f)
  135. , bone_weight4(0.0f)
  136. {}
  137. int bone_index1;
  138. int bone_index2;
  139. int bone_index3;
  140. int bone_index4;
  141. float bone_weight1;
  142. float bone_weight2;
  143. float bone_weight3;
  144. float bone_weight4;
  145. void Read(std::istream *stresam, PmxSetting *setting);
  146. };
  147. /// 頂点
  148. class PmxVertex
  149. {
  150. public:
  151. PmxVertex()
  152. : edge(0.0f)
  153. {
  154. uv[0] = uv[1] = 0.0f;
  155. for (int i = 0; i < 3; ++i) {
  156. position[i] = 0.0f;
  157. normal[i] = 0.0f;
  158. }
  159. for (int i = 0; i < 4; ++i) {
  160. for (int k = 0; k < 4; ++k) {
  161. uva[i][k] = 0.0f;
  162. }
  163. }
  164. }
  165. /// 位置
  166. float position[3];
  167. /// 法線
  168. float normal[3];
  169. /// テクスチャ座標
  170. float uv[2];
  171. /// 追加テクスチャ座標
  172. float uva[4][4];
  173. /// スキニングタイプ
  174. PmxVertexSkinningType skinning_type;
  175. /// スキニング
  176. std::unique_ptr<PmxVertexSkinning> skinning;
  177. /// エッジ倍率
  178. float edge;
  179. void Read(std::istream *stream, PmxSetting *setting);
  180. };
  181. /// マテリアル
  182. class PmxMaterial
  183. {
  184. public:
  185. PmxMaterial()
  186. : specularlity(0.0f)
  187. , flag(0)
  188. , edge_size(0.0f)
  189. , diffuse_texture_index(0)
  190. , sphere_texture_index(0)
  191. , sphere_op_mode(0)
  192. , common_toon_flag(0)
  193. , toon_texture_index(0)
  194. , index_count(0)
  195. {
  196. for (int i = 0; i < 3; ++i) {
  197. specular[i] = 0.0f;
  198. ambient[i] = 0.0f;
  199. edge_color[i] = 0.0f;
  200. }
  201. for (int i = 0; i < 4; ++i) {
  202. diffuse[i] = 0.0f;
  203. }
  204. }
  205. /// モデル名
  206. std::string material_name;
  207. /// モデル英名
  208. std::string material_english_name;
  209. /// 減衰色
  210. float diffuse[4];
  211. /// 光沢色
  212. float specular[3];
  213. /// 光沢度
  214. float specularlity;
  215. /// 環境色
  216. float ambient[3];
  217. /// 描画フラグ
  218. uint8_t flag;
  219. /// エッジ色
  220. float edge_color[4];
  221. /// エッジサイズ
  222. float edge_size;
  223. /// アルベドテクスチャインデックス
  224. int diffuse_texture_index;
  225. /// スフィアテクスチャインデックス
  226. int sphere_texture_index;
  227. /// スフィアテクスチャ演算モード
  228. uint8_t sphere_op_mode;
  229. /// 共有トゥーンフラグ
  230. uint8_t common_toon_flag;
  231. /// トゥーンテクスチャインデックス
  232. int toon_texture_index;
  233. /// メモ
  234. std::string memo;
  235. /// 頂点インデックス数
  236. int index_count;
  237. void Read(std::istream *stream, PmxSetting *setting);
  238. };
  239. /// リンク
  240. class PmxIkLink
  241. {
  242. public:
  243. PmxIkLink()
  244. : link_target(0)
  245. , angle_lock(0)
  246. {
  247. for (int i = 0; i < 3; ++i) {
  248. max_radian[i] = 0.0f;
  249. min_radian[i] = 0.0f;
  250. }
  251. }
  252. /// リンクボーンインデックス
  253. int link_target;
  254. /// 角度制限
  255. uint8_t angle_lock;
  256. /// 最大制限角度
  257. float max_radian[3];
  258. /// 最小制限角度
  259. float min_radian[3];
  260. void Read(std::istream *stream, PmxSetting *settingn);
  261. };
  262. /// ボーン
  263. class PmxBone
  264. {
  265. public:
  266. PmxBone()
  267. : parent_index(0)
  268. , level(0)
  269. , bone_flag(0)
  270. , target_index(0)
  271. , grant_parent_index(0)
  272. , grant_weight(0.0f)
  273. , key(0)
  274. , ik_target_bone_index(0)
  275. , ik_loop(0)
  276. , ik_loop_angle_limit(0.0f)
  277. , ik_link_count(0)
  278. {
  279. for (int i = 0; i < 3; ++i) {
  280. position[i] = 0.0f;
  281. offset[i] = 0.0f;
  282. lock_axis_orientation[i] = 0.0f;
  283. local_axis_x_orientation[i] = 0.0f;
  284. local_axis_y_orientation[i] = 0.0f;
  285. }
  286. }
  287. /// ボーン名
  288. std::string bone_name;
  289. /// ボーン英名
  290. std::string bone_english_name;
  291. /// 位置
  292. float position[3];
  293. /// 親ボーンインデックス
  294. int parent_index;
  295. /// 階層
  296. int level;
  297. /// ボーンフラグ
  298. uint16_t bone_flag;
  299. /// 座標オフセット(has Target)
  300. float offset[3];
  301. /// 接続先ボーンインデックス(not has Target)
  302. int target_index;
  303. /// 付与親ボーンインデックス
  304. int grant_parent_index;
  305. /// 付与率
  306. float grant_weight;
  307. /// 固定軸の方向
  308. float lock_axis_orientation[3];
  309. /// ローカル軸のX軸方向
  310. float local_axis_x_orientation[3];
  311. /// ローカル軸のY軸方向
  312. float local_axis_y_orientation[3];
  313. /// 外部親変形のkey値
  314. int key;
  315. /// IKターゲットボーン
  316. int ik_target_bone_index;
  317. /// IKループ回数
  318. int ik_loop;
  319. /// IKループ計算時の角度制限(ラジアン)
  320. float ik_loop_angle_limit;
  321. /// IKリンク数
  322. int ik_link_count;
  323. /// IKリンク
  324. std::unique_ptr<PmxIkLink []> ik_links;
  325. void Read(std::istream *stream, PmxSetting *setting);
  326. };
  327. enum class MorphType : uint8_t
  328. {
  329. Group = 0,
  330. Vertex = 1,
  331. Bone = 2,
  332. UV = 3,
  333. AdditionalUV1 = 4,
  334. AdditionalUV2 = 5,
  335. AdditionalUV3 = 6,
  336. AdditionalUV4 = 7,
  337. Matrial = 8,
  338. Flip = 9,
  339. Implus = 10,
  340. };
  341. enum class MorphCategory : uint8_t
  342. {
  343. ReservedCategory = 0,
  344. Eyebrow = 1,
  345. Eye = 2,
  346. Mouth = 3,
  347. Other = 4,
  348. };
  349. class PmxMorphOffset
  350. {
  351. public:
  352. void virtual Read(std::istream *stream, PmxSetting *setting) = 0;
  353. };
  354. class PmxMorphVertexOffset : public PmxMorphOffset
  355. {
  356. public:
  357. PmxMorphVertexOffset()
  358. : vertex_index(0)
  359. {
  360. for (int i = 0; i < 3; ++i) {
  361. position_offset[i] = 0.0f;
  362. }
  363. }
  364. int vertex_index;
  365. float position_offset[3];
  366. void Read(std::istream *stream, PmxSetting *setting); //override;
  367. };
  368. class PmxMorphUVOffset : public PmxMorphOffset
  369. {
  370. public:
  371. PmxMorphUVOffset()
  372. : vertex_index(0)
  373. {
  374. for (int i = 0; i < 4; ++i) {
  375. uv_offset[i] = 0.0f;
  376. }
  377. }
  378. int vertex_index;
  379. float uv_offset[4];
  380. void Read(std::istream *stream, PmxSetting *setting); //override;
  381. };
  382. class PmxMorphBoneOffset : public PmxMorphOffset
  383. {
  384. public:
  385. PmxMorphBoneOffset()
  386. : bone_index(0)
  387. {
  388. for (int i = 0; i < 3; ++i) {
  389. translation[i] = 0.0f;
  390. }
  391. for (int i = 0; i < 4; ++i) {
  392. rotation[i] = 0.0f;
  393. }
  394. }
  395. int bone_index;
  396. float translation[3];
  397. float rotation[4];
  398. void Read(std::istream *stream, PmxSetting *setting); //override;
  399. };
  400. class PmxMorphMaterialOffset : public PmxMorphOffset
  401. {
  402. public:
  403. PmxMorphMaterialOffset()
  404. : specularity(0.0f)
  405. , edge_size(0.0f)
  406. {
  407. for (int i = 0; i < 3; ++i) {
  408. specular[i] = 0.0f;
  409. ambient[i] = 0.0f;
  410. }
  411. for (int i = 0; i < 4; ++i) {
  412. diffuse[i] = 0.0f;
  413. edge_color[i] = 0.0f;
  414. texture_argb[i] = 0.0f;
  415. sphere_texture_argb[i] = 0.0f;
  416. toon_texture_argb[i] = 0.0f;
  417. }
  418. }
  419. int material_index;
  420. uint8_t offset_operation;
  421. float diffuse[4];
  422. float specular[3];
  423. float specularity;
  424. float ambient[3];
  425. float edge_color[4];
  426. float edge_size;
  427. float texture_argb[4];
  428. float sphere_texture_argb[4];
  429. float toon_texture_argb[4];
  430. void Read(std::istream *stream, PmxSetting *setting); //override;
  431. };
  432. class PmxMorphGroupOffset : public PmxMorphOffset
  433. {
  434. public:
  435. PmxMorphGroupOffset()
  436. : morph_index(0)
  437. , morph_weight(0.0f)
  438. {}
  439. int morph_index;
  440. float morph_weight;
  441. void Read(std::istream *stream, PmxSetting *setting); //override;
  442. };
  443. class PmxMorphFlipOffset : public PmxMorphOffset
  444. {
  445. public:
  446. PmxMorphFlipOffset()
  447. : morph_index(0)
  448. , morph_value(0.0f)
  449. {}
  450. int morph_index;
  451. float morph_value;
  452. void Read(std::istream *stream, PmxSetting *setting); //override;
  453. };
  454. class PmxMorphImplusOffset : public PmxMorphOffset
  455. {
  456. public:
  457. PmxMorphImplusOffset()
  458. : rigid_body_index(0)
  459. , is_local(0)
  460. {
  461. for (int i = 0; i < 3; ++i) {
  462. velocity[i] = 0.0f;
  463. angular_torque[i] = 0.0f;
  464. }
  465. }
  466. int rigid_body_index;
  467. uint8_t is_local;
  468. float velocity[3];
  469. float angular_torque[3];
  470. void Read(std::istream *stream, PmxSetting *setting); //override;
  471. };
  472. /// モーフ
  473. class PmxMorph
  474. {
  475. public:
  476. PmxMorph()
  477. : offset_count(0)
  478. {
  479. }
  480. /// モーフ名
  481. std::string morph_name;
  482. /// モーフ英名
  483. std::string morph_english_name;
  484. /// カテゴリ
  485. MorphCategory category;
  486. /// モーフタイプ
  487. MorphType morph_type;
  488. /// オフセット数
  489. int offset_count;
  490. /// 頂点モーフ配列
  491. std::unique_ptr<PmxMorphVertexOffset []> vertex_offsets;
  492. /// UVモーフ配列
  493. std::unique_ptr<PmxMorphUVOffset []> uv_offsets;
  494. /// ボーンモーフ配列
  495. std::unique_ptr<PmxMorphBoneOffset []> bone_offsets;
  496. /// マテリアルモーフ配列
  497. std::unique_ptr<PmxMorphMaterialOffset []> material_offsets;
  498. /// グループモーフ配列
  499. std::unique_ptr<PmxMorphGroupOffset []> group_offsets;
  500. /// フリップモーフ配列
  501. std::unique_ptr<PmxMorphFlipOffset []> flip_offsets;
  502. /// インパルスモーフ配列
  503. std::unique_ptr<PmxMorphImplusOffset []> implus_offsets;
  504. void Read(std::istream *stream, PmxSetting *setting);
  505. };
  506. /// 枠内要素
  507. class PmxFrameElement
  508. {
  509. public:
  510. PmxFrameElement()
  511. : element_target(0)
  512. , index(0)
  513. {
  514. }
  515. /// 要素対象
  516. uint8_t element_target;
  517. /// 要素対象インデックス
  518. int index;
  519. void Read(std::istream *stream, PmxSetting *setting);
  520. };
  521. /// 表示枠
  522. class PmxFrame
  523. {
  524. public:
  525. PmxFrame()
  526. : frame_flag(0)
  527. , element_count(0)
  528. {
  529. }
  530. /// 枠名
  531. std::string frame_name;
  532. /// 枠英名
  533. std::string frame_english_name;
  534. /// 特殊枠フラグ
  535. uint8_t frame_flag;
  536. /// 枠内要素数
  537. int element_count;
  538. /// 枠内要素配列
  539. std::unique_ptr<PmxFrameElement []> elements;
  540. void Read(std::istream *stream, PmxSetting *setting);
  541. };
  542. class PmxRigidBody
  543. {
  544. public:
  545. PmxRigidBody()
  546. : target_bone(0)
  547. , group(0)
  548. , mask(0)
  549. , shape(0)
  550. , mass(0.0f)
  551. , move_attenuation(0.0f)
  552. , rotation_attenuation(0.0f)
  553. , repulsion(0.0f)
  554. , friction(0.0f)
  555. , physics_calc_type(0)
  556. {
  557. for (int i = 0; i < 3; ++i) {
  558. size[i] = 0.0f;
  559. position[i] = 0.0f;
  560. orientation[i] = 0.0f;
  561. }
  562. }
  563. /// 剛体名
  564. std::string girid_body_name;
  565. /// 剛体英名
  566. std::string girid_body_english_name;
  567. /// 関連ボーンインデックス
  568. int target_bone;
  569. /// グループ
  570. uint8_t group;
  571. /// マスク
  572. uint16_t mask;
  573. /// 形状
  574. uint8_t shape;
  575. float size[3];
  576. float position[3];
  577. float orientation[3];
  578. float mass;
  579. float move_attenuation;
  580. float rotation_attenuation;
  581. float repulsion;
  582. float friction;
  583. uint8_t physics_calc_type;
  584. void Read(std::istream *stream, PmxSetting *setting);
  585. };
  586. enum class PmxJointType : uint8_t
  587. {
  588. Generic6DofSpring = 0,
  589. Generic6Dof = 1,
  590. Point2Point = 2,
  591. ConeTwist = 3,
  592. Slider = 5,
  593. Hinge = 6
  594. };
  595. class PmxJointParam
  596. {
  597. public:
  598. PmxJointParam()
  599. : rigid_body1(0)
  600. , rigid_body2(0)
  601. {
  602. for (int i = 0; i < 3; ++i) {
  603. position[i] = 0.0f;
  604. orientaiton[i] = 0.0f;
  605. move_limitation_min[i] = 0.0f;
  606. move_limitation_max[i] = 0.0f;
  607. rotation_limitation_min[i] = 0.0f;
  608. rotation_limitation_max[i] = 0.0f;
  609. spring_move_coefficient[i] = 0.0f;
  610. spring_rotation_coefficient[i] = 0.0f;
  611. }
  612. }
  613. int rigid_body1;
  614. int rigid_body2;
  615. float position[3];
  616. float orientaiton[3];
  617. float move_limitation_min[3];
  618. float move_limitation_max[3];
  619. float rotation_limitation_min[3];
  620. float rotation_limitation_max[3];
  621. float spring_move_coefficient[3];
  622. float spring_rotation_coefficient[3];
  623. void Read(std::istream *stream, PmxSetting *setting);
  624. };
  625. class PmxJoint
  626. {
  627. public:
  628. std::string joint_name;
  629. std::string joint_english_name;
  630. PmxJointType joint_type;
  631. PmxJointParam param;
  632. void Read(std::istream *stream, PmxSetting *setting);
  633. };
  634. enum PmxSoftBodyFlag : uint8_t
  635. {
  636. BLink = 0x01,
  637. Cluster = 0x02,
  638. Link = 0x04
  639. };
  640. class PmxAncherRigidBody
  641. {
  642. public:
  643. PmxAncherRigidBody()
  644. : related_rigid_body(0)
  645. , related_vertex(0)
  646. , is_near(false)
  647. {}
  648. int related_rigid_body;
  649. int related_vertex;
  650. bool is_near;
  651. void Read(std::istream *stream, PmxSetting *setting);
  652. };
  653. class PmxSoftBody
  654. {
  655. public:
  656. PmxSoftBody()
  657. : shape(0)
  658. , target_material(0)
  659. , group(0)
  660. , mask(0)
  661. , blink_distance(0)
  662. , cluster_count(0)
  663. , mass(0.0)
  664. , collisioni_margin(0.0)
  665. , aero_model(0)
  666. , VCF(0.0f)
  667. , DP(0.0f)
  668. , DG(0.0f)
  669. , LF(0.0f)
  670. , PR(0.0f)
  671. , VC(0.0f)
  672. , DF(0.0f)
  673. , MT(0.0f)
  674. , CHR(0.0f)
  675. , KHR(0.0f)
  676. , SHR(0.0f)
  677. , AHR(0.0f)
  678. , SRHR_CL(0.0f)
  679. , SKHR_CL(0.0f)
  680. , SSHR_CL(0.0f)
  681. , SR_SPLT_CL(0.0f)
  682. , SK_SPLT_CL(0.0f)
  683. , SS_SPLT_CL(0.0f)
  684. , V_IT(0)
  685. , P_IT(0)
  686. , D_IT(0)
  687. , C_IT(0)
  688. , LST(0.0f)
  689. , AST(0.0f)
  690. , VST(0.0f)
  691. , anchor_count(0)
  692. , pin_vertex_count(0)
  693. {}
  694. std::string soft_body_name;
  695. std::string soft_body_english_name;
  696. uint8_t shape;
  697. int target_material;
  698. uint8_t group;
  699. uint16_t mask;
  700. PmxSoftBodyFlag flag;
  701. int blink_distance;
  702. int cluster_count;
  703. float mass;
  704. float collisioni_margin;
  705. int aero_model;
  706. float VCF;
  707. float DP;
  708. float DG;
  709. float LF;
  710. float PR;
  711. float VC;
  712. float DF;
  713. float MT;
  714. float CHR;
  715. float KHR;
  716. float SHR;
  717. float AHR;
  718. float SRHR_CL;
  719. float SKHR_CL;
  720. float SSHR_CL;
  721. float SR_SPLT_CL;
  722. float SK_SPLT_CL;
  723. float SS_SPLT_CL;
  724. int V_IT;
  725. int P_IT;
  726. int D_IT;
  727. int C_IT;
  728. float LST;
  729. float AST;
  730. float VST;
  731. int anchor_count;
  732. std::unique_ptr<PmxAncherRigidBody []> anchers;
  733. int pin_vertex_count;
  734. std::unique_ptr<int []> pin_vertices;
  735. void Read(std::istream *stream, PmxSetting *setting);
  736. };
  737. /// PMXモデル
  738. class PmxModel
  739. {
  740. public:
  741. PmxModel()
  742. : version(0.0f)
  743. , vertex_count(0)
  744. , index_count(0)
  745. , texture_count(0)
  746. , material_count(0)
  747. , bone_count(0)
  748. , morph_count(0)
  749. , frame_count(0)
  750. , rigid_body_count(0)
  751. , joint_count(0)
  752. , soft_body_count(0)
  753. {}
  754. /// バージョン
  755. float version;
  756. /// 設定
  757. PmxSetting setting;
  758. /// モデル名
  759. std::string model_name;
  760. /// モデル英名
  761. std::string model_english_name;
  762. /// コメント
  763. std::string model_comment;
  764. /// 英語コメント
  765. std::string model_english_comment;
  766. /// 頂点数
  767. int vertex_count;
  768. /// 頂点配列
  769. std::unique_ptr<PmxVertex []> vertices;
  770. /// インデックス数
  771. int index_count;
  772. /// インデックス配列
  773. std::unique_ptr<int []> indices;
  774. /// テクスチャ数
  775. int texture_count;
  776. /// テクスチャ配列
  777. std::unique_ptr< std::string []> textures;
  778. /// マテリアル数
  779. int material_count;
  780. /// マテリアル
  781. std::unique_ptr<PmxMaterial []> materials;
  782. /// ボーン数
  783. int bone_count;
  784. /// ボーン配列
  785. std::unique_ptr<PmxBone []> bones;
  786. /// モーフ数
  787. int morph_count;
  788. /// モーフ配列
  789. std::unique_ptr<PmxMorph []> morphs;
  790. /// 表示枠数
  791. int frame_count;
  792. /// 表示枠配列
  793. std::unique_ptr<PmxFrame [] > frames;
  794. /// 剛体数
  795. int rigid_body_count;
  796. /// 剛体配列
  797. std::unique_ptr<PmxRigidBody []> rigid_bodies;
  798. /// ジョイント数
  799. int joint_count;
  800. /// ジョイント配列
  801. std::unique_ptr<PmxJoint []> joints;
  802. /// ソフトボディ数
  803. int soft_body_count;
  804. /// ソフトボディ配列
  805. std::unique_ptr<PmxSoftBody []> soft_bodies;
  806. /// モデル初期化
  807. void Init();
  808. /// モデル読み込み
  809. void Read(std::istream *stream);
  810. ///// ファイルからモデルの読み込み
  811. //static std::unique_ptr<PmxModel> ReadFromFile(const char *filename);
  812. ///// 入力ストリームからモデルの読み込み
  813. //static std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream);
  814. };
  815. }