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
79 position: common.Vector3,
\r
85 self.english_name=english_name
\r
86 self.position=position
\r
87 self.parent_index=parent_index
\r
91 def getConnectionFlag(self) -> int:
\r
92 return self.flag & 0x0001
\r
94 def getIkFlag(self) -> int:
\r
95 return (self.flag & 0x0020) >> 5
\r
97 def getRotationFlag(self) -> int:
\r
98 return (self.flag & 0x0100) >> 8
\r
100 def getTranslationFlag(self) -> int:
\r
101 return (self.flag & 0x0200) >> 9
\r
103 def getFixedAxisFlag(self) -> int:
\r
104 return (self.flag & 0x0400) >> 10
\r
106 def getLocalCoordinateFlag(self) -> int:
\r
107 return (self.flag & 0x0800) >> 11
\r
109 def getExternalParentDeformFlag(self) -> int:
\r
110 return (self.flag & 0x2000) >> 13
\r
113 class Material(object):
\r
116 Attributes: see __init__
\r
130 'sphia_texture_index',
\r
132 'toon_sharing_flag',
\r
133 'toon_texture_index',
\r
140 diffuse_color: common.RGB,
\r
141 diffuse_alpha: float,
\r
142 specular_color: common.RGB,
\r
143 specular_factor: float,
\r
144 ambient_color: common.RGB,
\r
146 edge_color: common.RGBA,
\r
148 texture_index: int,
\r
149 sphia_texture_index: int,
\r
151 toon_sharing_flag: int
\r
154 self.english_name=english_name
\r
155 self.diffuse_color=diffuse_color
\r
156 self.diffuse_alpha=diffuse_alpha
\r
157 self.specular_color=specular_color
\r
158 self.specular_factor=specular_factor
\r
159 self.ambient_color=ambient_color
\r
161 self.edge_color=edge_color
\r
162 self.edge_size=edge_size
\r
163 self.texture_index=texture_index
\r
164 self.sphia_texture_index=sphia_texture_index
\r
165 self.sphia_mode=sphia_mode
\r
166 self.toon_sharing_flag=toon_sharing_flag
\r
168 self.toon_texture_index=None
\r
173 class Deform(object):
\r
177 class Bdef1(object):
\r
178 """bone deform. use a weight
\r
180 Attributes: see __init__
\r
182 __slots__=[ 'bone_index']
\r
183 def __init__(self, bone_index: int):
\r
184 self.bone_index=bone_index
\r
187 class Bdef2(object):
\r
188 """bone deform. use two weights
\r
190 Attributes: see __init__
\r
192 __slots__=[ 'index0', 'index1', 'weight0']
\r
193 def __init__(self,
\r
199 self.weight0=weight0
\r
202 class Vertex(object):
\r
205 Attributes: see __init__
\r
207 __slots__=[ 'position', 'normal', 'uv', 'deform', 'edge_factor' ]
\r
208 def __init__(self,
\r
209 position: common.Vector3,
\r
210 normal: common.Vector3,
\r
211 uv: common.Vector2,
\r
213 edge_factor: float):
\r
214 self.position=position
\r
218 self.edge_factor=edge_factor
\r
221 class Morph(object):
\r
238 def __init__(self, name, english_name, panel, morph_type):
\r
240 self.english_name=english_name
\r
242 self.morph_type=morph_type
\r
246 class VerexMorphOffset(object):
\r
247 """pmx vertex morph offset
\r
251 position_offset: Vector3
\r
257 def __init__(self, vertex_index, position_offset):
\r
258 self.vertex_index=vertex_index
\r
259 self.position_offset=position_offset
\r
262 class DisplaySlot(object):
\r
263 """pmx display slot
\r
269 refrences: list of (ref_type, ref_index)
\r
277 def __init__(self, name, english_name, special_flag):
\r
279 self.english_name=english_name
\r
280 self.special_flag=special_flag
\r
284 class Shape(object):
\r
288 class SphereShape(Shape):
\r
289 __slots__=['radius']
\r
290 def __init__(self, radius):
\r
294 class CapsuleShape(Shape):
\r
295 __slots__=['short_radius', 'long_radius']
\r
296 def __init__(self, short_radius, long_radius):
\r
297 self.short_radius=short_radius
\r
298 self.long_radius=long_radius
\r
301 class BoxShape(Shape):
\r
302 __slots__=['x', 'y', 'z']
\r
303 def __init__(self, x, y, z):
\r
309 class RigidBodyParam(object):
\r
310 """pmx rigidbody param(for bullet)
\r
326 def __init__(self, mass,
\r
327 linear_damping, angular_damping, restitution, friction):
\r
329 self.linear_damping=linear_damping
\r
330 self.angular_damping=angular_damping
\r
331 self.restitution=restitution
\r
332 self.friction=friction
\r
335 class RigidBody(object):
\r
353 'no_collision_flag',
\r
376 self.english_name=english_name
\r
377 self.bone_index=bone_index
\r
378 self.collision_group=collision_group
\r
379 self.no_collision_flag=no_collision_flag
\r
381 self.shape=SphereShape(shape_size.x)
\r
382 elif shape_type==1:
\r
383 self.shape=BoxShape(shape_size.x, shape_size.y, shape_size.z)
\r
384 elif shape_type==2:
\r
385 self.shape=CapsuleShape(shape_size.x, shape_size.y)
\r
387 raise pymeshio.common.ParseException(
\r
388 "unknown shape_type: {0}".format(shape_type))
\r
389 self.param=RigidBodyParam(mass,
\r
390 linear_damping, angular_damping,
\r
391 restitution, friction)
\r
395 class Joint(object):
\r
406 translation_limit_min: Vector3
\r
407 translation_limit_max: Vector3
\r
408 rotation_limit_min: Vector3
\r
409 rotation_limit_max: Vector3
\r
410 spring_constant_translation: Vector3
\r
411 spring_constant_rotation: Vector3
\r
417 'rigidbody_index_a',
\r
418 'rigidbody_index_b',
\r
421 'translation_limit_min',
\r
422 'translation_limit_max',
\r
423 'rotation_limit_min',
\r
424 'rotation_limit_max',
\r
425 'spring_constant_translation',
\r
426 'spring_constant_rotation',
\r
428 def __init__(self, name, english_name,
\r
434 translation_limit_min,
\r
435 translation_limit_max,
\r
436 rotation_limit_min,
\r
437 rotation_limit_max,
\r
438 spring_constant_translation,
\r
439 spring_constant_rotation
\r
442 self.english_name=english_name
\r
443 self.joint_type=joint_type
\r
444 self.rigidbody_index_a=rigidbody_index_a
\r
445 self.rigidbody_index_b=rigidbody_index_b
\r
446 self.position=position
\r
447 self.rotation=rotation
\r
448 self.translation_limit_min=translation_limit_min
\r
449 self.translation_limit_max=translation_limit_max
\r
450 self.rotation_limit_min=rotation_limit_min
\r
451 self.rotation_limit_max=rotation_limit_max
\r
452 self.spring_constant_translation=spring_constant_translation
\r
453 self.spring_constant_rotation=spring_constant_rotation
\r
456 class Model(object):
\r
457 """pmx data representation
\r
460 version: pmx version(expected 2.0)
\r
475 'version', # pmx version
\r
476 'name', # model name
\r
477 'english_name', # model name in english
\r
478 'comment', # model comment
\r
479 'english_comment', # model comment in english
\r
490 def __init__(self, version):
\r
491 self.version=version
\r
493 self.english_name=''
\r
495 self.english_comment=''
\r
501 self.rigidbodies=[]
\r