diff --git a/Editor/LyumaAv3EditorSupport.cs b/Editor/LyumaAv3EditorSupport.cs index 52c8a90..3db0853 100644 --- a/Editor/LyumaAv3EditorSupport.cs +++ b/Editor/LyumaAv3EditorSupport.cs @@ -25,7 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using UnityEditor.Animations; using UnityEditor.Playables; using UnityEngine.Playables; -using VRC.SDK3.Components; +using VRC.SDK3.Avatars.Components; [InitializeOnLoadAttribute] public static class LyumaAv3EditorSupport diff --git a/README.md b/README.md index 178bf76..15e8fd1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # Avatar 3.0 Emulator +**NEW IN v0.5.0**: UPDATED _July 24, 2020_ for the Open Beta with support for VRCExpressionParameters! + +Documentation here: https://docs.vrchat.com/v2020.3.2/docs/what-is-avatars-30 + This is an emulator for Avatars 3.0 reimplemented in the unity editor on top the the unity [PlayableGraph](https://docs.unity3d.com/Manual/Playables-Graph.html) API, using the [AnimationControllerPlayable](https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Animations.AnimatorControllerPlayable.html) and [AnimationLayerMixerPlayable](https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Animations.AnimationLayerMixerPlayable.html) APIs. ## Features: diff --git a/Scripts/LyumaAv3Emulator.cs b/Scripts/LyumaAv3Emulator.cs index 0ad83cc..2dfe6d3 100644 --- a/Scripts/LyumaAv3Emulator.cs +++ b/Scripts/LyumaAv3Emulator.cs @@ -19,6 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using UnityEngine; using System.Collections.Generic; +using VRC.SDK3.Avatars.Components; public class LyumaAv3Emulator : MonoBehaviour { @@ -30,7 +31,7 @@ public class LyumaAv3Emulator : MonoBehaviour private void Start() { - VRC.SDK3.Components.VRCAvatarDescriptor[] avatars = FindObjectsOfType(); + VRCAvatarDescriptor[] avatars = FindObjectsOfType(); Debug.Log("drv len "+avatars.Length); foreach (var avadesc in avatars) { diff --git a/Scripts/LyumaAv3Runtime.cs b/Scripts/LyumaAv3Runtime.cs index b063487..658e778 100644 --- a/Scripts/LyumaAv3Runtime.cs +++ b/Scripts/LyumaAv3Runtime.cs @@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using UnityEngine; using UnityEngine.Animations; using UnityEngine.Playables; -using VRC.SDK3.Components; -using VRC.SDK3.ScriptableObjects; +using VRC.SDK3.Avatars.Components; +using VRC.SDK3.Avatars.ScriptableObjects; [RequireComponent(typeof(Animator))] public class LyumaAv3Runtime : MonoBehaviour @@ -47,7 +47,7 @@ public class LyumaAv3Runtime : MonoBehaviour AnimationLayerMixerPlayable playableMixer; PlayableGraph playableGraph; VRCExpressionsMenu expressionsMenu; - VRCStageParameters stageParameters; + VRCExpressionParameters stageParameters; int sittingIndex; int fxIndex; int actionIndex; @@ -95,8 +95,12 @@ public enum GestureIndex { public VisemeIndex VisemeDD; private int Viseme; public GestureIndex GestureLeft; + public int GestureLeftIdx; + private char GestureLeftIdxInt; [Range(0, 1)] public float GestureLeftWeight; public GestureIndex GestureRight; + public int GestureRightIdx; + private char GestureRightIdxInt; [Range(0, 1)] public float GestureRightWeight; public Vector3 Velocity; [Range(-1, 1)] public float AngularY; @@ -118,14 +122,15 @@ public enum GestureIndex { public Vector3 ViewPosition; float AvatarScaleFactor; public VRCAnimatorTrackingControl.TrackingType trackingHead; - public VRCAnimatorTrackingControl.TrackingType trackingRightFingers; - public VRCAnimatorTrackingControl.TrackingType trackingLeftFingers; - public VRCAnimatorTrackingControl.TrackingType trackingEyes; - public VRCAnimatorTrackingControl.TrackingType trackingLeftFoot; - public VRCAnimatorTrackingControl.TrackingType trackingHip; - public VRCAnimatorTrackingControl.TrackingType trackingRightHand; public VRCAnimatorTrackingControl.TrackingType trackingLeftHand; + public VRCAnimatorTrackingControl.TrackingType trackingRightHand; + public VRCAnimatorTrackingControl.TrackingType trackingHip; + public VRCAnimatorTrackingControl.TrackingType trackingLeftFoot; public VRCAnimatorTrackingControl.TrackingType trackingRightFoot; + public VRCAnimatorTrackingControl.TrackingType trackingLeftFingers; + public VRCAnimatorTrackingControl.TrackingType trackingRightFingers; + public VRCAnimatorTrackingControl.TrackingType trackingEyesAndEyelids; + public VRCAnimatorTrackingControl.TrackingType trackingMouthAndJaw; [Serializable] public class FloatParam @@ -407,6 +412,10 @@ static LyumaAv3Runtime () { return; } + if (behaviour.trackingMouth != VRCAnimatorTrackingControl.TrackingType.NoChange) + { + runtime.trackingMouthAndJaw = behaviour.trackingMouth; + } if (behaviour.trackingHead != VRCAnimatorTrackingControl.TrackingType.NoChange) { runtime.trackingHead = behaviour.trackingHead; @@ -417,7 +426,7 @@ static LyumaAv3Runtime () { } if (behaviour.trackingEyes != VRCAnimatorTrackingControl.TrackingType.NoChange) { - runtime.trackingEyes = behaviour.trackingEyes; + runtime.trackingEyesAndEyelids = behaviour.trackingEyes; } if (behaviour.trackingLeftFingers != VRCAnimatorTrackingControl.TrackingType.NoChange) { @@ -490,7 +499,7 @@ void Awake() expressionsMenu = avadesc.expressionsMenu; if (expressionsMenu != null) { - stageParameters = expressionsMenu.stageParameters; + stageParameters = avadesc.expressionParameters; } origAnimatorController = animator.runtimeAnimatorController; animator.runtimeAnimatorController = null; @@ -545,7 +554,7 @@ void Awake() if (stageParameters != null) { int stageId = 0; - foreach (var stageParam in stageParameters.stageParameters) + foreach (var stageParam in stageParameters.parameters) { stageId++; // one-indexed if (stageParam.name == null || stageParam.name.Length == 0) { @@ -728,8 +737,12 @@ void Update() Viseme = VisemeI = AvatarSyncSource.Viseme; VisemeDD = (VisemeIndex)Viseme; GestureLeft = AvatarSyncSource.GestureLeft; + GestureLeftIdx = AvatarSyncSource.GestureLeftIdx; + GestureLeftIdxInt = AvatarSyncSource.GestureLeftIdxInt; GestureLeftWeight = AvatarSyncSource.GestureLeftWeight; GestureRight = AvatarSyncSource.GestureRight; + GestureRightIdx = AvatarSyncSource.GestureRightIdx; + GestureRightIdxInt = AvatarSyncSource.GestureRightIdxInt; GestureRightWeight = AvatarSyncSource.GestureRightWeight; Velocity = AvatarSyncSource.Velocity; AngularY = AvatarSyncSource.AngularY; @@ -763,6 +776,24 @@ void Update() Viseme = (int)VisemeDD; VisemeI = Viseme; } + if (GestureLeftIdx != GestureLeftIdxInt) { + GestureLeft = (GestureIndex)GestureLeftIdx; + GestureLeftIdx = (int)GestureLeft; + GestureLeftIdxInt = (char)GestureLeftIdx; + } + if ((int)GestureLeft != (int)GestureLeftIdxInt) { + GestureLeftIdx = (int)GestureLeft; + GestureLeftIdxInt = (char)GestureLeftIdx; + } + if (GestureRightIdx != GestureRightIdxInt) { + GestureRight = (GestureIndex)GestureRightIdx; + GestureRightIdx = (int)GestureRight; + GestureRightIdxInt = (char)GestureRightIdx; + } + if ((int)GestureRight != (int)GestureRightIdxInt) { + GestureRightIdx = (int)GestureRight; + GestureRightIdxInt = (char)GestureRightIdx; + } IsLocal = AvatarSyncSource == this; int whichcontroller = 0; foreach (AnimatorControllerPlayable playable in playables) @@ -825,7 +856,9 @@ void Update() if (parameterIndices.TryGetValue("GestureLeft", out paramid)) { if (paramterInts.TryGetValue(paramid, out iparam) && iparam != playable.GetInteger(paramid)) { - GestureLeft = (GestureIndex)playable.GetInteger(paramid); + GestureLeftIdx = playable.GetInteger(paramid); + GestureLeftIdxInt = (char)GestureLeftIdx; + GestureLeft = (GestureIndex)GestureLeftIdx; } playable.SetInteger(paramid, (int)GestureLeft); paramterInts[paramid] = (int)GestureLeft; @@ -841,7 +874,9 @@ void Update() if (parameterIndices.TryGetValue("GestureRight", out paramid)) { if (paramterInts.TryGetValue(paramid, out iparam) && iparam != playable.GetInteger(paramid)) { - GestureRight = (GestureIndex)playable.GetInteger(paramid); + GestureRightIdx = playable.GetInteger(paramid); + GestureRightIdxInt = (char)GestureRightIdx; + GestureRight = (GestureIndex)GestureRightIdx; } playable.SetInteger(paramid, (int)GestureRight); paramterInts[paramid] = (int)GestureRight;