0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Maya python で BlendShapes からメッシュを作る

Posted at

Mayaで BlendShape で重みを変えて新しくメッシュを作ります.

変える重みのパターンが数十個や数百個になり多くなると, UI で手作業でやるのは面倒なので, python でやります.

で, 重みを変えてまずは blendshape を deform させます.
重みは (重みのインデックス, 重みの値)で指定します.
重みの名称は別途 listAttr で取得できます.

import maya.cmds as cmds

bs_name = 'blendspahe'
list = cmds.listAttr(bs_name + '.w', m=True)
print(list)
# [u'EyeOpen', u'EyeClose', ...]

重みパラメータを指定し, edit=True で変形できます.

cmds.blendShape( 'blendShape1', edit=True, w=[(0, 0.6), (1, 0.1)] )

Duplicate special して変形したメッシュを新しく作ります. name でノード名称を指定できます.

作ったメッシュは pm.hidden しておきます.

import maya.cmds as cmds
import pymel.core as pm

bs_name = 'blendsphape'
bs_list = cmds.listAttr(bs_name + '.w', m=True)

# ... setup weight table
# weight_table = [(0, 0.1), (1, 0.0), ...]

cmds.blendShape( bs_name, edit=True, w=weight_table )

src_obj = pm.PyNode('pBS') # blenshapes に対応したメッシュノード
dst_obj = pm.duplicate(src_obj, name = "new");

pm.hide(dst_obj)

TODO

  • Duplicate special のほうがよいか?
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?