X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;ds=sidebyside;f=pymeshio%2Fpmx%2F__init__.py;h=42b15f6a8685d2dafff36200b3ecf0fbda84394e;hb=cf6ec3e04ee67bbe635510486475961ed32e46f2;hp=d5665dcce136c31f7ec30e2ff47e7277b38e773a;hpb=1396b6606b794a2b5502af4973ec425ae6924d49;p=meshio%2Fpymeshio.git diff --git a/pymeshio/pmx/__init__.py b/pymeshio/pmx/__init__.py index d5665dc..42b15f6 100644 --- a/pymeshio/pmx/__init__.py +++ b/pymeshio/pmx/__init__.py @@ -81,13 +81,23 @@ class Bone(object): layer, flag ): - self.name=name, + self.name=name self.english_name=english_name self.position=position self.parent_index=parent_index self.layer=layer self.flag=flag + def __eq__(self, rhs): + return ( + self.name==rhs.name + and self.english_name==rhs.english_name + and self.position==rhs.position + and self.parent_index==rhs.parent_index + and self.layer==rhs.layer + and self.flag==rhs.flag + ) + def getConnectionFlag(self): return self.flag & 0x0001 @@ -119,7 +129,7 @@ class Material(object): 'name', 'english_name', 'diffuse_color', - 'diffuse_alpha', + 'alpha', 'specular_color', 'specular_factor', 'ambient_color', @@ -127,8 +137,8 @@ class Material(object): 'edge_color', 'edge_size', 'texture_index', - 'sphia_texture_index', - 'sphia_mode', + 'sphere_texture_index', + 'sphere_mode', 'toon_sharing_flag', 'toon_texture_index', 'comment', @@ -138,7 +148,7 @@ class Material(object): name, english_name, diffuse_color, - diffuse_alpha, + alpha, specular_color, specular_factor, ambient_color, @@ -146,14 +156,14 @@ class Material(object): edge_color, edge_size, texture_index, - sphia_texture_index, - sphia_mode, + sphere_texture_index, + sphere_mode, toon_sharing_flag ): self.name=name self.english_name=english_name self.diffuse_color=diffuse_color - self.diffuse_alpha=diffuse_alpha + self.alpha=alpha self.specular_color=specular_color self.specular_factor=specular_factor self.ambient_color=ambient_color @@ -161,14 +171,35 @@ class Material(object): self.edge_color=edge_color self.edge_size=edge_size self.texture_index=texture_index - self.sphia_texture_index=sphia_texture_index - self.sphia_mode=sphia_mode + self.sphere_texture_index=sphere_texture_index + self.sphere_mode=sphere_mode self.toon_sharing_flag=toon_sharing_flag # self.toon_texture_index=None - self.comment='' + self.comment=name.__class__() # unicode self.vertex_count=0 + def __eq__(self, rhs): + return ( + self.name==rhs.name + and self.english_name==rhs.english_name + and self.diffuse_color==rhs.diffuse_color + and self.alpha==rhs.alpha + and self.specular_color==rhs.specular_color + and self.specular_factor==rhs.specular_factor + and self.ambient_color==rhs.ambient_color + and self.flag==rhs.flag + and self.edge_color==rhs.edge_color + and self.edge_size==rhs.edge_size + and self.texture_index==rhs.texture_index + and self.sphere_texture_index==rhs.sphere_texture_index + and self.sphere_mode==rhs.sphere_mode + and self.toon_sharing_flag==rhs.toon_sharing_flag + and self.toon_texture_index==rhs.toon_texture_index + and self.comment==rhs.comment + and self.vertex_count==rhs.vertex_count + ) + def __str__(self): return ("".format( name=self.english_name @@ -188,6 +219,9 @@ class Bdef1(object): def __init__(self, index0): self.index0=index0 + def __eq__(self, rhs): + return self.index0==rhs.index0 + class Bdef2(object): """bone deform. use two weights @@ -203,6 +237,13 @@ class Bdef2(object): self.index1=index1 self.weight0=weight0 + def __eq__(self, rhs): + return ( + self.index0==rhs.index0 + and self.index1==rhs.index1 + and self.weight0==rhs.weight0 + ) + class Vertex(object): """pmx vertex @@ -222,6 +263,15 @@ class Vertex(object): self.deform=deform self.edge_factor=edge_factor + def __eq__(self, rhs): + return ( + self.position==rhs.position + and self.normal==rhs.normal + and self.uv==rhs.uv + and self.deform==rhs.deform + and self.edge_factor==rhs.edge_factor + ) + class Morph(object): """pmx morph @@ -247,6 +297,15 @@ class Morph(object): self.morph_type=morph_type self.offsets=[] + def __eq__(self, rhs): + return ( + self.name==rhs.name + and self.english_name==rhs.english_name + and self.panel==rhs.panel + and self.morph_type==rhs.morph_type + and self.offsets==rhs.offsets + ) + class VerexMorphOffset(object): """pmx vertex morph offset @@ -263,6 +322,12 @@ class VerexMorphOffset(object): self.vertex_index=vertex_index self.position_offset=position_offset + def __eq__(self, rhs): + return ( + self.vertex_index==rhs.vertex_index + and self.position_offset==rhs.position_offset + ) + class DisplaySlot(object): """pmx display slot @@ -285,30 +350,13 @@ class DisplaySlot(object): self.special_flag=special_flag self.refrences=[] - -class Shape(object): - pass - - -class SphereShape(Shape): - __slots__=['radius'] - def __init__(self, radius): - self.radius=radius - - -class CapsuleShape(Shape): - __slots__=['short_radius', 'long_radius'] - def __init__(self, short_radius, long_radius): - self.short_radius=short_radius - self.long_radius=long_radius - - -class BoxShape(Shape): - __slots__=['x', 'y', 'z'] - def __init__(self, x, y, z): - self.x=x - self.y=y - self.z=z + def __eq__(self, rhs): + return ( + self.name==rhs.name + and self.english_name==rhs.english_name + and self.special_flag==rhs.special_flag + and self.refrences==rhs.refrences + ) class RigidBodyParam(object): @@ -336,6 +384,15 @@ class RigidBodyParam(object): self.restitution=restitution self.friction=friction + def __eq__(self, rhs): + return ( + self.mass==rhs.mass + and self.linear_damping==rhs.linear_damping + and self.angular_damping==rhs.angular_damping + and self.restitution==rhs.restitution + and self.friction==rhs.friction + ) + class RigidBody(object): """pmx rigidbody @@ -356,7 +413,10 @@ class RigidBody(object): 'bone_index', 'collision_group', 'no_collision_group', - 'shape', + 'shape_type', + 'shape_size', + 'shape_position', + 'shape_rotation', 'param', 'mode', ] @@ -382,20 +442,28 @@ class RigidBody(object): self.bone_index=bone_index self.collision_group=collision_group self.no_collision_group=no_collision_group - if shape_type==0: - self.shape=SphereShape(shape_size.x) - elif shape_type==1: - self.shape=BoxShape(shape_size.x, shape_size.y, shape_size.z) - elif shape_type==2: - self.shape=CapsuleShape(shape_size.x, shape_size.y) - else: - raise pymeshio.common.ParseException( - "unknown shape_type: {0}".format(shape_type)) + self.shape_type=shape_type + self.shape_size=shape_size + self.shape_position=shape_position + self.shape_rotation=shape_rotation self.param=RigidBodyParam(mass, linear_damping, angular_damping, restitution, friction) self.mode=mode + def __eq__(self, rhs): + return ( + self.name==rhs.name + and self.english_name==rhs.english_name + and self.bone_index==rhs.bone_index + and self.collision_group==rhs.collision_group + and self.no_collision_group==rhs.no_collision_group + and self.shape_type==rhs.shape_type + and self.shape_size==rhs.shape_size + and self.param==rhs.param + and self.mode==rhs.mode + ) + class Joint(object): """pmx joint @@ -457,6 +525,23 @@ class Joint(object): self.spring_constant_translation=spring_constant_translation self.spring_constant_rotation=spring_constant_rotation + def __eq__(self, rhs): + return ( + self.name==rhs.name + and self.english_name==rhs.english_name + and self.joint_type==rhs.joint_type + and self.rigidbody_index_a==rhs.rigidbody_index_a + and self.rigidbody_index_b==rhs.rigidbody_index_b + and self.position==rhs.position + and self.rotation==rhs.rotation + and self.translation_limit_min==rhs.translation_limit_min + and self.translation_limit_max==rhs.translation_limit_max + and self.rotation_limit_min==rhs.rotation_limit_min + and self.rotation_limit_max==rhs.rotation_limit_max + and self.spring_constant_translation==rhs.spring_constant_translation + and self.spring_constant_rotation==rhs.spring_constant_rotation + ) + class Model(object): """pmx data representation @@ -503,6 +588,8 @@ class Model(object): self.textures=[] self.materials=[] self.bones=[] + self.morphs=[] + self.display_slots=[] self.rigidbodies=[] self.joints=[] @@ -513,3 +600,21 @@ class Model(object): vertices=len(self.vertices) )) + def __eq__(self, rhs): + return ( + self.version==rhs.version + and self.name==rhs.name + and self.english_name==rhs.english_name + and self.comment==rhs.comment + and self.english_comment==rhs.english_comment + and self.vertices==rhs.vertices + and self.indices==rhs.indices + and self.textures==rhs.textures + and self.materials==rhs.materials + and self.bones==rhs.bones + and self.morphs==rhs.morphs + and self.display_slots==rhs.display_slots + and self.rigidbodies==rhs.rigidbodies + and self.joints==rhs.joints + ) +