mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-25 07:28:51 -05:00
move Retarget to API
This commit is contained in:
parent
b74f28a4e1
commit
27b284bdb6
|
|
@ -39,6 +39,8 @@ namespace UniVRM10
|
|||
public Vrm10RuntimeExpression Expression { get; }
|
||||
public Vrm10RuntimeLookAt LookAt { get; }
|
||||
|
||||
public IVrmAnimation VrmAnimation { get; set; }
|
||||
|
||||
public Vector3 ExternalForce
|
||||
{
|
||||
get => m_externalData.ExternalForce;
|
||||
|
|
@ -178,7 +180,8 @@ namespace UniVRM10
|
|||
/// <summary>
|
||||
/// 毎フレーム関連コンポーネントを解決する
|
||||
///
|
||||
/// * Contraint
|
||||
/// * Update from VrmAnimation
|
||||
/// * Constraint
|
||||
/// * Spring
|
||||
/// * LookAt
|
||||
/// * Expression
|
||||
|
|
@ -186,6 +189,23 @@ namespace UniVRM10
|
|||
/// </summary>
|
||||
public void Process()
|
||||
{
|
||||
// 0. Update From VrmAnimation
|
||||
if (VrmAnimation != null)
|
||||
{
|
||||
// copy pose
|
||||
{
|
||||
VRM10Retarget.Retarget(VrmAnimation.ControlRig, (ControlRig, ControlRig));
|
||||
}
|
||||
|
||||
// update expressions
|
||||
foreach (var (k, v) in VrmAnimation.ExpressionMap)
|
||||
{
|
||||
Expression.SetWeight(k, v());
|
||||
}
|
||||
|
||||
// TODO: look at target
|
||||
}
|
||||
|
||||
// 1. Control Rig
|
||||
ControlRig?.Process();
|
||||
|
||||
|
|
@ -198,7 +218,7 @@ namespace UniVRM10
|
|||
// 3. Gaze control
|
||||
LookAt.Process(m_target.LookAtTargetType, m_target.LookAtTarget);
|
||||
|
||||
// 4. Expression
|
||||
// 4. Apply Expression
|
||||
Expression.Process();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
public interface IVrmAnimation : IDisposable
|
||||
{
|
||||
(INormalizedPoseProvider, ITPoseProvider) ControlRig { get; }
|
||||
IReadOnlyDictionary<ExpressionKey, Func<float>> ExpressionMap { get; }
|
||||
public void ShowBoxMan(bool enable);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bd8db8a4bdc3e7f40a0a7a1bcd554137
|
||||
guid: 1b2654d5824889e418b2f9bdc9456680
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -5,11 +5,30 @@ using UnityEngine;
|
|||
|
||||
namespace UniVRM10
|
||||
{
|
||||
public class VrmAnimationInstance : MonoBehaviour
|
||||
public class VrmAnimationInstance : MonoBehaviour, IVrmAnimation
|
||||
{
|
||||
public SkinnedMeshRenderer BoxMan;
|
||||
public (INormalizedPoseProvider, ITPoseProvider) ControlRig;
|
||||
public Dictionary<ExpressionKey, Func<float>> ExpressionMap = new();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
Destroy(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
DestroyImmediate(this);
|
||||
}
|
||||
}
|
||||
|
||||
public (INormalizedPoseProvider, ITPoseProvider) ControlRig { get; set; }
|
||||
Dictionary<ExpressionKey, Func<float>> _ExpressionMap = new();
|
||||
public IReadOnlyDictionary<ExpressionKey, Func<float>> ExpressionMap => _ExpressionMap;
|
||||
|
||||
public void ShowBoxMan(bool enable)
|
||||
{
|
||||
BoxMan.enabled = enable;
|
||||
}
|
||||
|
||||
public float preset_happy;
|
||||
public float preset_angry;
|
||||
|
|
@ -163,137 +182,137 @@ namespace UniVRM10
|
|||
{
|
||||
switch (key.Preset)
|
||||
{
|
||||
case ExpressionPreset.happy: ExpressionMap.Add(key, () => preset_happy); break;
|
||||
case ExpressionPreset.angry: ExpressionMap.Add(key, () => preset_angry); break;
|
||||
case ExpressionPreset.sad: ExpressionMap.Add(key, () => preset_sad); break;
|
||||
case ExpressionPreset.relaxed: ExpressionMap.Add(key, () => preset_relaxed); break;
|
||||
case ExpressionPreset.surprised: ExpressionMap.Add(key, () => preset_surprised); break;
|
||||
case ExpressionPreset.aa: ExpressionMap.Add(key, () => preset_aa); break;
|
||||
case ExpressionPreset.ih: ExpressionMap.Add(key, () => preset_ih); break;
|
||||
case ExpressionPreset.ou: ExpressionMap.Add(key, () => preset_ou); break;
|
||||
case ExpressionPreset.ee: ExpressionMap.Add(key, () => preset_ee); break;
|
||||
case ExpressionPreset.oh: ExpressionMap.Add(key, () => preset_oh); break;
|
||||
case ExpressionPreset.blink: ExpressionMap.Add(key, () => preset_blink); break;
|
||||
case ExpressionPreset.blinkLeft: ExpressionMap.Add(key, () => preset_blinkleft); break;
|
||||
case ExpressionPreset.blinkRight: ExpressionMap.Add(key, () => preset_blinkright); break;
|
||||
// case ExpressionPreset.lookUp: ExpressionMap.Add(key, () => preset_lookUp); break;
|
||||
// case ExpressionPreset.lookDown: ExpressionMap.Add(key, () => preset_lookDown); break;
|
||||
// case ExpressionPreset.lookLeft: ExpressionMap.Add(key, () => preset_lookLeft); break;
|
||||
// case ExpressionPreset.lookRight: ExpressionMap.Add(key, () => preset_lookRight); break;
|
||||
case ExpressionPreset.neutral: ExpressionMap.Add(key, () => preset_neutral); break;
|
||||
case ExpressionPreset.happy: _ExpressionMap.Add(key, () => preset_happy); break;
|
||||
case ExpressionPreset.angry: _ExpressionMap.Add(key, () => preset_angry); break;
|
||||
case ExpressionPreset.sad: _ExpressionMap.Add(key, () => preset_sad); break;
|
||||
case ExpressionPreset.relaxed: _ExpressionMap.Add(key, () => preset_relaxed); break;
|
||||
case ExpressionPreset.surprised: _ExpressionMap.Add(key, () => preset_surprised); break;
|
||||
case ExpressionPreset.aa: _ExpressionMap.Add(key, () => preset_aa); break;
|
||||
case ExpressionPreset.ih: _ExpressionMap.Add(key, () => preset_ih); break;
|
||||
case ExpressionPreset.ou: _ExpressionMap.Add(key, () => preset_ou); break;
|
||||
case ExpressionPreset.ee: _ExpressionMap.Add(key, () => preset_ee); break;
|
||||
case ExpressionPreset.oh: _ExpressionMap.Add(key, () => preset_oh); break;
|
||||
case ExpressionPreset.blink: _ExpressionMap.Add(key, () => preset_blink); break;
|
||||
case ExpressionPreset.blinkLeft: _ExpressionMap.Add(key, () => preset_blinkleft); break;
|
||||
case ExpressionPreset.blinkRight: _ExpressionMap.Add(key, () => preset_blinkright); break;
|
||||
// case ExpressionPreset.lookUp: _ExpressionMap.Add(key, () => preset_lookUp); break;
|
||||
// case ExpressionPreset.lookDown: _ExpressionMap.Add(key, () => preset_lookDown); break;
|
||||
// case ExpressionPreset.lookLeft: _ExpressionMap.Add(key, () => preset_lookLeft); break;
|
||||
// case ExpressionPreset.lookRight: _ExpressionMap.Add(key, () => preset_lookRight); break;
|
||||
case ExpressionPreset.neutral: _ExpressionMap.Add(key, () => preset_neutral); break;
|
||||
case ExpressionPreset.custom:
|
||||
{
|
||||
switch (customIndex++)
|
||||
{
|
||||
case 00: ExpressionMap.Add(key, () => custom_00); break;
|
||||
case 01: ExpressionMap.Add(key, () => custom_01); break;
|
||||
case 02: ExpressionMap.Add(key, () => custom_02); break;
|
||||
case 03: ExpressionMap.Add(key, () => custom_03); break;
|
||||
case 04: ExpressionMap.Add(key, () => custom_04); break;
|
||||
case 05: ExpressionMap.Add(key, () => custom_05); break;
|
||||
case 06: ExpressionMap.Add(key, () => custom_06); break;
|
||||
case 07: ExpressionMap.Add(key, () => custom_07); break;
|
||||
case 08: ExpressionMap.Add(key, () => custom_08); break;
|
||||
case 09: ExpressionMap.Add(key, () => custom_09); break;
|
||||
case 00: _ExpressionMap.Add(key, () => custom_00); break;
|
||||
case 01: _ExpressionMap.Add(key, () => custom_01); break;
|
||||
case 02: _ExpressionMap.Add(key, () => custom_02); break;
|
||||
case 03: _ExpressionMap.Add(key, () => custom_03); break;
|
||||
case 04: _ExpressionMap.Add(key, () => custom_04); break;
|
||||
case 05: _ExpressionMap.Add(key, () => custom_05); break;
|
||||
case 06: _ExpressionMap.Add(key, () => custom_06); break;
|
||||
case 07: _ExpressionMap.Add(key, () => custom_07); break;
|
||||
case 08: _ExpressionMap.Add(key, () => custom_08); break;
|
||||
case 09: _ExpressionMap.Add(key, () => custom_09); break;
|
||||
|
||||
case 10: ExpressionMap.Add(key, () => custom_10); break;
|
||||
case 11: ExpressionMap.Add(key, () => custom_11); break;
|
||||
case 12: ExpressionMap.Add(key, () => custom_12); break;
|
||||
case 13: ExpressionMap.Add(key, () => custom_13); break;
|
||||
case 14: ExpressionMap.Add(key, () => custom_14); break;
|
||||
case 15: ExpressionMap.Add(key, () => custom_15); break;
|
||||
case 16: ExpressionMap.Add(key, () => custom_16); break;
|
||||
case 17: ExpressionMap.Add(key, () => custom_17); break;
|
||||
case 18: ExpressionMap.Add(key, () => custom_18); break;
|
||||
case 19: ExpressionMap.Add(key, () => custom_19); break;
|
||||
case 10: _ExpressionMap.Add(key, () => custom_10); break;
|
||||
case 11: _ExpressionMap.Add(key, () => custom_11); break;
|
||||
case 12: _ExpressionMap.Add(key, () => custom_12); break;
|
||||
case 13: _ExpressionMap.Add(key, () => custom_13); break;
|
||||
case 14: _ExpressionMap.Add(key, () => custom_14); break;
|
||||
case 15: _ExpressionMap.Add(key, () => custom_15); break;
|
||||
case 16: _ExpressionMap.Add(key, () => custom_16); break;
|
||||
case 17: _ExpressionMap.Add(key, () => custom_17); break;
|
||||
case 18: _ExpressionMap.Add(key, () => custom_18); break;
|
||||
case 19: _ExpressionMap.Add(key, () => custom_19); break;
|
||||
|
||||
case 20: ExpressionMap.Add(key, () => custom_20); break;
|
||||
case 21: ExpressionMap.Add(key, () => custom_21); break;
|
||||
case 22: ExpressionMap.Add(key, () => custom_22); break;
|
||||
case 23: ExpressionMap.Add(key, () => custom_23); break;
|
||||
case 24: ExpressionMap.Add(key, () => custom_24); break;
|
||||
case 25: ExpressionMap.Add(key, () => custom_25); break;
|
||||
case 26: ExpressionMap.Add(key, () => custom_26); break;
|
||||
case 27: ExpressionMap.Add(key, () => custom_27); break;
|
||||
case 28: ExpressionMap.Add(key, () => custom_28); break;
|
||||
case 29: ExpressionMap.Add(key, () => custom_29); break;
|
||||
case 20: _ExpressionMap.Add(key, () => custom_20); break;
|
||||
case 21: _ExpressionMap.Add(key, () => custom_21); break;
|
||||
case 22: _ExpressionMap.Add(key, () => custom_22); break;
|
||||
case 23: _ExpressionMap.Add(key, () => custom_23); break;
|
||||
case 24: _ExpressionMap.Add(key, () => custom_24); break;
|
||||
case 25: _ExpressionMap.Add(key, () => custom_25); break;
|
||||
case 26: _ExpressionMap.Add(key, () => custom_26); break;
|
||||
case 27: _ExpressionMap.Add(key, () => custom_27); break;
|
||||
case 28: _ExpressionMap.Add(key, () => custom_28); break;
|
||||
case 29: _ExpressionMap.Add(key, () => custom_29); break;
|
||||
|
||||
case 30: ExpressionMap.Add(key, () => custom_30); break;
|
||||
case 31: ExpressionMap.Add(key, () => custom_31); break;
|
||||
case 32: ExpressionMap.Add(key, () => custom_32); break;
|
||||
case 33: ExpressionMap.Add(key, () => custom_33); break;
|
||||
case 34: ExpressionMap.Add(key, () => custom_34); break;
|
||||
case 35: ExpressionMap.Add(key, () => custom_35); break;
|
||||
case 36: ExpressionMap.Add(key, () => custom_36); break;
|
||||
case 37: ExpressionMap.Add(key, () => custom_37); break;
|
||||
case 38: ExpressionMap.Add(key, () => custom_38); break;
|
||||
case 39: ExpressionMap.Add(key, () => custom_39); break;
|
||||
case 30: _ExpressionMap.Add(key, () => custom_30); break;
|
||||
case 31: _ExpressionMap.Add(key, () => custom_31); break;
|
||||
case 32: _ExpressionMap.Add(key, () => custom_32); break;
|
||||
case 33: _ExpressionMap.Add(key, () => custom_33); break;
|
||||
case 34: _ExpressionMap.Add(key, () => custom_34); break;
|
||||
case 35: _ExpressionMap.Add(key, () => custom_35); break;
|
||||
case 36: _ExpressionMap.Add(key, () => custom_36); break;
|
||||
case 37: _ExpressionMap.Add(key, () => custom_37); break;
|
||||
case 38: _ExpressionMap.Add(key, () => custom_38); break;
|
||||
case 39: _ExpressionMap.Add(key, () => custom_39); break;
|
||||
|
||||
case 40: ExpressionMap.Add(key, () => custom_40); break;
|
||||
case 41: ExpressionMap.Add(key, () => custom_41); break;
|
||||
case 42: ExpressionMap.Add(key, () => custom_42); break;
|
||||
case 43: ExpressionMap.Add(key, () => custom_43); break;
|
||||
case 44: ExpressionMap.Add(key, () => custom_44); break;
|
||||
case 45: ExpressionMap.Add(key, () => custom_45); break;
|
||||
case 46: ExpressionMap.Add(key, () => custom_46); break;
|
||||
case 47: ExpressionMap.Add(key, () => custom_47); break;
|
||||
case 48: ExpressionMap.Add(key, () => custom_48); break;
|
||||
case 49: ExpressionMap.Add(key, () => custom_49); break;
|
||||
case 40: _ExpressionMap.Add(key, () => custom_40); break;
|
||||
case 41: _ExpressionMap.Add(key, () => custom_41); break;
|
||||
case 42: _ExpressionMap.Add(key, () => custom_42); break;
|
||||
case 43: _ExpressionMap.Add(key, () => custom_43); break;
|
||||
case 44: _ExpressionMap.Add(key, () => custom_44); break;
|
||||
case 45: _ExpressionMap.Add(key, () => custom_45); break;
|
||||
case 46: _ExpressionMap.Add(key, () => custom_46); break;
|
||||
case 47: _ExpressionMap.Add(key, () => custom_47); break;
|
||||
case 48: _ExpressionMap.Add(key, () => custom_48); break;
|
||||
case 49: _ExpressionMap.Add(key, () => custom_49); break;
|
||||
|
||||
case 50: ExpressionMap.Add(key, () => custom_50); break;
|
||||
case 51: ExpressionMap.Add(key, () => custom_51); break;
|
||||
case 52: ExpressionMap.Add(key, () => custom_52); break;
|
||||
case 53: ExpressionMap.Add(key, () => custom_53); break;
|
||||
case 54: ExpressionMap.Add(key, () => custom_54); break;
|
||||
case 55: ExpressionMap.Add(key, () => custom_55); break;
|
||||
case 56: ExpressionMap.Add(key, () => custom_56); break;
|
||||
case 57: ExpressionMap.Add(key, () => custom_57); break;
|
||||
case 58: ExpressionMap.Add(key, () => custom_58); break;
|
||||
case 59: ExpressionMap.Add(key, () => custom_59); break;
|
||||
case 50: _ExpressionMap.Add(key, () => custom_50); break;
|
||||
case 51: _ExpressionMap.Add(key, () => custom_51); break;
|
||||
case 52: _ExpressionMap.Add(key, () => custom_52); break;
|
||||
case 53: _ExpressionMap.Add(key, () => custom_53); break;
|
||||
case 54: _ExpressionMap.Add(key, () => custom_54); break;
|
||||
case 55: _ExpressionMap.Add(key, () => custom_55); break;
|
||||
case 56: _ExpressionMap.Add(key, () => custom_56); break;
|
||||
case 57: _ExpressionMap.Add(key, () => custom_57); break;
|
||||
case 58: _ExpressionMap.Add(key, () => custom_58); break;
|
||||
case 59: _ExpressionMap.Add(key, () => custom_59); break;
|
||||
|
||||
case 60: ExpressionMap.Add(key, () => custom_60); break;
|
||||
case 61: ExpressionMap.Add(key, () => custom_61); break;
|
||||
case 62: ExpressionMap.Add(key, () => custom_62); break;
|
||||
case 63: ExpressionMap.Add(key, () => custom_63); break;
|
||||
case 64: ExpressionMap.Add(key, () => custom_64); break;
|
||||
case 65: ExpressionMap.Add(key, () => custom_65); break;
|
||||
case 66: ExpressionMap.Add(key, () => custom_66); break;
|
||||
case 67: ExpressionMap.Add(key, () => custom_67); break;
|
||||
case 68: ExpressionMap.Add(key, () => custom_68); break;
|
||||
case 69: ExpressionMap.Add(key, () => custom_69); break;
|
||||
case 60: _ExpressionMap.Add(key, () => custom_60); break;
|
||||
case 61: _ExpressionMap.Add(key, () => custom_61); break;
|
||||
case 62: _ExpressionMap.Add(key, () => custom_62); break;
|
||||
case 63: _ExpressionMap.Add(key, () => custom_63); break;
|
||||
case 64: _ExpressionMap.Add(key, () => custom_64); break;
|
||||
case 65: _ExpressionMap.Add(key, () => custom_65); break;
|
||||
case 66: _ExpressionMap.Add(key, () => custom_66); break;
|
||||
case 67: _ExpressionMap.Add(key, () => custom_67); break;
|
||||
case 68: _ExpressionMap.Add(key, () => custom_68); break;
|
||||
case 69: _ExpressionMap.Add(key, () => custom_69); break;
|
||||
|
||||
case 70: ExpressionMap.Add(key, () => custom_70); break;
|
||||
case 71: ExpressionMap.Add(key, () => custom_71); break;
|
||||
case 72: ExpressionMap.Add(key, () => custom_72); break;
|
||||
case 73: ExpressionMap.Add(key, () => custom_73); break;
|
||||
case 74: ExpressionMap.Add(key, () => custom_74); break;
|
||||
case 75: ExpressionMap.Add(key, () => custom_75); break;
|
||||
case 76: ExpressionMap.Add(key, () => custom_76); break;
|
||||
case 77: ExpressionMap.Add(key, () => custom_77); break;
|
||||
case 78: ExpressionMap.Add(key, () => custom_78); break;
|
||||
case 79: ExpressionMap.Add(key, () => custom_79); break;
|
||||
case 70: _ExpressionMap.Add(key, () => custom_70); break;
|
||||
case 71: _ExpressionMap.Add(key, () => custom_71); break;
|
||||
case 72: _ExpressionMap.Add(key, () => custom_72); break;
|
||||
case 73: _ExpressionMap.Add(key, () => custom_73); break;
|
||||
case 74: _ExpressionMap.Add(key, () => custom_74); break;
|
||||
case 75: _ExpressionMap.Add(key, () => custom_75); break;
|
||||
case 76: _ExpressionMap.Add(key, () => custom_76); break;
|
||||
case 77: _ExpressionMap.Add(key, () => custom_77); break;
|
||||
case 78: _ExpressionMap.Add(key, () => custom_78); break;
|
||||
case 79: _ExpressionMap.Add(key, () => custom_79); break;
|
||||
|
||||
case 80: ExpressionMap.Add(key, () => custom_80); break;
|
||||
case 81: ExpressionMap.Add(key, () => custom_81); break;
|
||||
case 82: ExpressionMap.Add(key, () => custom_82); break;
|
||||
case 83: ExpressionMap.Add(key, () => custom_83); break;
|
||||
case 84: ExpressionMap.Add(key, () => custom_84); break;
|
||||
case 85: ExpressionMap.Add(key, () => custom_85); break;
|
||||
case 86: ExpressionMap.Add(key, () => custom_86); break;
|
||||
case 87: ExpressionMap.Add(key, () => custom_87); break;
|
||||
case 88: ExpressionMap.Add(key, () => custom_88); break;
|
||||
case 89: ExpressionMap.Add(key, () => custom_89); break;
|
||||
case 80: _ExpressionMap.Add(key, () => custom_80); break;
|
||||
case 81: _ExpressionMap.Add(key, () => custom_81); break;
|
||||
case 82: _ExpressionMap.Add(key, () => custom_82); break;
|
||||
case 83: _ExpressionMap.Add(key, () => custom_83); break;
|
||||
case 84: _ExpressionMap.Add(key, () => custom_84); break;
|
||||
case 85: _ExpressionMap.Add(key, () => custom_85); break;
|
||||
case 86: _ExpressionMap.Add(key, () => custom_86); break;
|
||||
case 87: _ExpressionMap.Add(key, () => custom_87); break;
|
||||
case 88: _ExpressionMap.Add(key, () => custom_88); break;
|
||||
case 89: _ExpressionMap.Add(key, () => custom_89); break;
|
||||
|
||||
case 90: ExpressionMap.Add(key, () => custom_90); break;
|
||||
case 91: ExpressionMap.Add(key, () => custom_91); break;
|
||||
case 92: ExpressionMap.Add(key, () => custom_92); break;
|
||||
case 93: ExpressionMap.Add(key, () => custom_93); break;
|
||||
case 94: ExpressionMap.Add(key, () => custom_94); break;
|
||||
case 95: ExpressionMap.Add(key, () => custom_95); break;
|
||||
case 96: ExpressionMap.Add(key, () => custom_96); break;
|
||||
case 97: ExpressionMap.Add(key, () => custom_97); break;
|
||||
case 98: ExpressionMap.Add(key, () => custom_98); break;
|
||||
case 99: ExpressionMap.Add(key, () => custom_99); break;
|
||||
case 90: _ExpressionMap.Add(key, () => custom_90); break;
|
||||
case 91: _ExpressionMap.Add(key, () => custom_91); break;
|
||||
case 92: _ExpressionMap.Add(key, () => custom_92); break;
|
||||
case 93: _ExpressionMap.Add(key, () => custom_93); break;
|
||||
case 94: _ExpressionMap.Add(key, () => custom_94); break;
|
||||
case 95: _ExpressionMap.Add(key, () => custom_95); break;
|
||||
case 96: _ExpressionMap.Add(key, () => custom_96); break;
|
||||
case 97: _ExpressionMap.Add(key, () => custom_97); break;
|
||||
case 98: _ExpressionMap.Add(key, () => custom_98); break;
|
||||
case 99: _ExpressionMap.Add(key, () => custom_99); break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10.VRM10Viewer
|
||||
namespace UniVRM10
|
||||
{
|
||||
public static class VRM10Retarget
|
||||
{
|
||||
11
Assets/VRM10/Runtime/ControlRig/VRM10Retarget.cs.meta
Normal file
11
Assets/VRM10/Runtime/ControlRig/VRM10Retarget.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e44301f13c6a1e74ba0e5322262db259
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10.VRM10Viewer
|
||||
{
|
||||
public interface IMotion : IDisposable
|
||||
{
|
||||
(INormalizedPoseProvider, ITPoseProvider) ControlRig { get; }
|
||||
IDictionary<ExpressionKey, Transform> ExpressionMap { get; }
|
||||
|
||||
void ShowBoxMan(bool enable);
|
||||
}
|
||||
}
|
||||
8
Assets/VRM10_Samples/SimpleVrma.meta
Normal file
8
Assets/VRM10_Samples/SimpleVrma.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59ba601fea149ed498a9ca37af1d3c55
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.cs
Normal file
64
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using UniGLTF;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UniVRM10;
|
||||
using UniVRM10.VRM10Viewer;
|
||||
using VRMShaders;
|
||||
|
||||
public class SimpleVrma : MonoBehaviour
|
||||
{
|
||||
public Vrm10Instance Vrm;
|
||||
|
||||
public VrmAnimationInstance Vrma;
|
||||
|
||||
bool m_boxman = true;
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (GUILayout.Button("open vrm"))
|
||||
{
|
||||
var path = EditorUtility.OpenFilePanel("open vrm", "", "vrm");
|
||||
Debug.Log(path);
|
||||
LoadVrm(path);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("open vrma"))
|
||||
{
|
||||
var path = EditorUtility.OpenFilePanel("open vrma", "", "vrma");
|
||||
Debug.Log(path);
|
||||
LoadVrma(path);
|
||||
}
|
||||
|
||||
m_boxman = GUILayout.Toggle(m_boxman, "BoxMan");
|
||||
if (Vrma != null)
|
||||
{
|
||||
Vrma.BoxMan.enabled = m_boxman;
|
||||
}
|
||||
}
|
||||
|
||||
async void LoadVrm(string path)
|
||||
{
|
||||
Vrm = await Vrm10.LoadPathAsync(path,
|
||||
canLoadVrm0X: true,
|
||||
showMeshes: false,
|
||||
awaitCaller: new ImmediateCaller());
|
||||
|
||||
var instance = Vrm.GetComponent<RuntimeGltfInstance>();
|
||||
instance.ShowMeshes();
|
||||
}
|
||||
|
||||
async void LoadVrma(string path)
|
||||
{
|
||||
// load vrma
|
||||
using GltfData data = new AutoGltfFileParser(path).Parse();
|
||||
using var loader = new VrmAnimationImporter(data);
|
||||
var instance = await loader.LoadAsync(new ImmediateCaller());
|
||||
|
||||
Vrma = instance.GetComponent<VrmAnimationInstance>();
|
||||
Vrm.Runtime.VrmAnimation = Vrma;
|
||||
Debug.Log(Vrma);
|
||||
|
||||
var animation = Vrma.GetComponent<Animation>();
|
||||
animation.Play();
|
||||
}
|
||||
}
|
||||
11
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.cs.meta
Normal file
11
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e941e78669b3e784fa684c23441459fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
349
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.unity
Normal file
349
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.unity
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 256
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRDenoiserTypeDirect: 1
|
||||
m_PVRDenoiserTypeIndirect: 1
|
||||
m_PVRDenoiserTypeAO: 1
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &45959732
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 45959734}
|
||||
- component: {fileID: 45959733}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &45959733
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 45959732}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &45959734
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 45959732}
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &231202275
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 231202278}
|
||||
- component: {fileID: 231202277}
|
||||
- component: {fileID: 231202276}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &231202276
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 231202275}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &231202277
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 231202275}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &231202278
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 231202275}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2069542080
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2069542081}
|
||||
- component: {fileID: 2069542082}
|
||||
m_Layer: 0
|
||||
m_Name: vrma
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2069542081
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2069542080}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2069542082
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2069542080}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e941e78669b3e784fa684c23441459fb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Vrm: {fileID: 0}
|
||||
Vrma: {fileID: 0}
|
||||
7
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.unity.meta
Normal file
7
Assets/VRM10_Samples/SimpleVrma/SimpleVrma.unity.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ceefca1729da714e8f1163c8f391445
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -6,15 +6,17 @@ using UnityEngine;
|
|||
|
||||
namespace UniVRM10.VRM10Viewer
|
||||
{
|
||||
public class BvhMotion : IMotion
|
||||
public class BvhMotion : IVrmAnimation
|
||||
{
|
||||
UniHumanoid.BvhImporterContext m_context;
|
||||
public Transform Root => m_context?.Root.transform;
|
||||
public SkinnedMeshRenderer m_boxMan;
|
||||
public SkinnedMeshRenderer BoxMan => m_boxMan;
|
||||
(INormalizedPoseProvider, ITPoseProvider) m_controlRig;
|
||||
(INormalizedPoseProvider, ITPoseProvider) IMotion.ControlRig => m_controlRig;
|
||||
public IDictionary<ExpressionKey, Func<float>> ExpressionMap { get; } = new Dictionary<ExpressionKey, Func<float>>();
|
||||
(INormalizedPoseProvider, ITPoseProvider) IVrmAnimation.ControlRig => m_controlRig;
|
||||
IDictionary<ExpressionKey, Func<float>> _ExpressionMap = new Dictionary<ExpressionKey, Func<float>>();
|
||||
public IReadOnlyDictionary<ExpressionKey, Func<float>> ExpressionMap => (IReadOnlyDictionary<ExpressionKey, Func<float>>)_ExpressionMap;
|
||||
|
||||
public BvhMotion(UniHumanoid.BvhImporterContext context)
|
||||
{
|
||||
m_context = context;
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10.VRM10Viewer
|
||||
{
|
||||
public interface IMotion : IDisposable
|
||||
{
|
||||
(INormalizedPoseProvider, ITPoseProvider) ControlRig { get; }
|
||||
IDictionary<ExpressionKey, Func<float>> ExpressionMap { get; }
|
||||
|
||||
void ShowBoxMan(bool enable);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,12 +8,12 @@ using VRMShaders;
|
|||
|
||||
namespace UniVRM10.VRM10Viewer
|
||||
{
|
||||
public class VrmAnimation : IMotion
|
||||
public class VrmAnimation : IVrmAnimation
|
||||
{
|
||||
private readonly VrmAnimationInstance m_instance;
|
||||
|
||||
(INormalizedPoseProvider, ITPoseProvider) IMotion.ControlRig => m_instance.ControlRig;
|
||||
IDictionary<ExpressionKey, Func<float>> IMotion.ExpressionMap => m_instance.ExpressionMap;
|
||||
(INormalizedPoseProvider, ITPoseProvider) IVrmAnimation.ControlRig => m_instance.ControlRig;
|
||||
IReadOnlyDictionary<ExpressionKey, Func<float>> IVrmAnimation.ExpressionMap => m_instance.ExpressionMap;
|
||||
|
||||
public VrmAnimation(VrmAnimationInstance instance,
|
||||
Vector3 hips = default, Dictionary<HumanBodyBones, Quaternion> map = null)
|
||||
|
|
@ -58,13 +58,6 @@ namespace UniVRM10.VRM10Viewer
|
|||
}
|
||||
}
|
||||
|
||||
public static async Task<VrmAnimation> LoadVrmAnimationFromPathAsync(string path)
|
||||
{
|
||||
using GltfData data = new AutoGltfFileParser(path).Parse();
|
||||
using var loader = new VrmAnimationImporter(data);
|
||||
var instance = await loader.LoadAsync(new ImmediateCaller());
|
||||
return new VrmAnimation(instance.GetComponent<VrmAnimationInstance>());
|
||||
}
|
||||
|
||||
static Vector3 ToVec3(JsonNode j)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using VRMShaders;
|
||||
using UniJSON;
|
||||
|
||||
namespace UniVRM10.VRM10Viewer
|
||||
{
|
||||
|
|
@ -50,8 +53,8 @@ namespace UniVRM10.VRM10Viewer
|
|||
|
||||
GameObject Root = default;
|
||||
|
||||
IMotion m_src = default;
|
||||
public IMotion Motion
|
||||
IVrmAnimation m_src = default;
|
||||
public IVrmAnimation Motion
|
||||
{
|
||||
get { return m_src; }
|
||||
set
|
||||
|
|
@ -431,7 +434,11 @@ namespace UniVRM10.VRM10Viewer
|
|||
}
|
||||
|
||||
// gltf, glb etc...
|
||||
Motion = await VrmAnimation.LoadVrmAnimationFromPathAsync(path);
|
||||
using GltfData data = new AutoGltfFileParser(path).Parse();
|
||||
using var loader = new VrmAnimationImporter(data);
|
||||
var instance = await loader.LoadAsync(new ImmediateCaller());
|
||||
Motion = instance.GetComponent<VrmAnimationInstance>();
|
||||
instance.GetComponent<Animation>().Play();
|
||||
}
|
||||
|
||||
async void OnPastePoseClicked()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user