LoginSignup
9
11

More than 5 years have passed since last update.

UnityのhumanoidからBlenderのArmatureを作る

Posted at

既存のUnityモデルにBlenderを使ってモーションをさくっと追加する手段を模索。
BlenderにUnityで使っているfbxをインポートするのはスケールや座標軸の変換等あまりうまくいかなかったので、
骨格情報のみをクリップボード経由でコピーしてArmatureを構築することにした。

成果物

UnityScript

Animatorから骨格情報を取得してクリップボードにコピーする。

Unityちゃんで試した例。Humanoid - Copy メニューから以下のJSONがクリップボードにコピーされる。

{
  "name": "Hips"
  , "pos": [0, 0.8685818, 0.01182688]
  , "children": [
  {
    "name": "Spine"
    , "pos": [1.21363E-08, 0.1135728, 0.01773594]
    , "children": [
    {
      "name": "Chest"
      , "pos": [1.830631E-08, 0.08765572, -0.001428664]
      , "children": [
      {
        "name": "Neck"
        , "pos": [-2.171146E-08, 0.1516775, -0.04080684]
        , "children": [
        {
          "name": "Head"
          , "pos": [-7.334165E-09, 0.07825303, -0.002021553]
          , "children": [
          {
            "name": "LeftEye"
          }
,           {
            "name": "RightEye"
          }
,           {
            "name": "Jaw"
          }
          ]
        }
        ]
      }
,       {
        "name": "LeftUpperArm"
        , "pos": [-0.09755183, 0.1161225, -0.038738]
        , "children": [
        {
          "name": "LeftLowerArm"
          , "pos": [-0.2337739, -0.00123477, 0.0003336743]
          , "children": [
          {
            "name": "LeftHand"
            , "pos": [-0.1624773, -0.001188517, 0.0003583133]
          }
          ]
        }
        ]
      }
,       {
        "name": "RightUpperArm"
        , "pos": [0.09755225, 0.1161224, -0.03873801]
        , "children": [
        {
          "name": "RightLowerArm"
          , "pos": [0.2337757, -0.001235604, 0.0003338605]
          , "children": [
          {
            "name": "RightHand"
            , "pos": [0.1624756, -0.001188517, 0.0003624558]
          }
          ]
        }
        ]
      }
      ]
    }
    ]
  }
,   {
    "name": "LeftUpperLeg"
    , "pos": [-0.07276823, -0.06057799, 0.002078831]
    , "children": [
    {
      "name": "LeftLowerLeg"
      , "pos": [0.01823138, -0.3510956, -0.01586638]
      , "children": [
      {
        "name": "LeftFoot"
        , "pos": [0.01031195, -0.3781777, -0.01709024]
        , "children": [
        {
          "name": "LeftToes"
          , "pos": [-0.002024546, -0.05287695, 0.08122413]
        }
        ]
      }
      ]
    }
    ]
  }
,   {
    "name": "RightUpperLeg"
    , "pos": [0.07276823, -0.06057763, 0.002078786]
    , "children": [
    {
      "name": "RightLowerLeg"
      , "pos": [-0.01823185, -0.3510961, -0.01587624]
      , "children": [
      {
        "name": "RightFoot"
        , "pos": [-0.01031367, -0.3781779, -0.01710318]
        , "children": [
        {
          "name": "RightToes"
          , "pos": [0.002025545, -0.05287772, 0.08122506]
        }
        ]
      }
      ]
    }
    ]
  }
  ]
}

BlenderでクリップボードのJSONからArmatureを構築する

AddOn作った。

paste_armature.png

3D viewのツールシェルフのMiscタブにできる[Paste Unity Humanoid]でクリップボード上のJSONからArmatureを作成する。
Blender仕様の右手系のZ-UPに変換したArmatureができる。

適当にポーズつけてみる

BindPoseと下図のポーズをつけた。
pose.png

あらかじめ[Fix Rotation]ボタンで回転を補正(Rotation 90°になっている)してから
fbxエクスポート。

Unityにインポート

インポートしてRigをHumanoidにしてApply。

unity_pose.png

無事同じポーズになった。
これで同じ骨格に対してポーズ付けできる。

9
11
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
9
11