LoginSignup
4
3

More than 3 years have passed since last update.

meta-rig を組み立てる

Last updated at Posted at 2020-11-08

Blender-2.83

これ。

Rigify は Rig ジェネレーターで、ジェネレートする元の Meta-Rig 、ジェネレートされた後の Rig 、双方よくわからないのである。

参考

2.6 の詳しいマニュアル

Rigify の一般的な使い方

  • Human(Meta-Rig) 新規追加
  • 自分のモデルに位置を合わせる
  • Rig をジェネレート
  • ジェネレートされた Rig の Deformボーンに対して自分のモデルのボーンウェイト付ける

で、最初から機能満載でよくわからんとなる。
たぶん、

に書いてある個別の Rig Type についての知識がないと、Human Rig のような集合体は手が出ない。

Rigify を既存のArmatureに対して組み立てたい

自分のモデルには最初からウェイトが付いている Armature があるので、それにリグを追加したい。

  • 自前の Armature に Meta-Rig 設定
  • Rig をジェネレート
  • RigのDEF-ボーンを消す
  • RigのORGボーンの Deform を有効にする
  • RigのORG-ボーンの名前を変えて元のボーンウェイトを引き継ぐ

という手が使えそう。

参考
https://github.com/trynyty/Rigify_DeformBones

最小限の meta-rig

blender の rigify のドキュメントを読んでいたら

を見つけた。

Building your own meta-rig from scratch

  • Add - Armature - Single Bone
  • Edit
  • 既存のボーンを消す
  • Armature の property から Rigify Buttons - Add sample 押す

add_sample.jpg

basic.copy_cahin の sample(meta-rig) が生成される

bones.jpg

poseモードで眺めると

一個目のボーンに rigify_typebasic.copy_chain が設定されている

rigify_type.jpg

Requirement: A chain of at least two connected bones.

なので3本出てくるぽい。rigify_type 毎に必要な構成が決まっている様子。

generate してみる。

generate.jpg

この小さいサンプルでも、ボーンの数が3倍になって9本になる。

generated.jpg

  • ORG-bone.01-03 オリジナル。たぶんなんもしない。消してもよいのでは
  • bone.01-03 表示されているボーン。たぶん操作用
  • DEF-bone.01-03 スキニングにボーンウェイトを設定する用

で、この basic.copy_chain は使い道がよくわからなかった。human では使っていないみたいなので気にしない。

Copies the bone chain keeping all the parent relations within the chain untouched. Useful as a utility rig type for custom rigs.

Human(Meta-Rig) を解読

Human(Meta-Rig) に使われている rigify_type の sample を眺めてみる

limbs.leg

human 使われている limbs.super_limb のと微妙に違うのかと思ったが、
limbs.super_limb に Limb Type = Leg に設定したものが limbs.leg のような気がする。
limbs.super_limb は generate 時に、 limbs.Limb_Type で置き換えるもののようだ。

limbs_leg.jpg

Meta-Rig は thigh - shin - foot -toe という構成。

ジェネレートする

rig_leg.jpg

大量のボーンが生成された。

  • root
    • ORG-thigh
    • MCH-thigh_parent
    • VIS_thigh_IK_pole
    • MCH-thigh_tweak
    • DEF-thigh
  • MCH-foot_IK
  • MCH_thigh_IK

主に足の底にある IK ターゲットで操作すればよさそう

basic.super_copy

spines.basic_spine

spines.super_head

limbs.super_finger

faces.super_face

既存の Armature に Meta-Rig を設定する

ということで、 vroid のモデルを Blender に持ってきたところから始まる。

vroid.jpg

limb.leg を設定してみる

  • Pose モードにする
  • UpperLeg.L の rigify_typelimbs.leg に設定
  • Generate ボタン

エラー出た。

rigify.utils.errors.MetarigError: "RIGIFY ERROR: Bone 'UpperLeg.L': Heel bone not found."
Error: RIGIFY ERROR: Bone 'UpperLeg.L': Heel bone not found.
Incorrect armature for type 'leg'

どうやら踵ボーンが足りない。
limbs.leg のサンプル構成を参考にして適当に足してみる。

Foot.L の child にボーンを追加する。 use_connect = False

heel.jpg

  • Generate ボタン
rigify.utils.errors.MetarigError: "RIGIFY ERROR: Bone 'UpperLeg.L': Input to rig type must be a chain of 4 bones."
Error: RIGIFY ERROR: Bone 'UpperLeg.L': Input to rig type must be a chain of 4 bones.
Incorrect armature for type 'leg'

これは、 upperLeg - lowerLeg - foot - toe - end となっていて、末端に end が付いているのが原因だった(chainが4つである必要がある)。
end は BoneWeight の無い先端ボーンなので削除する。

  • Generate ボタン

vroid_leg.jpg

生成できた。

  • Mesh の Armature Modifier の参照を、新たに生成された rig Armature に変更する。
  • DEF- ボーン消す
  • ORG- ボーンの名前から ORG- を取り除いて、deform を有効にする

したところ、ORG-Toes.LToes.L が存在して名前が変えられなかった(Toes.L.001になる)。
VertexGroup の方の名前を変える。
スクリプト作った。連続で実行しても大丈夫なように書いてあるのでprintデバッグしながら進められる。

# object mode で 生成した rig をアクティブにして実行する
print()
print('### start ###')

import bpy

armature_obj = bpy.context.view_layer.objects.active
armature = armature_obj.data
print(armature)

# edit_bones にアクセスするのに必要
bpy.ops.object.mode_set(mode='EDIT')

# DEF- を消す
defs = [b for b in armature.edit_bones if b.name.startswith('DEF-')]
print(defs)
for b in defs:
    armature.edit_bones.remove(b)

# ORG- の deform を有効にする
for b in armature.edit_bones:
    if b.name.startswith('ORG-'):
        b.use_deform = True

bpy.ops.object.mode_set(mode='OBJECT')

# シーンのオブジェクトを列挙
for o in bpy.data.objects:
    # armature を生成した rig に設定
    for m in  o.modifiers:
        if m.type != 'ARMATURE':
            continue            
        m.object = armature_obj

    # vertex group の名前を変える
    for vg in o.vertex_groups:
        if vg.name.startswith('ORG-'):
            continue
        vg.name = 'ORG-' + vg.name

vroid_leg_rig.jpg

足リグの IK を動かすことができた。

spine

ToDo

arm

ToDo

hand

ToDo

face

ToDo

vrm LookAt

ToDo: 作れるか

vrm BlendShapeClip

ToDo: 作れるか

4
3
1

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
4
3