• R/O
  • HTTP
  • SSH
  • HTTPS

pymeshio: Commit

pmdとmqoの入出力ライブラリと、それを使ったBlender2.5向けのaddon。


Commit MetaInfo

Revisionf4ab30fd28a4cb62ba6f7dd5fc7023182b8a2371 (tree)
Time2011-10-14 23:23:18
Authorousttrue <ousttrue@gmai...>
Commiterousttrue

Log Message

implement shape key

Change Summary

Incremental Difference

--- a/blender26-meshio/import_pmx.py
+++ b/blender26-meshio/import_pmx.py
@@ -178,7 +178,7 @@ def _execute(filepath):
178178 print("%s(%d)" % (name, letter_count))
179179 return name
180180 for i, m in enumerate(model.materials):
181- print(m.name)
181+ #print(m.name)
182182 # material作成
183183 material=__create_a_material(m, m.name, textures_and_images)
184184 # object名はutf-8で21byteまで
@@ -235,5 +235,23 @@ def _execute(filepath):
235235 else:
236236 raise Exception("unknown deform: %s" % v.deform)
237237
238+ # set shape_key pin
239+ bl.object.pinShape(mesh_object, True)
240+ # create base key
241+ baseShapeBlock=bl.object.addShapeKey(mesh_object, bl.BASE_SHAPE_NAME)
242+ mesh.update()
243+ for m in model.morphs:
244+ new_shape_key=bl.object.addShapeKey(mesh_object, m.name)
245+ for o in m.offsets:
246+ if isinstance(o, pmx.VertexMorphOffset):
247+ bl.shapekey.assign(new_shape_key,
248+ o.vertex_index,
249+ mesh.vertices[o.vertex_index].co+
250+ bl.createVector(*convert_coord(o.position_offset)))
251+ else:
252+ raise Exception("unknown morph type: %s" % o)
253+ # select base shape
254+ bl.object.setActivateShapeKey(mesh_object, 0)
255+
238256 return {'FINISHED'}
239257
--- a/pymeshio/converter.py
+++ b/pymeshio/converter.py
@@ -275,7 +275,7 @@ def pmd_to_pmx(src):
275275 english_name=m.english_name.decode('cp932'),
276276 panel=get_panel(m),
277277 morph_type=1,
278- offsets=[pmx.VerexMorphOffset(base.indices[i], pos)
278+ offsets=[pmx.VertexMorphOffset(base.indices[i], pos)
279279 for i, pos in zip(m.indices, m.pos_list)]
280280 )
281281 for i, m in enumerate(src.morphs) if m.name!=b"base"]
--- a/pymeshio/pmx/__init__.py
+++ b/pymeshio/pmx/__init__.py
@@ -107,8 +107,8 @@ class IkLink(Diff):
107107 def __init__(self, bone_index, limit_angle, limit_min=None, limit_max=None):
108108 self.bone_index=bone_index
109109 self.limit_angle=limit_angle
110- self.limit_min=limit_min or common.Vector3
111- self.limit_max=limit_max or common.Vector3
110+ self.limit_min=limit_min or common.Vector3()
111+ self.limit_max=limit_max or common.Vector3()
112112
113113 def __eq__(self, rhs):
114114 return (
@@ -171,13 +171,13 @@ class Bone(Diff):
171171 self.parent_index=parent_index
172172 self.layer=layer
173173 self.flag=flag
174- self.tail_position=tail_position or common.Vector3
174+ self.tail_position=tail_position or common.Vector3()
175175 self.tail_index=tail_index
176176 self.effect_index=effect_index
177177 self.effect_factor=effect_factor
178- self.fixed_axis=fixed_axis or common.Vector3
179- self.local_x_vector=local_x_vector or common.Vector3
180- self.local_z_vector=local_z_vector or common.Vector3
178+ self.fixed_axis=fixed_axis or common.Vector3()
179+ self.local_x_vector=local_x_vector or common.Vector3()
180+ self.local_z_vector=local_z_vector or common.Vector3()
181181 self.external_key=external_key
182182 self.ik=ik
183183
@@ -497,7 +497,7 @@ class Morph(Diff):
497497 self._diff_array(rhs, 'offsets')
498498
499499
500-class VerexMorphOffset(Diff):
500+class VertexMorphOffset(Diff):
501501 """pmx vertex morph offset
502502
503503 Attributes:
--- a/pymeshio/pmx/reader.py
+++ b/pymeshio/pmx/reader.py
@@ -216,7 +216,7 @@ class Reader(common.BinaryReader):
216216 "unknown morph type: {0}".format(morph_type))
217217
218218 def read_vertex_morph_offset(self):
219- return pmx.VerexMorphOffset(
219+ return pmx.VertexMorphOffset(
220220 self.read_vertex_index(), self.read_vector3())
221221
222222 def read_display_slot(self):
Show on old repository browser