diff --git a/docs/api/index.md b/docs/api/index.md index 74c8e8159..94ebca539 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -26,15 +26,3 @@ fast_spring_bone 0_95_highlevel 0_96_1_use_gamma_colorspace ``` - -## VRM-1.0(β) - -```{toctree} -:maxdepth: 2 - -vrm1_runtime_load -vrm1_get_humanoid -vrm1_expression -vrm1_lookat -vrm1_firstperson -``` diff --git a/docs/api/vrm1_get_humanoid.md b/docs/api/vrm1_get_humanoid.md deleted file mode 100644 index 814cefea3..000000000 --- a/docs/api/vrm1_get_humanoid.md +++ /dev/null @@ -1,7 +0,0 @@ -# 🚧Humanoid - -## Humanoid Bone の取得方法 - -### Humanoidコンポーネント(vrm-1.0) - -### Animator経由(vrm-0.xとvrm-1.0共通) diff --git a/docs/index.html b/docs/index.html index 073737c1c..084518140 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,10 +42,10 @@ - + Download - UniVRM-0.103.0 + UniVRM-0.103.1 diff --git a/docs/index.md b/docs/index.md index bf5dccea2..4314151fb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,6 +6,7 @@ api/index build implementation/index +vrm1/index ``` ```{toctree} diff --git a/docs/vrm1/index.md b/docs/vrm1/index.md new file mode 100644 index 000000000..b1e43f8cd --- /dev/null +++ b/docs/vrm1/index.md @@ -0,0 +1,34 @@ +# VRM-1.0 の API + +`vrm-0.103.1` + +`VRM-1.0` ではフォーマットの更新とともに、 `Unity Component` が変わります。 +また、`VRM-0.X` をロードして新しいコンポーネントで動かすことができます。 +この場合 `VRM-0` ライセンスで扱ってください。 + +```csharp +RuntimeGltfInstance instance = await VrmUtility.LoadAsync(path); +``` + +👇 + +```csharp +Vrm10Instance vrm10Instance = await Vrm10.LoadPathAsync(path); +``` + +`VRM-0.x` から設計を変更して `Vrm10Instance` にすべての情報を格納する方式になりました。 + +```{admonition} Vrm10Instance +:class: info +Expression や LookAt, FirstPerson などまとめて入っています。 +``` + +```{toctree} +:maxdepth: 2 + +vrm1_load +vrm1_controlrig +vrm1_expression +vrm1_lookat +vrm1_firstperson +``` diff --git a/docs/vrm1/vrm1_controlrig.md b/docs/vrm1/vrm1_controlrig.md new file mode 100644 index 000000000..39bf18258 --- /dev/null +++ b/docs/vrm1/vrm1_controlrig.md @@ -0,0 +1,46 @@ +# ControlRig 正規化されていないモデルを操作する + +VRM-1.0 は正規化が仕様から除かれました。 + +```{admonition} 正規化 +:class: info + +ヒエラルキーからの 回転、スケールの除去。 +その状態での Binding 行列再生成。 +です。 +すべてのノードの回転が 0 のときが初期姿勢(T-Pose)であるという仕様で、 +プログラムから統一的にモデルを操作することが可能でした。 +``` + +正規化されていないモデルも含めて統一的にポーズを付けるインターフェスとして、 `ControlRig` が新規に導入されました。 `v0.103` + +基本的な使い方は下記のとおりです。 +`UnityEngine.Animator.GetBoneTransform` の代わりに使う想定です。 + +```csharp +Vrm10RuntimeControlRig rig = instance.Runtime.ControlRig + +// 使用例 +var transform = rig.GetBoneTransform(HumanBodyBones.Head); +transform.localRotation = rotation; +``` + +```{admonition} ランタイムロード専用 +:class: warn + +`v0.103` 現在この機能は Editor で Asset 生成されたモデルでは動作しません。 +初期姿勢を確実に取得する方法を検討中です。 +``` + +vrm-0.x でプログラムから HumanoidBone に回転クォータニオンを代入していた +場所を `Vrm10RuntimeControlRig.GetBoneTransform` で置きかえることで +同じポーズを当てることができます。 + +## 動作の説明 + +毎フレーム `Vrm10Instance` が `Vrm10RuntimeControlRig` からVRM-1.0のヒエラルキーにポーズを転送します。 + +`Vrm10RuntimeControlRig` が初期姿勢を記憶していて、 +`正規化ポーズ localRotation => 初期姿勢を加味 => 元のヒエラルキーの localRotation` に変換という処理をします。 + +初期姿勢は `T-Pose` ですが、 `VRM-0.X` のように正規化されている必要がありません。 diff --git a/docs/api/vrm1_expression.md b/docs/vrm1/vrm1_expression.md similarity index 100% rename from docs/api/vrm1_expression.md rename to docs/vrm1/vrm1_expression.md diff --git a/docs/api/vrm1_firstperson.md b/docs/vrm1/vrm1_firstperson.md similarity index 100% rename from docs/api/vrm1_firstperson.md rename to docs/vrm1/vrm1_firstperson.md diff --git a/docs/api/vrm1_runtime_load.md b/docs/vrm1/vrm1_load.md similarity index 53% rename from docs/api/vrm1_runtime_load.md rename to docs/vrm1/vrm1_load.md index 811d65f4e..413b3c763 100644 --- a/docs/api/vrm1_runtime_load.md +++ b/docs/vrm1/vrm1_load.md @@ -1,46 +1,23 @@ # RuntimeLoad -## Runtime Normalization (from `v0.92.0`) +`Assets\VRM10\Samples\VRM10Viewer\VRM10ViewerUI.cs` -`VRM-1.0` は、ノードの `回転・スケールの削除` をしません。 -後方互換性のため、 `RuntimeLoad` 時に動的に `回転・スケールの削除` する機能を提供します。 - -> `VRM-0.x` のエクスポート時の正規化に相当する処理です - -以下のように doNormalize に true を付与してください。 +## RuntimeLoad ```csharp -using (var loader = new Vrm10Importer(vrm, - // normalize option - doNormalize: true)) -{ - RuntimeGltfInstance instance = await loader.LoadAsync(); - return instance; -} +Vrm10Instance vrm10Instance = await Vrm10.LoadPathAsync(path); ``` ## Migration(VRM-0 to VRM-1) `VRM-1.0` は、 `VRM-0.x` もロードできます。 その場合、あたらしい meta への変換が発生し互換性の無い部分はすべて `不許可` の値になります。 -このため、変換前のライセンスにアクセスする API を提供します。 +変換前のライセンスにアクセスできます。 サンプルの `Assets\VRM10\Samples\VRM10Viewer\VRM10ViewerUI.cs` も参照してください。 ```csharp -static IMaterialDescriptorGenerator GetVrmMaterialDescriptorGenerator(bool useUrp) -{ - if (useUrp) - { - return new Vrm10UrpMaterialDescriptorGenerator(); - } - else - { - return new Vrm10MaterialDescriptorGenerator(); - } -} - -async Task LoadAsync(string path) +async Task LoadAsync(string path) { GltfData data = new AutoGltfFileParser(path).Parse(); @@ -48,8 +25,7 @@ async Task LoadAsync(string path) if (Vrm10Data.TryParseOrMigrate(data, doMigrate: true, out Vrm10Data vrm)) { // vrm - using (var loader = new Vrm10Importer(vrm, - materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn))) + using (var loader = new Vrm10Importer(vrm)) { // migrate しても thumbnail は同じ var thumbnail = await loader.LoadVrmThumbnailAsync(); @@ -67,7 +43,7 @@ async Task LoadAsync(string path) // モデルをロード RuntimeGltfInstance instance = await loader.LoadAsync(); - return instance; + return instance.GetComponent(); } } else{ diff --git a/docs/api/vrm1_lookat.md b/docs/vrm1/vrm1_lookat.md similarity index 100% rename from docs/api/vrm1_lookat.md rename to docs/vrm1/vrm1_lookat.md