OSDN Git Service

fix material.
[meshio/meshio.git] / swig / blender24 / pmd_export.py
index bf01d56..d70361b 100644 (file)
@@ -484,7 +484,7 @@ class BoneBuilder(object):
 
         if len(b.children)==0:
             # 末端の非表示ボーン
-            bone=Bone(b.name+'_tail', b.tail['ARMATURESPACE'])
+            bone=Bone(b.name+'_t', b.tail['ARMATURESPACE'])
             bone.type=7
             self.__addBone(bone)
             assert(parent)
@@ -562,15 +562,16 @@ class PmdExporter(object):
             material.diffuse.g=m.G
             material.diffuse.b=m.B
             material.diffuse.a=m.alpha
-            material.sinness=m.spec
+            material.sinness=0 if m.spec<1e-5 else m.spec*10
             material.specular.r=m.specR
             material.specular.g=m.specG
             material.specular.b=m.specB
-            material.ambient.r=m.amb
-            material.ambient.g=m.amb
-            material.ambient.b=m.amb
+            material.ambient.r=m.mirR
+            material.ambient.g=m.mirG
+            material.ambient.b=m.mirB
             material.vertex_count=len(indices)
             material.toon_index=0
+            material.flag=1 if m.enableSSS else 0
             # ToDo
             material.texture=""
             # 面
@@ -589,7 +590,20 @@ class PmdExporter(object):
         # bones
         for b in builder.bones:
             bone=io.addBone()
-            bone.name=b.name
+
+            unicode=englishmap.getUnicodeBoneName(b.name)
+            if unicode:
+                cp932=unicode.encode('cp932')
+            else:
+                cp932=b.name
+            bone_name="%s\n" % cp932
+            assert(len(bone_name)<20)
+            bone.name=bone_name
+
+            bone_english_name="%s\n" % b.name
+            assert(len(bone_english_name)<20)
+            bone.english_name=bone_english_name
+
             bone.type=b.type
             bone.parent_index=b.parent_index if b.parent_index!=None else 0xFFFF
             bone.tail_index=b.tail_index if b.tail_index!=None else 0
@@ -617,7 +631,15 @@ class PmdExporter(object):
         for i, m in enumerate(self.oneSkinMesh.morphList):
             # morph
             morph=io.addMorph()
-            morph.name=m.name
+
+            unicode=englishmap.getUnicodeSkinName(m.name)
+            if unicode:
+                cp932=unicode.encode('cp932')
+            else:
+                cp932=m.name
+            morph.name="%s\n" % cp932
+
+            morph.english_name="%s\n" % m.name
             morph.type=m.type
             for index, offset in zip(m.indices, m.offsets):
                 # convert right-handed z-up to left-handed y-up
@@ -628,12 +650,21 @@ class PmdExporter(object):
             if i>0:
                 io.face_list.append(i)
 
-        # ボーン枠
-        io.addBoneNameList("bones")
-        display=1
+        # ボーン表示枠
+        boneDisplayName=io.addBoneDisplayName()
+        boneDisplayName.name="bones\n"
+        boneDisplayName.english_name="bones\n"
+        displayIndex=1
         for i, b in enumerate(builder.bones):
             if b.type in [6, 7]:
-                io.addBoneDisplay(i, display)
+                io.addBoneDisplay(i, displayIndex)
+
+        # English
+        io.english_name="blender export model"
+        io.english_coment="blender export"
+
+        for i in range(10):
+            io.getToonTexture(i).name="toon%02d.bmp" % i
 
         # 書き込み
         return io.write(path.encode(FS_ENCODING))