pmdとmqoの入出力ライブラリと、それを使ったBlender2.5向けのaddon。
Revision | 20b3814577c75012599265ab8f3c27dbfb885115 (tree) |
---|---|
Time | 2011-10-14 23:32:31 |
Author | ousttrue <ousttrue@gmai...> |
Commiter | ousttrue |
implement clean up.
@@ -178,9 +178,14 @@ def _execute(filepath): | ||
178 | 178 | print("%s(%d)" % (name, letter_count)) |
179 | 179 | return name |
180 | 180 | for i, m in enumerate(model.materials): |
181 | - #print(m.name) | |
182 | - # material作成 | |
181 | + #################### | |
182 | + # material | |
183 | + #################### | |
183 | 184 | material=__create_a_material(m, m.name, textures_and_images) |
185 | + | |
186 | + #################### | |
187 | + # mesh object | |
188 | + #################### | |
184 | 189 | # object名はutf-8で21byteまで |
185 | 190 | mesh, mesh_object=bl.mesh.create(get_object_name(i, m.name)) |
186 | 191 | bl.mesh.addMaterial(mesh, material) |
@@ -188,9 +193,13 @@ def _execute(filepath): | ||
188 | 193 | bl.object.deselectAll() |
189 | 194 | bl.object.activate(mesh_object) |
190 | 195 | bl.object.makeParent(root_object, mesh_object) |
196 | + | |
197 | + #################### | |
191 | 198 | # vertices & faces |
199 | + #################### | |
192 | 200 | indices=[next(index_generator) |
193 | 201 | for _ in range(m.vertex_count)] |
202 | + used_indices=set(indices) | |
194 | 203 | bl.mesh.addGeometry(mesh, vertices, |
195 | 204 | [(indices[i], indices[i+1], indices[i+2]) |
196 | 205 | for i in range(0, len(indices), 3)]) |
@@ -217,6 +226,9 @@ def _execute(filepath): | ||
217 | 226 | ], |
218 | 227 | image) |
219 | 228 | |
229 | + #################### | |
230 | + # armature | |
231 | + #################### | |
220 | 232 | if armature_object: |
221 | 233 | # armature modifirer |
222 | 234 | bl.modifier.addArmature(mesh_object, armature_object) |
@@ -235,6 +247,9 @@ def _execute(filepath): | ||
235 | 247 | else: |
236 | 248 | raise Exception("unknown deform: %s" % v.deform) |
237 | 249 | |
250 | + #################### | |
251 | + # shape keys | |
252 | + #################### | |
238 | 253 | # set shape_key pin |
239 | 254 | bl.object.pinShape(mesh_object, True) |
240 | 255 | # create base key |
@@ -253,5 +268,12 @@ def _execute(filepath): | ||
253 | 268 | # select base shape |
254 | 269 | bl.object.setActivateShapeKey(mesh_object, 0) |
255 | 270 | |
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 | + | |
256 | 278 | return {'FINISHED'} |
257 | 279 |