Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cfa9644
refactor: 配置の行列の計算を bpy に依存しない core/model_space.py に移す(#263)
utagestudio Nov 23, 2026
28dda2f
refactor: placements() を段階ごとの関数に分ける(#263)
utagestudio Nov 23, 2026
5f78531
refactor: prepare_package() をマテリアル・モデル・prefab・パイプラインの段階に分ける(#263)
utagestudio Nov 23, 2026
e5c1a5b
refactor: package.py から FBX・OBJ の中身の読み取りと入れ子のパッケージを分ける(#263)
utagestudio Nov 23, 2026
f42db5e
feat: AnimationClip(.anim)の解析とパスの照合を core に足す(#209)
utagestudio Nov 23, 2026
5f9d112
feat: パッケージの .anim を Action にして NLA にミュートで並べる(#209)
utagestudio Nov 23, 2026
6078dfd
test: .anim を含む合成パッケージと期待値を足す(#209)
utagestudio Nov 23, 2026
a80293e
docs: アニメーションクリップの読み込みを README・DESIGN.md・CLAUDE.md に書く(#209)
utagestudio Nov 23, 2026
10f4704
feat: 状態を切り替えるだけのアニメーションクリップを読み込まない(#209)
utagestudio Nov 25, 2026
4d45cec
docs: 状態を切り替えるだけのクリップを読み込まないことを書く(#209)
utagestudio Nov 25, 2026
5111e3d
feat: Humanoid のアニメーションクリップはクリップごと読み込まない(#209)
utagestudio Nov 25, 2026
57b94b8
docs: Humanoid のクリップをクリップごと外すことを書く(#209)
utagestudio Nov 25, 2026
143aa19
Merge pull request #271 from utagestudio/refactor/issue-263-placement
utagestudio Nov 25, 2026
8d86587
Merge pull request #273 from utagestudio/feat/issue-209-anim
utagestudio Nov 25, 2026
7213813
feat: モデルの .meta からアニメーションのクリップの設定を読む(#276)
utagestudio Nov 25, 2026
371ed3b
feat: FBX のテイクを Unity のクリップどおりに NLA に並べ、モーションだけのアーマチュアをまとめる(#276)
utagestudio Nov 25, 2026
9de3dd1
test: モデルのテイクを含む合成パッケージと期待値を足す(#276)
utagestudio Nov 25, 2026
837ea46
docs: モデルの中のモーションと Animation のオプションを書く(#276)
utagestudio Nov 25, 2026
0bfa9f3
Merge pull request #278 from utagestudio/feat/issue-276-fbx-motion
utagestudio Nov 25, 2026
566588d
feat: ループするクリップのストリップをシーンの終わりまで繰り返す
utagestudio Nov 25, 2026
889088d
docs: ループするクリップの扱いを書く
utagestudio Nov 25, 2026
dd1944e
fix: ルートのノードが決まらない配置で、ルート自身のメッシュを GameObject の位置に置く(#272)
utagestudio Nov 25, 2026
f5b072d
test: 名前を変えた GameObject が、表の無い FBX の原点から離れたノードを指すケースを足す(#272)
utagestudio Nov 25, 2026
97cff93
docs: ルートのノードが決まらない配置の置き直しを DESIGN.md に書く(#272)
utagestudio Nov 25, 2026
23b8f45
Merge pull request #280 from utagestudio/fix/issue-272-root-renderer
utagestudio Nov 26, 2026
a70957d
chore: release/1.18.0(#272 の修正)を取り込み、バージョンを 1.18.0-dev.13 にする
utagestudio Nov 26, 2026
76d5cdf
Merge pull request #279 from utagestudio/feat/clip-loop
utagestudio Nov 26, 2026
232314e
refactor: NLA の共通処理を nla.py に、アーマチュアのまとめを rig_merge.py に分ける(#281)
utagestudio Nov 26, 2026
8885624
test: Animation が Active のとき .anim のトラックのミュートが外れることを確かめる(#281)
utagestudio Nov 26, 2026
95f5b28
docs: nla.py と rig_merge.py を DESIGN.md と CLAUDE.md に書く(#281)
utagestudio Nov 26, 2026
0cdd058
Merge pull request #282 from utagestudio/refactor/nla-rig-merge
utagestudio Nov 26, 2026
3d8df50
chore: バージョンを 1.18.0 にする
utagestudio Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

- メッシュ(アーマチュア・シェイプキー込み)に、Unity 側のマテリアル設定とテクスチャを反映した状態で読み込む。
- Unity と Blender のマテリアルは 1:1 に対応しないので「参考にできる値だけ」を反映し、残りはカスタムプロパティに保存する。
- シェーダー本体、C#、アニメーション、prefab 階層、Expression メニュー等は読み込まない。
- シェーダー本体、C#、Humanoid のアニメーション・ボーンのカーブ・Animator Controller、Expression メニュー等は読み込まない。
Generic な `.anim`(シェイプキー・表示の切り替え・オブジェクトの Transform)は、ミュートした NLA トラックの Action にする(`core/animation.py`。#209)。
値が変わらないか 0.1 秒以下で終わる、状態を切り替えるだけのクリップ(Animator のステート用)は読み込まない。
FBX の中のテイクは、.meta の clipAnimations どおりのクリップにして同じく NLA に並べ、同じ骨格のモーションだけのモデルは
レストの違いを変換して 1 体のアーマチュアにまとめる(`blender/fbx_motion.py` と `rig_merge.py`。NLA への置き方は両方で `nla.py`。#276)。オプションは Animation(Muted / Active / None)。

## 設計の要点(詳細は DESIGN.md)

Expand Down Expand Up @@ -47,7 +51,7 @@
```
unitypackage_loader/ Extension 本体(blender_manifest.toml、Blender 4.5 以降の Extension 形式)
core/ bpy 非依存。単体テスト可能。bpy を import しないこと
blender/ bpy 依存(importer / options / log / prepare / model_import / session_materials / scene_placement / scene_objects / terrain / unity_meshes / materials / nodes / textures / toon_group / outline)
blender/ bpy 依存(importer / options / log / prepare / model_import / session_materials / scene_placement / scene_objects / terrain / unity_meshes / animation / fbx_motion / rig_merge / nla / materials / nodes / textures / toon_group / outline)
operators/ File > Import、モデル選択ダイアログ、再構築、アウトライン
ui/ Preferences、サイドバー "UPI" タブ
tests/ unittest(bpy 不要)+ Blender 上の統合テスト+合成パッケージ生成
Expand Down
120 changes: 111 additions & 9 deletions DESIGN.md

Large diffs are not rendered by default.

49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ A Blender Extension that imports `.unitypackage` files directly from File > Impo
(including armatures and shape keys) with the material settings and textures from the Unity side applied.

- Supported Blender: 4.5 or later (developed on 5.2 LTS, tested on 4.5 LTS and 5.2 LTS)
- What is imported: FBX / OBJ / glTF / VRM / Collada (Blender 4.5 only; removed in Blender 5.0) / bundled .blend files (opt-in), `.mat` files (lilToon / MToon / Poiyomi / Standard / URP / HDRP / VRChat Mobile (Quest) shaders; others on a best-effort basis using generic rules), and referenced textures
- What is not imported: shader source code, C# scripts, animations, Expression menus, etc. Prefab hierarchies, lights and cameras are reproduced only when a scene is imported.
- What is imported: FBX / OBJ / glTF / VRM / Collada (Blender 4.5 only; removed in Blender 5.0) / bundled .blend files (opt-in), `.mat` files (lilToon / MToon / Poiyomi / Standard / URP / HDRP / VRChat Mobile (Quest) shaders; others on a best-effort basis using generic rules), referenced textures, and animation as actions on muted NLA tracks: the animation takes inside models (split into Unity's clips; motion-only FBX files with the same skeleton are merged into one armature) and Generic animation clips (`.anim`: blend shapes, object visibility and transforms)
- What is not imported: shader source code, C# scripts, Humanoid animation clips, animation curves on bones, Animator Controllers, Expression menus, etc. Prefab hierarchies, lights and cameras are reproduced only when a scene is imported.
- VRM: when the [VRM format](https://extensions.blender.org/add-ons/vrm/) add-on is installed, `.vrm` models are handed to it (MToon materials, humanoid rig, spring bones and expressions are reproduced by the add-on). Without it, the glTF importer is used and materials are rebuilt from the bundled `.mat` files.

## Installation
Expand Down Expand Up @@ -79,7 +79,8 @@ The options show Material Mode and Scale; everything else is folded into the Mod
| (always shown) | Material Mode | `Auto` (Toon for toon-style shaders, Principled for PBR) / `Principled BSDF` / `Toon (Node Group)` / `Unlit (Emission)` / `Names Only` |
| | Scale | Scale passed to the model importer |
| Model | FBX Importer | Prefer the new C++ importer (`Auto`) / choose explicitly |
| | Import Animation / Ignore Leaf Bones | Passed to the FBX importer (OFF / ON by default) |
| | Animation | `Muted` (default): import the models' animation takes and the package's `.anim` clips as muted NLA tracks / `Active`: the same, but unmute the first track of each object / `None`: do not import animation. See [Animation clips](#animation-clips) |
| | Ignore Leaf Bones | Passed to the FBX importer (default ON) |
| | VRM via VRM Add-on | Import `.vrm` with the VRM format add-on when installed (default ON); otherwise fall back to the glTF importer and rebuild materials from `.mat` |
| | Import Bundled .blend Files | Append objects from `.blend` files inside the package (default OFF). See [Security notes](#security-notes) |
| Materials | Force Opaque | Ignore Unity's Cutout / Transparent settings |
Expand Down Expand Up @@ -169,6 +170,48 @@ To stay within the Windows path length limit, files whose full path would be too
`_long/` in the destination. If the destination folder itself is too long, the import stops with an error; in that case set
Textures > Extract To to `Custom Path` and choose a short folder such as `C:\upi`.

### Animation clips

Animation is added as **muted** NLA tracks named after each clip, so the scene looks the same right after the import.
To preview a clip, unmute its track in the NLA editor (or click its star to solo it), or select the strip and press Tab to
edit the action. With Animation set to `Active`, the first track of each object is unmuted instead (only one, because
unmuted NLA tracks override each other).

#### Motions inside models

Animation takes inside FBX files (for example motion packs, or `model@motion.fbx` files) are split into the clips that the
model's `.meta` defines in Unity (Model Import Settings > Animation: name, first and last frame). All clips of a take share
one action, and each strip plays its own frame range. Models without clip settings get one clip per take. Short clips
(0.1 seconds or shorter, such as a T-pose take) are skipped, and the active action that the FBX importer assigns is cleared.

When several motion-only models (no meshes, one armature) share the same skeleton, they are merged into one armature
that has all the motions as NLA tracks (Models only). An FBX without a skin uses its default pose as the rest pose, so
the rest pose differs from file to file; the keys are converted so that each motion keeps its pose on the remaining
armature. A skeleton that lacks some bones (for example weapon bones) is merged too; the missing bones stay at rest.
When a scene places the same model many times, the actions of its takes are shared. Looping clips (Loop Time in Unity)
repeat their strip until the end of the scene's frame range.

#### Generic `.anim` clips

Generic animation clips (`.anim`) in the package become one action per clip. These curves are read:

- Blend shape weights (`blendShape.<name>`, 0–100 in Unity) → shape key values (0–1)
- GameObject active state (`m_IsActive`) and Renderer `m_Enabled` → `hide_viewport` / `hide_render` (deactivating a GameObject also hides its children)
- Transform position, rotation (quaternion or Euler) and scale → the object's location, rotation and scale, sampled every frame

A clip does not say which model it belongs to, so the importer looks for the imported object under which the most curve
paths resolve, and treats it as the object the clip is played on (all placements of the same model get the clip).
Each clip gets an NLA track on every object or shape key it animates. Keys start at the scene's start frame and use the scene's frame rate.
Looping clips (Loop Time in Unity) repeat their strip until the end of the scene's frame range.

Clips that only switch a state are skipped: clips whose values never change, or that end within 0.1 seconds. Unity's
Animator uses such clips as states and makes the motion with transitions (outfit toggles and expressions of VRChat avatars,
the steering angle of a vehicle, and so on), so they have nothing to play back in Blender.

Not imported (the report lists how many were skipped): state clips (above), Humanoid clips (the body motion is stored as muscle curves, so the whole clip is skipped, including its other curves; the original motion is usually in an FBX in the package, which is imported as above),
curves on bones, clips that only animate the object they are played on (no path, so the object is unknown), and curves on
materials or object references. Clips whose paths match no imported object are skipped too. Animator Controllers are not read.

### Security notes

- **Bundled .blend files are not imported by default.** A `.blend` can carry Python code (driver expressions,
Expand Down
47 changes: 44 additions & 3 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
Unity 側のマテリアル設定とテクスチャを反映した状態で配置する Extension です。

- 対応 Blender: 4.5 以降(開発は 5.2 LTS、検証は 4.5 LTS と 5.2 LTS)
- 読み込むもの: FBX / OBJ / glTF / VRM / Collada(Blender 4.5 のみ。5.0 で削除された)/ 同梱 .blend(オプトイン)、`.mat`(lilToon / MToon / Poiyomi / Standard / URP / HDRP / VRChat Mobile(Quest 向け)シェーダー、その他は一般規則で最善努力)、参照テクスチャ
- 読み込まないもの: シェーダー本体、C#、アニメーション、Expression メニュー等。prefab の階層、ライト、カメラは、シーンを読み込むときだけ再現します
- 読み込むもの: FBX / OBJ / glTF / VRM / Collada(Blender 4.5 のみ。5.0 で削除された)/ 同梱 .blend(オプトイン)、`.mat`(lilToon / MToon / Poiyomi / Standard / URP / HDRP / VRChat Mobile(Quest 向け)シェーダー、その他は一般規則で最善努力)、参照テクスチャ、アニメーション(ミュートした NLA トラックの Action にする。モデルの中のテイクを Unity のクリップどおりに分けたもの(同じ骨格のモーションだけの FBX は 1 体のアーマチュアにまとめる)と、Generic な `.anim` のシェイプキー・表示の切り替え・Transform)
- 読み込まないもの: シェーダー本体、C#、Humanoid のアニメーションクリップ、ボーンのアニメーションのカーブ、Animator Controller、Expression メニュー等。prefab の階層、ライト、カメラは、シーンを読み込むときだけ再現します
- VRM: [VRM format](https://extensions.blender.org/add-ons/vrm/) add-on が入っていれば `.vrm` はそちらに委譲します(MToon マテリアル、Humanoid リグ、スプリングボーン、表情は add-on が再現)。無ければ glTF インポーターで読み、同梱の `.mat` からマテリアルを組み直します。

## インストール
Expand Down Expand Up @@ -77,7 +77,8 @@ Settings > Pages > Source を "GitHub Actions" にしてください。
| (常に表示) | Material Mode | `Auto`(トゥーン系は Toon、PBR 系は Principled)/ `Principled BSDF` / `Toon (Node Group)` / `Unlit (Emission)` / `Names Only` |
| | Scale | モデルのインポーターに渡すスケール |
| Model | FBX Importer | 新 C++ インポーター優先(`Auto`)/ 明示指定 |
| | Import Animation / Ignore Leaf Bones | FBX インポーターに渡す(既定はそれぞれ OFF / ON) |
| | Animation | `Muted`(既定): モデルのテイクとパッケージの `.anim` を、ミュートした NLA トラックにする / `Active`: 同じく読み、オブジェクトごとに最初のトラックだけミュートを外す / `None`: アニメーションを読まない。[アニメーションクリップ](#アニメーションクリップ) を参照 |
| | Ignore Leaf Bones | FBX インポーターに渡す(既定 ON) |
| | VRM via VRM Add-on | `.vrm` を VRM format add-on で読む(既定 ON)。add-on が無ければ glTF インポーターで読んで `.mat` から組み直す |
| | Import Bundled .blend Files | パッケージ内の `.blend` からオブジェクトを append する(既定 OFF)。[セキュリティ上の注意](#セキュリティ上の注意) を参照 |
| Materials | Force Opaque | Unity の Cutout / Transparent 設定を無視する |
Expand Down Expand Up @@ -151,6 +152,46 @@ prefab のルートをその Collection の原点に置きます。
Windows のパスの長さの上限に当たらないよう、フルパスが長くなるファイルは展開先の `_long/` の下の短いフォルダに置きます。
展開先のフォルダ自体が長すぎるとエラーになるので、その場合は Textures の Extract To を `Custom Path` にして `C:\upi` のような短いフォルダを選んでください。

### アニメーションクリップ

アニメーションは、クリップの名前の NLA トラックを**ミュート**で足すので、読み込んだ直後の見た目は変わりません。確かめるときは
NLA エディターでトラックのミュートを外すか、星のアイコンでソロにします。ストリップを選んで Tab で Action を編集することもできます。
Animation を `Active` にすると、オブジェクトごとに最初の 1 本だけミュートを外します(ミュートしていないトラックは上のものが下を
上書きするので、1 本だけにしています)。

#### モデルの中のモーション

FBX の中のアニメーションのテイク(モーション集や、`モデル@モーション.fbx` のファイルなど)は、Unity でモデルの `.meta` に設定した
クリップ(Model Import Settings の Animation。名前と開始・終了フレーム)に分けます。同じテイクのクリップは 1 つの Action を共有し、
ストリップごとに自分の範囲を再生します。クリップの設定が無いモデルは、テイクごとに 1 クリップです。0.1 秒以下の短いクリップ
(T ポーズのテイクなど)は外し、FBX インポーターが付けるアクティブな Action も外します。

同じ骨格のモーションだけのモデル(メッシュが無く、アーマチュアが 1 体)が複数あれば、1 体のアーマチュアにまとめて、全モーションを
NLA トラックとして並べます(Models 単位)。スキンの無い FBX はファイルの既定の姿勢をレストにするので、レスト姿勢はファイルごとに
違います。残すアーマチュアでも同じ姿勢になるよう、キーを変換します。一部のボーン(武器用のボーンなど)が無い骨格もまとめます
(無いボーンはレストのまま)。シーンで同じモデルを何度も置くときは、テイクの Action を共有します。ループするクリップ(Unity の Loop Time)は、
シーンのフレーム範囲の終わりまでストリップを繰り返します。

#### Generic な `.anim`

パッケージの Generic なアニメーションクリップ(`.anim`)を、クリップごとに 1 つの Action にします。読むカーブは次のとおりです。

- シェイプキーの重み(`blendShape.<名前>`。Unity では 0〜100)→ シェイプキーの値(0〜1)
- GameObject のアクティブ(`m_IsActive`)と Renderer の `m_Enabled` → `hide_viewport` / `hide_render`(GameObject を非アクティブにすると子も隠れる)
- Transform の位置・回転(クォータニオンかオイラー角)・スケール → オブジェクトの位置・回転・スケール(フレームごとに求める)

クリップは対象のモデルを持たないので、カーブの階層パスがいちばん多く当てはまる読み込んだオブジェクトを、クリップを再生する
オブジェクトとみなします(同じモデルを複数置いていれば、すべてに付けます)。動かすオブジェクトとシェイプキーごとに
NLA トラックを足します。キーはシーンの開始フレームから、シーンのフレームレートで並べます。ループするクリップ(Unity の Loop Time)は、シーンのフレーム範囲の終わりまでストリップを繰り返します。

状態を切り替えるだけのクリップ(値が変わらないもの、0.1 秒以下で終わるもの)は読み込みません。Unity の Animator はこうしたクリップを
ステートとして使い、動きは遷移で作ります(VRChat のアバターの衣装の切り替えや表情、車両のハンドルの角度など)。
Blender では再生しても何も動かないためです。

読み込まないもの(件数はレポートに出ます): 状態を切り替えるだけのクリップ(上記)、Humanoid のクリップ(体の動きがマッスル値で入っているため、ほかのカーブも含めてクリップごと外します。元のモーションはたいていパッケージの FBX にあり、上記のとおり読み込みます)、ボーンのカーブ、
再生するオブジェクト自身だけを動かすクリップ(パスが無く、どのオブジェクトか決められない)、マテリアルやオブジェクト参照のカーブ。
読み込んだオブジェクトにパスが当てはまらないクリップも外します。Animator Controller は読みません。

### セキュリティ上の注意

- **同梱 .blend は既定では読み込みません。** `.blend` には Python コード(ドライバー式、登録済みテキストブロック)を
Expand Down
Loading
Loading