3 * MMD
\82Ì
\83\82\83f
\83\8b\83f
\81[
\83^
\81B
\83o
\83C
\83i
\83\8a\8c`
\8e®
\82Å
\82Ð
\82Æ
\82Â
\82Ì
\92¸
\93_
\82ª
\8dÅ
\91å
\82Q
\82Â
\82Ü
\82Å
\82Ì
\83{
\81[
\83\93\82Ì
4 *
\83E
\83F
\83C
\83g
\82ð
\95Û
\8e\9d\82·
\82é
\92P
\88ê
\82Ì
\92¸
\93_
\94z
\97ñ
\82Æ
\92¸
\93_
\83C
\83\93\83f
\83b
\83N
\83X
\94z
\97ñ
\82ð
\82à
\82Â
\81B
\96Ê
\82Í
5 *
\8eO
\8ap
\8c`
\82Ì
\82Ý
\81B
6 *
\82Ü
\82½
\95\
\8fî
\83\82\81[
\83t
\83B
\83\93\83O
\8fî
\95ñ
\81A
\95¨
\97\9d\89\89\8eZ
\8cü
\82¯
\82Ì
\8d\84\91Ì
\8fî
\95ñ
\82Æ
\8dS
\91©
\8fî
\95ñ
\82È
\82Ç
\82ð
\82à
\82Â
\81B
18 *
\92¸
\93_
\96@
\90ü
\82ª
\8ai
\94[
\8dÏ
\82Ý
\81B
20 *
\83\81\83b
\83V
\83\85
21 *
\8dÅ
\91å
\92¸
\93_
\90\94
22 *
\8dÅ
\91å
\8eO
\8ap
\8c`
\90\94
24 *
\97 \96Ê
\82Ì
\88µ
\82¢
25 *
\83I
\83\8a\83W
\83i
\83\8b\82Å
\82Í
\83o
\83b
\83N
\83J
\83\8a\83\93\83O
\82ð
\82µ
\82Ä
\82¢
\82È
\82¢
\82Ì
\82Å
\82â
\82é
\8fê
\8d\87\82Í
\83\82\83f
\83\8b\8cÂ
\95Ê
\82É
26 *
\91Î
\89\9e\82ª
\95K
\97v
\81B
28 *
\8eQ
\8dl
\83T
\83C
\83g
29 * http://blog.goo.ne.jp/torisu_tetosuki/e/209ad341d3ece2b1b4df24abf619d6e4
32 #ifndef MESH_IO_PMD_H_INCLUDED
33 #define MESH_IO_PMD_H_INCLUDED
45 ////////////////////////////////////////////////////////////
47 ////////////////////////////////////////////////////////////
52 //!
\96@
\90ü
\83x
\83N
\83g
\83\8b
53 meshio::Vector3 normal;
54 //!
\83e
\83N
\83X
\83`
\83\83UV
56 //!
\83u
\83\8c\83\93\83f
\83B
\83\93\83O
\83{
\81[
\83\931
58 //!
\83u
\83\8c\83\93\83f
\83B
\83\93\83O
\83{
\81[
\83\932
60 //!
\83E
\83F
\83C
\83g[0 - 100]
61 unsigned char weight0;
63 unsigned char edge_flag;
66 inline std::ostream &operator<<(std::ostream &os, const Vertex &rhs)
71 << " normal:" << rhs.normal
73 << " bone0:" << rhs.bone0
74 << " bone1:" << rhs.bone1
75 << " weight0:" << (int)rhs.weight0
76 << " edge_flag:" << (int)rhs.edge_flag
83 ////////////////////////////////////////////////////////////
85 ////////////////////////////////////////////////////////////
89 meshio::fRGBA diffuse;
93 meshio::fRGB specular;
96 //!
\83g
\83D
\81[
\83\93\83e
\83N
\83X
\83`
\83\83
97 unsigned char toon_index;
100 //!
\96Ê
\92¸
\93_
\90\94
101 unsigned int vertex_count;
102 //!
\83e
\83N
\83X
\83`
\83\83
103 meshio::fixed_string<20> texture;
106 inline std::ostream &operator<<(std::ostream &os,
111 << " diffuse:" << rhs.diffuse
112 << " toon_index:" << (int)rhs.toon_index
113 << " flag:" << (int)rhs.flag
114 << " vertex_count:" << rhs.vertex_count
115 << " texture:" << rhs.texture
122 ////////////////////////////////////////////////////////////
124 ////////////////////////////////////////////////////////////
125 //!
\83{
\81[
\83\93\82Ì
\8eí
\97Þ
130 //
\89ñ
\93]
\82Æ
\88Ú
\93®
138 //
\89ñ
\93]
\89e
\8b¿
\89º
139 BONE_ROTATE_INFLUENCED,
152 meshio::fixed_string<20> name;
153 //!
\90e
\83{
\81[
\83\93
154 unsigned short parent_index;
155 //!
\8eq
\83{
\81[
\83\93
156 unsigned short tail_index;
157 //!
\83{
\81[
\83\93\8eí
\97Þ
159 //!
\89e
\8b¿IK
\83{
\81[
\83\93
160 unsigned short ik_index;
161 //
\83{
\81[
\83\93\8dÀ
\95W
164 meshio::fixed_string<20> english_name;
165 //!
\83{
\81[
\83\93\8aK
\91w
\8d\
\92z
\97p
167 meshio::Vector3 tail;
168 std::vector<Bone*> children;
169 unsigned short index;
172 : parent_index(-1), tail_index(-1), type(BONE_UNKNOWN), ik_index(-1), parent(0), index(-1)
176 inline std::ostream &operator<<(std::ostream &os,
181 << '"' << rhs.name << '"'
188 ////////////////////////////////////////////////////////////
190 ////////////////////////////////////////////////////////////
193 //! IK(IK
\83^
\81[
\83Q
\83b
\83g)
194 unsigned short index;
195 //! Target(
\83G
\83t
\83F
\83N
\83^
\81[)
196 unsigned short target;
197 //!
\83G
\83t
\83F
\83N
\83^
\82É
\98A
\93®
\82·
\82é
\83{
\81[
\83\93\90\94
198 unsigned char length;
199 //! IK
\92l1
\81BCCD-IK
\8e\8e\8ds
\89ñ
\90\94
200 unsigned short iterations;
201 //! IK
\92l2
\81BCCD-IK
\8e\8e\8ds
\88ê
\89ñ
\95Ó
\82è
\82Ì
\89e
\8b¿
\93x
203 //!
\83G
\83t
\83F
\83N
\83^
\82É
\98A
\93®
\82·
\82é
\83{
\81[
\83\93(
\8aî
\96{
\93I
\82É
\90e
\83{
\81[
\83\93\82É
\91k
\82é)
204 std::vector<unsigned short> children;
207 inline std::ostream &operator<<(std::ostream &os, const IK &rhs)
217 ////////////////////////////////////////////////////////////
219 ////////////////////////////////////////////////////////////
220 //!
\95\
\8fî
\82Ì
\8eí
\97Þ
223 //!
\83x
\81[
\83X
\95\
\8fî
237 meshio::fixed_string<20> name;
238 //!
\8eg
\97p
\82·
\82é
\92¸
\93_
\90\94
239 unsigned int vertex_count;
243 std::vector<unsigned int> indices;
245 std::vector<meshio::Vector3> pos_list;
247 meshio::fixed_string<20> english_name;
250 inline std::ostream &operator<<(std::ostream &os, const Morph &rhs)
254 << '"' << rhs.name << '"'
261 ////////////////////////////////////////////////////////////
262 //!
\83{
\81[
\83\93\95\
\8e¦
\98g
263 ////////////////////////////////////////////////////////////
266 meshio::fixed_string<50> name;
267 meshio::fixed_string<50> english_name;
270 ////////////////////////////////////////////////////////////
272 ////////////////////////////////////////////////////////////
280 //!
\83J
\83v
\83Z
\83\8b
283 //!
\8d\84\91Ì
\83^
\83C
\83v
286 //!
\83{
\81[
\83\93\82Æ
\93¯
\82¶
\93®
\82«
287 RIGIDBODY_KINEMATICS=0,
288 //!
\95¨
\97\9d\89\89\8eZ
290 //!
\95¨
\97\9d\89\89\8eZ
\8c\8b\89Ê
\82ð
\83{
\81[
\83\93\82É
\94½
\89f
\82·
\82é
291 RIGIDBODY_PHYSICS_WITH_BONE,
297 meshio::fixed_string<20> name;
298 //!
\8aÖ
\98A
\83{
\81[
\83\93(
\83{
\81[
\83\93\92Ç
\8f]
\82Æ
\83{
\81[
\83\93\88Ê
\92u
\8d\87\82í
\82¹
\82Å
\95K
\97v)
299 unsigned short boneIndex;
300 //!
\83O
\83\8b\81[
\83v
302 //!
\94ñ
\8fÕ
\93Ë
\83O
\83\8b\81[
\83v
303 unsigned short target;
305 SHAPE_TYPE shapeType;
311 meshio::Vector3 position;
312 meshio::Vector3 rotation;
315 //!
\95¨
\97\9d\89\89\8eZ
\83p
\83\89\83\81\81[
\83^(bullet)
317 float angularDamping;
320 //!
\8d\84\91Ì
\83^
\83C
\83v
321 PROCESS_TYPE processType;
324 //! Joint(
\95¨
\97\9d\89\89\8eZ
\82Å
\82ÌJoint
\82ÆConstraint
\82Í
\93¯
\82¶
\88Ó
\96¡)
328 meshio::fixed_string<20> name;
329 //!
\90Ú
\91±
\8d\84\91ÌA
331 //!
\90Ú
\91±
\8d\84\91ÌB
338 meshio::Vector3 constraintPosMin;
339 meshio::Vector3 constraintPosMax;
341 meshio::Vector3 constraintRotMin;
342 meshio::Vector3 constraintRotMax;
344 meshio::Vector3 springPos;
345 meshio::Vector3 springRot;
353 meshio::fixed_string<20> name;
354 meshio::fixed_string<256> comment;
355 std::vector<Vertex> vertices;
356 std::vector<unsigned short> indices;
357 std::vector<Material> materials;
358 std::vector<Bone> bones;
359 std::vector<IK> ik_list;
360 std::vector<Morph> morph_list;
361 std::vector<unsigned short> face_list;
362 std::vector<BoneGroup> bone_group_list;
363 std::vector<std::pair<unsigned short, unsigned char> > bone_display_list;
364 std::array<meshio::fixed_string<100>, 10> toon_textures;
365 std::vector<RigidBody> rigidbodies;
366 std::vector<Constraint> constraints;
368 meshio::fixed_string<20> english_name;
369 meshio::fixed_string<256> english_comment;
372 bool read(const char *path);
373 bool write(const char *path);
374 bool read(meshio::binary::IReader &reader);
375 bool write(meshio::binary::IWriter &writer);
378 inline std::ostream &operator<<(std::ostream &os, const IO &rhs)
381 << "<PMD " << rhs.name << std::endl
382 << rhs.comment << std::endl
383 << "[vertices] " << rhs.vertices.size() << std::endl
384 << "[indices] " << rhs.indices.size() << std::endl
385 << "[materials] " << rhs.materials.size() << std::endl
388 std::copy(rhs.materials.begin(), rhs.materials.end(),
389 std::ostream_iterator<Material>(os, ""));
392 << "[bones] " << rhs.bones.size() << std::endl
394 std::copy(rhs.bones.begin(), rhs.bones.end(),
395 std::ostream_iterator<Bone>(os, ""));
398 << "[ik] " << rhs.ik_list.size() << std::endl
400 std::copy(rhs.ik_list.begin(), rhs.ik_list.end(),
401 std::ostream_iterator<IK>(os, ""));
404 << "[morph] " << rhs.morph_list.size() << std::endl
406 std::copy(rhs.morph_list.begin(), rhs.morph_list.end(),
407 std::ostream_iterator<Morph>(os, ""));
419 } // namespace meshio
421 #endif // MESH_IO_PMD_H_INCLUDED