1 #!/usr/bin/env python
\r
7 PMDEditor's Lib/PMX仕様/PMX仕様.txt
\r
9 __author__="ousttrue"
\r
11 __versioon__="1.0.0"
\r
17 from pymeshio import common
\r
30 def __init__(self, target_index, loop, limit_radian):
\r
31 self.target_index=target_index
\r
33 self.limit_radian=limit_radian
\r
37 class IkLink(object):
\r
46 def __init__(self, bone_index, limit_angle):
\r
47 self.bone_index=bone_index
\r
48 self.limit_angle=limit_angle
\r
85 self.english_name=english_name
\r
86 self.position=position
\r
87 self.parent_index=parent_index
\r
91 def __eq__(self, rhs):
\r
94 and self.english_name==rhs.english_name
\r
95 and self.position==rhs.position
\r
96 and self.parent_index==rhs.parent_index
\r
97 and self.layer==rhs.layer
\r
98 and self.flag==rhs.flag
\r
101 def getConnectionFlag(self):
\r
102 return self.flag & 0x0001
\r
104 def getIkFlag(self):
\r
105 return (self.flag & 0x0020) >> 5
\r
107 def getRotationFlag(self):
\r
108 return (self.flag & 0x0100) >> 8
\r
110 def getTranslationFlag(self):
\r
111 return (self.flag & 0x0200) >> 9
\r
113 def getFixedAxisFlag(self):
\r
114 return (self.flag & 0x0400) >> 10
\r
116 def getLocalCoordinateFlag(self):
\r
117 return (self.flag & 0x0800) >> 11
\r
119 def getExternalParentDeformFlag(self):
\r
120 return (self.flag & 0x2000) >> 13
\r
123 class Material(object):
\r
126 Attributes: see __init__
\r
140 'sphere_texture_index',
\r
142 'toon_sharing_flag',
\r
143 'toon_texture_index',
\r
159 sphere_texture_index,
\r
164 self.english_name=english_name
\r
165 self.diffuse_color=diffuse_color
\r
167 self.specular_color=specular_color
\r
168 self.specular_factor=specular_factor
\r
169 self.ambient_color=ambient_color
\r
171 self.edge_color=edge_color
\r
172 self.edge_size=edge_size
\r
173 self.texture_index=texture_index
\r
174 self.sphere_texture_index=sphere_texture_index
\r
175 self.sphere_mode=sphere_mode
\r
176 self.toon_sharing_flag=toon_sharing_flag
\r
178 self.toon_texture_index=None
\r
179 self.comment=name.__class__() # unicode
\r
180 self.vertex_count=0
\r
182 def __eq__(self, rhs):
\r
184 self.name==rhs.name
\r
185 and self.english_name==rhs.english_name
\r
186 and self.diffuse_color==rhs.diffuse_color
\r
187 and self.alpha==rhs.alpha
\r
188 and self.specular_color==rhs.specular_color
\r
189 and self.specular_factor==rhs.specular_factor
\r
190 and self.ambient_color==rhs.ambient_color
\r
191 and self.flag==rhs.flag
\r
192 and self.edge_color==rhs.edge_color
\r
193 and self.edge_size==rhs.edge_size
\r
194 and self.texture_index==rhs.texture_index
\r
195 and self.sphere_texture_index==rhs.sphere_texture_index
\r
196 and self.sphere_mode==rhs.sphere_mode
\r
197 and self.toon_sharing_flag==rhs.toon_sharing_flag
\r
198 and self.toon_texture_index==rhs.toon_texture_index
\r
199 and self.comment==rhs.comment
\r
200 and self.vertex_count==rhs.vertex_count
\r
204 return ("<pmx.Material {name}>".format(
\r
205 name=self.english_name
\r
209 class Deform(object):
\r
213 class Bdef1(object):
\r
214 """bone deform. use a weight
\r
216 Attributes: see __init__
\r
218 __slots__=[ 'index0']
\r
219 def __init__(self, index0):
\r
222 def __eq__(self, rhs):
\r
223 return self.index0==rhs.index0
\r
226 class Bdef2(object):
\r
227 """bone deform. use two weights
\r
229 Attributes: see __init__
\r
231 __slots__=[ 'index0', 'index1', 'weight0']
\r
232 def __init__(self,
\r
238 self.weight0=weight0
\r
240 def __eq__(self, rhs):
\r
242 self.index0==rhs.index0
\r
243 and self.index1==rhs.index1
\r
244 and self.weight0==rhs.weight0
\r
248 class Vertex(object):
\r
251 Attributes: see __init__
\r
253 __slots__=[ 'position', 'normal', 'uv', 'deform', 'edge_factor' ]
\r
254 def __init__(self,
\r
260 self.position=position
\r
264 self.edge_factor=edge_factor
\r
266 def __eq__(self, rhs):
\r
268 self.position==rhs.position
\r
269 and self.normal==rhs.normal
\r
270 and self.uv==rhs.uv
\r
271 and self.deform==rhs.deform
\r
272 and self.edge_factor==rhs.edge_factor
\r
276 class Morph(object):
\r
293 def __init__(self, name, english_name, panel, morph_type):
\r
295 self.english_name=english_name
\r
297 self.morph_type=morph_type
\r
300 def __eq__(self, rhs):
\r
302 self.name==rhs.name
\r
303 and self.english_name==rhs.english_name
\r
304 and self.panel==rhs.panel
\r
305 and self.morph_type==rhs.morph_type
\r
306 and self.offsets==rhs.offsets
\r
310 class VerexMorphOffset(object):
\r
311 """pmx vertex morph offset
\r
315 position_offset: Vector3
\r
321 def __init__(self, vertex_index, position_offset):
\r
322 self.vertex_index=vertex_index
\r
323 self.position_offset=position_offset
\r
325 def __eq__(self, rhs):
\r
327 self.vertex_index==rhs.vertex_index
\r
328 and self.position_offset==rhs.position_offset
\r
332 class DisplaySlot(object):
\r
333 """pmx display slot
\r
339 refrences: list of (ref_type, ref_index)
\r
347 def __init__(self, name, english_name, special_flag):
\r
349 self.english_name=english_name
\r
350 self.special_flag=special_flag
\r
353 def __eq__(self, rhs):
\r
355 self.name==rhs.name
\r
356 and self.english_name==rhs.english_name
\r
357 and self.special_flag==rhs.special_flag
\r
358 and self.refrences==rhs.refrences
\r
362 class RigidBodyParam(object):
\r
363 """pmx rigidbody param(for bullet)
\r
379 def __init__(self, mass,
\r
380 linear_damping, angular_damping, restitution, friction):
\r
382 self.linear_damping=linear_damping
\r
383 self.angular_damping=angular_damping
\r
384 self.restitution=restitution
\r
385 self.friction=friction
\r
387 def __eq__(self, rhs):
\r
389 self.mass==rhs.mass
\r
390 and self.linear_damping==rhs.linear_damping
\r
391 and self.angular_damping==rhs.angular_damping
\r
392 and self.restitution==rhs.restitution
\r
393 and self.friction==rhs.friction
\r
397 class RigidBody(object):
\r
405 no_collision_group:
\r
415 'no_collision_group',
\r
428 no_collision_group,
\r
441 self.english_name=english_name
\r
442 self.bone_index=bone_index
\r
443 self.collision_group=collision_group
\r
444 self.no_collision_group=no_collision_group
\r
445 self.shape_type=shape_type
\r
446 self.shape_size=shape_size
\r
447 self.shape_position=shape_position
\r
448 self.shape_rotation=shape_rotation
\r
449 self.param=RigidBodyParam(mass,
\r
450 linear_damping, angular_damping,
\r
451 restitution, friction)
\r
454 def __eq__(self, rhs):
\r
456 self.name==rhs.name
\r
457 and self.english_name==rhs.english_name
\r
458 and self.bone_index==rhs.bone_index
\r
459 and self.collision_group==rhs.collision_group
\r
460 and self.no_collision_group==rhs.no_collision_group
\r
461 and self.shape_type==rhs.shape_type
\r
462 and self.shape_size==rhs.shape_size
\r
463 and self.param==rhs.param
\r
464 and self.mode==rhs.mode
\r
468 class Joint(object):
\r
479 translation_limit_min: Vector3
\r
480 translation_limit_max: Vector3
\r
481 rotation_limit_min: Vector3
\r
482 rotation_limit_max: Vector3
\r
483 spring_constant_translation: Vector3
\r
484 spring_constant_rotation: Vector3
\r
490 'rigidbody_index_a',
\r
491 'rigidbody_index_b',
\r
494 'translation_limit_min',
\r
495 'translation_limit_max',
\r
496 'rotation_limit_min',
\r
497 'rotation_limit_max',
\r
498 'spring_constant_translation',
\r
499 'spring_constant_rotation',
\r
501 def __init__(self, name, english_name,
\r
507 translation_limit_min,
\r
508 translation_limit_max,
\r
509 rotation_limit_min,
\r
510 rotation_limit_max,
\r
511 spring_constant_translation,
\r
512 spring_constant_rotation
\r
515 self.english_name=english_name
\r
516 self.joint_type=joint_type
\r
517 self.rigidbody_index_a=rigidbody_index_a
\r
518 self.rigidbody_index_b=rigidbody_index_b
\r
519 self.position=position
\r
520 self.rotation=rotation
\r
521 self.translation_limit_min=translation_limit_min
\r
522 self.translation_limit_max=translation_limit_max
\r
523 self.rotation_limit_min=rotation_limit_min
\r
524 self.rotation_limit_max=rotation_limit_max
\r
525 self.spring_constant_translation=spring_constant_translation
\r
526 self.spring_constant_rotation=spring_constant_rotation
\r
528 def __eq__(self, rhs):
\r
530 self.name==rhs.name
\r
531 and self.english_name==rhs.english_name
\r
532 and self.joint_type==rhs.joint_type
\r
533 and self.rigidbody_index_a==rhs.rigidbody_index_a
\r
534 and self.rigidbody_index_b==rhs.rigidbody_index_b
\r
535 and self.position==rhs.position
\r
536 and self.rotation==rhs.rotation
\r
537 and self.translation_limit_min==rhs.translation_limit_min
\r
538 and self.translation_limit_max==rhs.translation_limit_max
\r
539 and self.rotation_limit_min==rhs.rotation_limit_min
\r
540 and self.rotation_limit_max==rhs.rotation_limit_max
\r
541 and self.spring_constant_translation==rhs.spring_constant_translation
\r
542 and self.spring_constant_rotation==rhs.spring_constant_rotation
\r
546 class Model(object):
\r
547 """pmx data representation
\r
550 version: pmx version(expected 2.0)
\r
565 'version', # pmx version
\r
566 'name', # model name
\r
567 'english_name', # model name in english
\r
568 'comment', # model comment
\r
569 'english_comment', # model comment in english
\r
580 def __init__(self, version):
\r
581 self.version=version
\r
583 self.english_name=''
\r
585 self.english_comment=''
\r
592 self.display_slots=[]
\r
593 self.rigidbodies=[]
\r
597 return ('<pmx-{version} "{name}" {vertices}vertices>'.format(
\r
598 version=self.version,
\r
599 name=self.english_name,
\r
600 vertices=len(self.vertices)
\r
603 def __eq__(self, rhs):
\r
605 self.version==rhs.version
\r
606 and self.name==rhs.name
\r
607 and self.english_name==rhs.english_name
\r
608 and self.comment==rhs.comment
\r
609 and self.english_comment==rhs.english_comment
\r
610 and self.vertices==rhs.vertices
\r
611 and self.indices==rhs.indices
\r
612 and self.textures==rhs.textures
\r
613 and self.materials==rhs.materials
\r
614 and self.bones==rhs.bones
\r
615 and self.morphs==rhs.morphs
\r
616 and self.display_slots==rhs.display_slots
\r
617 and self.rigidbodies==rhs.rigidbodies
\r
618 and self.joints==rhs.joints
\r