From 302c5a07e67f5ed2f46232ed0417bad03668ba77 Mon Sep 17 00:00:00 2001 From: Riccardo Zaglia Date: Sun, 24 Dec 2023 19:36:50 +0100 Subject: [PATCH] feat: :sparkles: Support FB face tracking 2; fix eye tracking --- ALVRModule/ALVRModule.cs | 41 +++++++++++++++++++++++++++++----------- metadata.json | 2 +- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ALVRModule/ALVRModule.cs b/ALVRModule/ALVRModule.cs index 6ff62ff..002d015 100644 --- a/ALVRModule/ALVRModule.cs +++ b/ALVRModule/ALVRModule.cs @@ -77,7 +77,15 @@ public enum FaceFb UpperLidRaiserR = 60, UpperLipRaiserL = 61, UpperLipRaiserR = 62, - FaceFbMax = 63 + TongueTipInterdental = 63, + TongueTipAlveolar = 64, + TongueFrontDorsalPalate = 65, + TongueMidDorsalPalate = 66, + TongueBackDorsalVelar = 67, + TongueOutFb = 68, + TongueRetreat = 69, + Face1FbMax = 63, + Face2FbMax = 70, } public class ALVRModule : ExtTrackingModule @@ -171,9 +179,14 @@ private static void SetCombEyesQuatParams(float[] p) SetEyesQuatParams(array); } - private static void SetFaceFbParams(float[] p) + static void SetParam(float[] data, FaceFb input, UnifiedExpressions outputType) { - Debug.Assert(p.Length == (int)FaceFbMax); + UnifiedTracking.Data.Shapes[(int)outputType].Weight = data[(int)input]; + } + + private static void SetFace1FbParams(float[] p) + { + // Debug.Assert(p.Length == (int)Face1FbMax); var eye = UnifiedTracking.Data.Eye; var expr = UnifiedTracking.Data.Shapes; @@ -181,10 +194,6 @@ private static void SetFaceFbParams(float[] p) eye.Left.Openness = 1.0f - (float)Math.Max(0, Math.Min(1, p[(int)EyesClosedL] + p[(int)EyesClosedL] * p[(int)LidTightenerL])); eye.Right.Openness = 1.0f - (float)Math.Max(0, Math.Min(1, p[(int)EyesClosedR] + p[(int)EyesClosedR] * p[(int)LidTightenerR])); - static void SetParam(float[] data, FaceFb input, UnifiedExpressions outputType) - { - UnifiedTracking.Data.Shapes[(int)outputType].Weight = data[(int)input]; - } // Eyelids SetParam(p, LidTightenerR, EyeSquintRight); @@ -266,7 +275,6 @@ static void SetParam(float[] data, FaceFb input, UnifiedExpressions outputType) SetParam(p, DimplerL, MouthDimpleLeft); SetParam(p, DimplerR, MouthDimpleRight); - SetParam(p, ChinRaiserT, MouthRaiserUpper); SetParam(p, ChinRaiserB, MouthRaiserLower); SetParam(p, LipPressorR, MouthPressRight); @@ -275,6 +283,14 @@ static void SetParam(float[] data, FaceFb input, UnifiedExpressions outputType) SetParam(p, LipTightenerL, MouthTightenerLeft); } + private static void SetFace2FbParams(float[] p) { + Debug.Assert(p.Length == (int)Face2FbMax); + + SetFace1FbParams(p); + + SetParam(p, TongueOutFb, TongueOut); + } + public override void Update() { byte[] packet; @@ -297,13 +313,16 @@ public override void Update() switch (str) { case "EyesQuat": - SetFaceFbParams(GetParams(packet, ref cursor, 8)); + SetEyesQuatParams(GetParams(packet, ref cursor, 8)); break; case "CombQuat": - SetFaceFbParams(GetParams(packet, ref cursor, 4)); + SetCombEyesQuatParams(GetParams(packet, ref cursor, 4)); break; case "FaceFb\0\0": - SetFaceFbParams(GetParams(packet, ref cursor, (int)FaceFbMax)); + SetFace1FbParams(GetParams(packet, ref cursor, (int)Face1FbMax)); + break; + case "Face2Fb\0": + SetFace2FbParams(GetParams(packet, ref cursor, (int)Face2FbMax)); break; default: Logger.LogError("[ALVR Module] Unrecognized prefix"); diff --git a/metadata.json b/metadata.json index c58fae6..321816b 100644 --- a/metadata.json +++ b/metadata.json @@ -4,7 +4,7 @@ "DllFileName": "ALVRModule.dll", "Downloads": 0, "DownloadUrl": "https://github.com/alvr-org/VRCFT-ALVR/releases/download/v1.2.0/ALVRModule.zip", - "LastUpdated": "2023-11-08T07:36:37Z", + "LastUpdated": "2023-12-24T18:33:19Z", "ModuleDescription": "VRCFaceTracking module for ALVR support", "ModuleName": "ALVR Module", "ModulePageUrl": "https://github.com/alvr-org/VRCFT-ALVR",