#!/usr/bin/env python\r
# coding: utf-8\r
"""\r
-pmx file io library.\r
+========================\r
+MikuMikuDance PMX format\r
+========================\r
+\r
+file format\r
+~~~~~~~~~~~\r
+* PMDEditor's Lib/PMX仕様/PMX仕様.txt\r
+\r
+specs\r
+~~~~~\r
+* textencoding: unicode\r
+* coordinate: left handed y-up(DirectX)\r
+* uv origin: \r
+* face: only triangle\r
+* backculling: \r
\r
-pmx file format:\r
- PMDEditor's Lib/PMX仕様/PMX仕様.txt\r
"""\r
__author__="ousttrue"\r
__license__="zlib"\r
layer,\r
flag\r
):\r
- self.name=name,\r
+ self.name=name\r
self.english_name=english_name\r
self.position=position\r
self.parent_index=parent_index\r
self.layer=layer\r
self.flag=flag\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.name==rhs.name\r
+ and self.english_name==rhs.english_name\r
+ and self.position==rhs.position\r
+ and self.parent_index==rhs.parent_index\r
+ and self.layer==rhs.layer\r
+ and self.flag==rhs.flag\r
+ )\r
+\r
def getConnectionFlag(self):\r
return self.flag & 0x0001\r
\r
'name',\r
'english_name',\r
'diffuse_color',\r
- 'diffuse_alpha',\r
+ 'alpha',\r
'specular_color',\r
'specular_factor',\r
'ambient_color',\r
'edge_color',\r
'edge_size',\r
'texture_index',\r
- 'sphia_texture_index',\r
- 'sphia_mode',\r
+ 'sphere_texture_index',\r
+ 'sphere_mode',\r
'toon_sharing_flag',\r
'toon_texture_index',\r
'comment',\r
name,\r
english_name,\r
diffuse_color,\r
- diffuse_alpha,\r
+ alpha,\r
specular_color,\r
specular_factor,\r
ambient_color,\r
edge_color,\r
edge_size,\r
texture_index,\r
- sphia_texture_index,\r
- sphia_mode,\r
+ sphere_texture_index,\r
+ sphere_mode,\r
toon_sharing_flag\r
):\r
self.name=name\r
self.english_name=english_name\r
self.diffuse_color=diffuse_color\r
- self.diffuse_alpha=diffuse_alpha\r
+ self.alpha=alpha\r
self.specular_color=specular_color\r
self.specular_factor=specular_factor\r
self.ambient_color=ambient_color\r
self.edge_color=edge_color\r
self.edge_size=edge_size\r
self.texture_index=texture_index\r
- self.sphia_texture_index=sphia_texture_index\r
- self.sphia_mode=sphia_mode\r
+ self.sphere_texture_index=sphere_texture_index\r
+ self.sphere_mode=sphere_mode\r
self.toon_sharing_flag=toon_sharing_flag\r
#\r
self.toon_texture_index=None\r
- self.comment=''\r
+ self.comment=name.__class__() # unicode\r
self.vertex_count=0\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.name==rhs.name\r
+ and self.english_name==rhs.english_name\r
+ and self.diffuse_color==rhs.diffuse_color\r
+ and self.alpha==rhs.alpha\r
+ and self.specular_color==rhs.specular_color\r
+ and self.specular_factor==rhs.specular_factor\r
+ and self.ambient_color==rhs.ambient_color\r
+ and self.flag==rhs.flag\r
+ and self.edge_color==rhs.edge_color\r
+ and self.edge_size==rhs.edge_size\r
+ and self.texture_index==rhs.texture_index\r
+ and self.sphere_texture_index==rhs.sphere_texture_index\r
+ and self.sphere_mode==rhs.sphere_mode\r
+ and self.toon_sharing_flag==rhs.toon_sharing_flag\r
+ and self.toon_texture_index==rhs.toon_texture_index\r
+ and self.comment==rhs.comment\r
+ and self.vertex_count==rhs.vertex_count\r
+ )\r
+\r
def __str__(self):\r
return ("<pmx.Material {name}>".format(\r
name=self.english_name\r
def __init__(self, index0):\r
self.index0=index0\r
\r
+ def __eq__(self, rhs):\r
+ return self.index0==rhs.index0\r
+\r
\r
class Bdef2(object):\r
"""bone deform. use two weights\r
self.index1=index1\r
self.weight0=weight0\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.index0==rhs.index0\r
+ and self.index1==rhs.index1\r
+ and self.weight0==rhs.weight0\r
+ )\r
+\r
\r
class Vertex(object):\r
"""pmx vertex\r
self.deform=deform\r
self.edge_factor=edge_factor\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.position==rhs.position\r
+ and self.normal==rhs.normal\r
+ and self.uv==rhs.uv\r
+ and self.deform==rhs.deform\r
+ and self.edge_factor==rhs.edge_factor\r
+ )\r
+\r
\r
class Morph(object):\r
"""pmx morph\r
self.morph_type=morph_type\r
self.offsets=[]\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.name==rhs.name\r
+ and self.english_name==rhs.english_name\r
+ and self.panel==rhs.panel\r
+ and self.morph_type==rhs.morph_type\r
+ and self.offsets==rhs.offsets\r
+ )\r
+\r
\r
class VerexMorphOffset(object):\r
"""pmx vertex morph offset\r
self.vertex_index=vertex_index\r
self.position_offset=position_offset\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.vertex_index==rhs.vertex_index \r
+ and self.position_offset==rhs.position_offset\r
+ )\r
+\r
\r
class DisplaySlot(object):\r
"""pmx display slot\r
self.special_flag=special_flag\r
self.refrences=[]\r
\r
-\r
-class Shape(object):\r
- pass\r
-\r
-\r
-class SphereShape(Shape):\r
- __slots__=['radius']\r
- def __init__(self, radius):\r
- self.radius=radius\r
-\r
-\r
-class CapsuleShape(Shape):\r
- __slots__=['short_radius', 'long_radius']\r
- def __init__(self, short_radius, long_radius): \r
- self.short_radius=short_radius\r
- self.long_radius=long_radius\r
-\r
-\r
-class BoxShape(Shape):\r
- __slots__=['x', 'y', 'z']\r
- def __init__(self, x, y, z):\r
- self.x=x\r
- self.y=y\r
- self.z=z\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.name==rhs.name\r
+ and self.english_name==rhs.english_name\r
+ and self.special_flag==rhs.special_flag\r
+ and self.refrences==rhs.refrences\r
+ )\r
\r
\r
class RigidBodyParam(object):\r
self.restitution=restitution\r
self.friction=friction\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.mass==rhs.mass\r
+ and self.linear_damping==rhs.linear_damping\r
+ and self.angular_damping==rhs.angular_damping\r
+ and self.restitution==rhs.restitution\r
+ and self.friction==rhs.friction\r
+ )\r
+\r
\r
class RigidBody(object):\r
"""pmx rigidbody\r
english_name: \r
bone_index:\r
collision_group:\r
- no_collision_flag:\r
+ no_collision_group:\r
shape:\r
param:\r
mode:\r
'english_name',\r
'bone_index',\r
'collision_group',\r
- 'no_collision_flag',\r
- 'shape',\r
+ 'no_collision_group',\r
+ 'shape_type',\r
+ 'shape_size',\r
+ 'shape_position',\r
+ 'shape_rotation',\r
'param',\r
'mode',\r
]\r
english_name,\r
bone_index,\r
collision_group,\r
- no_collision_flag,\r
+ no_collision_group,\r
shape_type,\r
shape_size,\r
shape_position,\r
self.english_name=english_name\r
self.bone_index=bone_index\r
self.collision_group=collision_group\r
- self.no_collision_flag=no_collision_flag\r
- if shape_type==0:\r
- self.shape=SphereShape(shape_size.x)\r
- elif shape_type==1:\r
- self.shape=BoxShape(shape_size.x, shape_size.y, shape_size.z)\r
- elif shape_type==2:\r
- self.shape=CapsuleShape(shape_size.x, shape_size.y)\r
- else:\r
- raise pymeshio.common.ParseException(\r
- "unknown shape_type: {0}".format(shape_type))\r
+ self.no_collision_group=no_collision_group\r
+ self.shape_type=shape_type\r
+ self.shape_size=shape_size\r
+ self.shape_position=shape_position\r
+ self.shape_rotation=shape_rotation\r
self.param=RigidBodyParam(mass,\r
linear_damping, angular_damping,\r
restitution, friction)\r
self.mode=mode\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.name==rhs.name\r
+ and self.english_name==rhs.english_name\r
+ and self.bone_index==rhs.bone_index\r
+ and self.collision_group==rhs.collision_group\r
+ and self.no_collision_group==rhs.no_collision_group\r
+ and self.shape_type==rhs.shape_type\r
+ and self.shape_size==rhs.shape_size\r
+ and self.param==rhs.param\r
+ and self.mode==rhs.mode\r
+ )\r
+\r
\r
class Joint(object):\r
"""pmx joint\r
self.spring_constant_translation=spring_constant_translation\r
self.spring_constant_rotation=spring_constant_rotation\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.name==rhs.name\r
+ and self.english_name==rhs.english_name\r
+ and self.joint_type==rhs.joint_type\r
+ and self.rigidbody_index_a==rhs.rigidbody_index_a\r
+ and self.rigidbody_index_b==rhs.rigidbody_index_b\r
+ and self.position==rhs.position\r
+ and self.rotation==rhs.rotation\r
+ and self.translation_limit_min==rhs.translation_limit_min\r
+ and self.translation_limit_max==rhs.translation_limit_max\r
+ and self.rotation_limit_min==rhs.rotation_limit_min\r
+ and self.rotation_limit_max==rhs.rotation_limit_max\r
+ and self.spring_constant_translation==rhs.spring_constant_translation\r
+ and self.spring_constant_rotation==rhs.spring_constant_rotation\r
+ )\r
+\r
\r
class Model(object):\r
"""pmx data representation\r
self.textures=[]\r
self.materials=[]\r
self.bones=[]\r
+ self.morphs=[]\r
+ self.display_slots=[]\r
self.rigidbodies=[]\r
self.joints=[]\r
\r
vertices=len(self.vertices)\r
))\r
\r
+ def __eq__(self, rhs):\r
+ return (\r
+ self.version==rhs.version\r
+ and self.name==rhs.name\r
+ and self.english_name==rhs.english_name\r
+ and self.comment==rhs.comment\r
+ and self.english_comment==rhs.english_comment\r
+ and self.vertices==rhs.vertices\r
+ and self.indices==rhs.indices\r
+ and self.textures==rhs.textures\r
+ and self.materials==rhs.materials\r
+ and self.bones==rhs.bones\r
+ and self.morphs==rhs.morphs\r
+ and self.display_slots==rhs.display_slots\r
+ and self.rigidbodies==rhs.rigidbodies\r
+ and self.joints==rhs.joints\r
+ )\r
+\r