From: ousttrue Date: Sat, 19 Jun 2010 01:22:30 +0000 (+0900) Subject: fix bone structure. X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;ds=sidebyside;h=2d6c27006b56ff3829c2de45daa795c37fd08481;p=meshio%2Fmeshio.git fix bone structure. --- diff --git a/swig/blender/pmd_export.py b/swig/blender/pmd_export.py index d3d1949..d010503 100644 --- a/swig/blender/pmd_export.py +++ b/swig/blender/pmd_export.py @@ -627,6 +627,26 @@ class BoneBuilder(object): if b.ik_index>0: b.ik_index=sortMap[b.ik_index] + def fix(self): + """ + 調整 + """ + for b in self.bones: + # parent index + if b.parent_index==None: + b.parent_index=0xFFFF + else: + if b.type==6 or b.type==7: + # fix tail bone + parent=self.bones[b.parent_index] + parent.tail_index=b.index + + for b in self.bones: + if b.tail_index==None: + b.tail_index=0 + elif b.type==9: + b.tail_index==0 + def getIndex(self, bone): for i, b in enumerate(self.bones): if b==bone: @@ -699,6 +719,7 @@ class PmdExporter(object): self.builder.ik_list.sort(lambda l, r: getIndex(l)-getIndex(r)) else: self.builder.ik_list.sort(key=getIndex) + self.builder.fix() def __createOneSkinMesh(self, node): ############################################################ @@ -814,18 +835,8 @@ class PmdExporter(object): else: bone.type=b.type - # parent index - bone.parent_index=b.parent_index if b.parent_index!=None else 0xFFFF - - # tail index - if b.tail_index!=None: - if bone.type==9: - bone.tail_index=0 - else: - bone.tail_index=b.tail_index - else: - bone.tail_index=0 - + bone.parent_index=b.parent_index + bone.tail_index=b.tail_index bone.ik_index=b.ik_index # convert right-handed z-up to left-handed y-up diff --git a/swig/blender/pmd_import.py b/swig/blender/pmd_import.py index c8b5560..3f7b33b 100644 --- a/swig/blender/pmd_import.py +++ b/swig/blender/pmd_import.py @@ -210,8 +210,8 @@ def __build(armature, b, p, parent): bone=bl.createArmatureBone(armature, name) if b.tail_index==0: - # 先端 - assert(b.type==6 or b.type==7) + # 先端ボーン + assert(b.type==6 or b.type==7 or b.type==9) bone.head = bl.createVector(*convert_coord(b.pos)) bone.tail=bone.head+bl.createVector(0, 1, 0) assert(parent) @@ -227,6 +227,7 @@ def __build(armature, b, p, parent): # armature layer 2 bl.boneLayerMask(bone, [0, 1]) else: + # 通常ボーン bone.head = bl.createVector(*convert_coord(b.pos)) bone.tail = bl.createVector(*convert_coord(b.tail)) if parent: