• R/O
  • HTTP
  • SSH
  • HTTPS

pymeshio: Commit

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


Commit MetaInfo

Revision20b3814577c75012599265ab8f3c27dbfb885115 (tree)
Time2011-10-14 23:32:31
Authorousttrue <ousttrue@gmai...>
Commiterousttrue

Log Message

implement clean up.

Change Summary

Incremental Difference

--- a/blender26-meshio/import_pmx.py
+++ b/blender26-meshio/import_pmx.py
@@ -178,9 +178,14 @@ 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)
182- # material作成
181+ ####################
182+ # material
183+ ####################
183184 material=__create_a_material(m, m.name, textures_and_images)
185+
186+ ####################
187+ # mesh object
188+ ####################
184189 # object名はutf-8で21byteまで
185190 mesh, mesh_object=bl.mesh.create(get_object_name(i, m.name))
186191 bl.mesh.addMaterial(mesh, material)
@@ -188,9 +193,13 @@ def _execute(filepath):
188193 bl.object.deselectAll()
189194 bl.object.activate(mesh_object)
190195 bl.object.makeParent(root_object, mesh_object)
196+
197+ ####################
191198 # vertices & faces
199+ ####################
192200 indices=[next(index_generator)
193201 for _ in range(m.vertex_count)]
202+ used_indices=set(indices)
194203 bl.mesh.addGeometry(mesh, vertices,
195204 [(indices[i], indices[i+1], indices[i+2])
196205 for i in range(0, len(indices), 3)])
@@ -217,6 +226,9 @@ def _execute(filepath):
217226 ],
218227 image)
219228
229+ ####################
230+ # armature
231+ ####################
220232 if armature_object:
221233 # armature modifirer
222234 bl.modifier.addArmature(mesh_object, armature_object)
@@ -235,6 +247,9 @@ def _execute(filepath):
235247 else:
236248 raise Exception("unknown deform: %s" % v.deform)
237249
250+ ####################
251+ # shape keys
252+ ####################
238253 # set shape_key pin
239254 bl.object.pinShape(mesh_object, True)
240255 # create base key
@@ -253,5 +268,12 @@ def _execute(filepath):
253268 # select base shape
254269 bl.object.setActivateShapeKey(mesh_object, 0)
255270
271+ #############################
272+ # clean up not used vertices
273+ # in the material.
274+ #############################
275+ bl.mesh.vertsDelete(mesh, [i for i in range(len(mesh.vertices))
276+ if i not in used_indices])
277+
256278 return {'FINISHED'}
257279
Show on old repository browser