|
1 |
| -namespace VRCFaceTracking.Babble; |
2 |
| -public partial class BabbleOSC |
| 1 | +using Newtonsoft.Json; |
| 2 | +using System.Reflection; |
| 3 | +using VRCFaceTracking.Core.Params.Expressions; |
| 4 | +using VRCFaceTracking.Babble.Collections; |
| 5 | + |
| 6 | +namespace VRCFaceTracking.Babble; |
| 7 | +public static class BabbleExpressions |
3 | 8 | {
|
4 |
| - public Dictionary<string, float> BabbleExpressionMap = new() |
| 9 | + private const string BabbleExpressionsPath = "BabbleExpressions.json"; |
| 10 | + |
| 11 | + public static readonly TwoKeyDictionary<UnifiedExpressions, string, float> BabbleExpressionMap; |
| 12 | + static BabbleExpressions() |
5 | 13 | {
|
6 |
| - { "/cheekPuffLeft", 0f }, |
7 |
| - { "/cheekPuffRight", 0f }, |
8 |
| - { "/cheekSuckLeft", 0f }, |
9 |
| - { "/cheekSuckRight", 0f }, |
10 |
| - { "/jawOpen", 0f }, |
11 |
| - { "/jawForward", 0f }, |
12 |
| - { "/jawLeft", 0f }, |
13 |
| - { "/jawRight", 0f }, |
14 |
| - { "/noseSneerLeft", 0f }, |
15 |
| - { "/noseSnerrRight", 0f }, |
16 |
| - { "/mouthFunnel", 0f }, |
17 |
| - { "/mouthPucker", 0f }, |
18 |
| - { "/mouthLeft", 0f }, |
19 |
| - { "/mouthRight", 0f }, |
20 |
| - { "/mouthRollUpper", 0f }, |
21 |
| - { "/mouthRollLower", 0f }, |
22 |
| - { "/mouthShrugUpper", 0f }, |
23 |
| - { "/mouthShrugLower", 0f }, |
24 |
| - { "/mouthClose", 0f }, |
25 |
| - { "/mouthSmileLeft", 0f }, |
26 |
| - { "/mouthSmileRight", 0f }, |
27 |
| - { "/mouthFrownLeft", 0f }, |
28 |
| - { "/mouthFrownRight", 0f }, |
29 |
| - { "/mouthDimpleLeft", 0f }, |
30 |
| - { "/mouthDimpleRight", 0f }, |
31 |
| - { "/mouthUpperUpLeft", 0f }, |
32 |
| - { "/mouthUpperUpRight", 0f }, |
33 |
| - { "/mouthLowerDownLeft", 0f }, |
34 |
| - { "/mouthLowerDownRight", 0f }, |
35 |
| - { "/mouthPressLeft", 0f }, |
36 |
| - { "/mouthPressRight", 0f }, |
37 |
| - { "/mouthStretchLeft", 0f }, |
38 |
| - { "/mouthStretchRight", 0f }, |
39 |
| - { "/tongueOut", 0f }, |
40 |
| - { "/tongueUp", 0f }, |
41 |
| - { "/tongueDown", 0f }, |
42 |
| - { "/tongueLeft", 0f }, |
43 |
| - { "/tongueRight", 0f }, |
44 |
| - { "/tongueRoll", 0f }, |
45 |
| - { "/tongueBendDown", 0f }, |
46 |
| - { "/tongueCurlUp", 0f }, |
47 |
| - { "/tongueSquish", 0f }, |
48 |
| - { "/tongueFlat", 0f }, |
49 |
| - { "/tongueTwistLeft", 0f }, |
50 |
| - { "/tognueTwistRight", 0f } |
| 14 | + var expressions = Path.Combine( |
| 15 | + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, |
| 16 | + BabbleExpressionsPath); |
| 17 | + var converter = new TwoKeyDictionaryConverter<UnifiedExpressions, string, float>(); |
| 18 | + if (!File.Exists(expressions)) |
| 19 | + { |
| 20 | + string json = JsonConvert.SerializeObject( |
| 21 | + DefaultBabbleExpressionMap, converter); |
| 22 | + File.WriteAllText(expressions, json); |
| 23 | + } |
| 24 | + |
| 25 | + BabbleExpressionMap = JsonConvert.DeserializeObject |
| 26 | + <TwoKeyDictionary<UnifiedExpressions, string, float>> |
| 27 | + (File.ReadAllText(expressions), converter)!; |
| 28 | + } |
| 29 | + |
| 30 | + private static readonly TwoKeyDictionary<UnifiedExpressions, string, float> DefaultBabbleExpressionMap = new() |
| 31 | + { |
| 32 | + { UnifiedExpressions.CheekPuffLeft, "/cheekPuffLeft", 0f }, |
| 33 | + { UnifiedExpressions.CheekPuffRight, "/cheekPuffRight", 0f }, |
| 34 | + { UnifiedExpressions.CheekSuckLeft, "/cheekSuckLeft", 0f }, |
| 35 | + { UnifiedExpressions.CheekSuckRight, "/cheekSuckRight", 0f }, |
| 36 | + { UnifiedExpressions.JawOpen, "/jawOpen", 0f }, |
| 37 | + { UnifiedExpressions.JawForward, "/jawForward", 0f }, |
| 38 | + { UnifiedExpressions.JawLeft, "/jawLeft", 0f }, |
| 39 | + { UnifiedExpressions.JawRight, "/jawRight", 0f }, |
| 40 | + { UnifiedExpressions.NoseSneerLeft, "/noseSneerLeft", 0f }, |
| 41 | + { UnifiedExpressions.NoseSneerRight, "/noseSneerRight", 0f }, |
| 42 | + { UnifiedExpressions.LipFunnelLowerLeft, "/mouthFunnel", 0f }, |
| 43 | + { UnifiedExpressions.LipFunnelLowerRight, "/mouthFunnel", 0f }, |
| 44 | + { UnifiedExpressions.LipFunnelUpperLeft, "/mouthFunnel", 0f }, |
| 45 | + { UnifiedExpressions.LipFunnelUpperRight, "/mouthFunnel", 0f }, |
| 46 | + { UnifiedExpressions.LipPuckerLowerLeft, "/mouthPucker", 0f }, |
| 47 | + { UnifiedExpressions.LipPuckerLowerRight, "/mouthPucker", 0f }, |
| 48 | + { UnifiedExpressions.LipPuckerUpperLeft, "/mouthPucker", 0f }, |
| 49 | + { UnifiedExpressions.LipPuckerUpperRight, "/mouthPucker", 0f }, |
| 50 | + { UnifiedExpressions.MouthPressLeft, "/mouthLeft", 0f }, |
| 51 | + { UnifiedExpressions.MouthPressRight, "/mouthRight", 0f }, |
| 52 | + { UnifiedExpressions.LipSuckUpperLeft, "/mouthRollUpper", 0f }, |
| 53 | + { UnifiedExpressions.LipSuckUpperRight, "/mouthRollUpper", 0f }, |
| 54 | + { UnifiedExpressions.LipSuckLowerLeft, "/mouthRollLower", 0f }, |
| 55 | + { UnifiedExpressions.LipSuckLowerRight, "/mouthRollLower", 0f }, |
| 56 | + { UnifiedExpressions.MouthRaiserUpper, "/mouthShrugUpper", 0f }, |
| 57 | + { UnifiedExpressions.MouthRaiserLower, "/mouthShrugLower", 0f }, |
| 58 | + { UnifiedExpressions.MouthClosed, "/mouthClose", 0f }, |
| 59 | + { UnifiedExpressions.MouthCornerPullLeft, "/mouthSmileLeft", 0f }, |
| 60 | + { UnifiedExpressions.MouthCornerPullRight, "/mouthSmileRight", 0f }, |
| 61 | + { UnifiedExpressions.MouthFrownLeft, "/mouthFrownLeft", 0f }, |
| 62 | + { UnifiedExpressions.MouthFrownRight, "/mouthFrownRight", 0f }, |
| 63 | + { UnifiedExpressions.MouthDimpleLeft, "/mouthDimpleLeft", 0f }, |
| 64 | + { UnifiedExpressions.MouthDimpleRight, "/mouthDimpleRight", 0f }, |
| 65 | + { UnifiedExpressions.MouthUpperUpLeft, "/mouthUpperUpLeft", 0f }, |
| 66 | + { UnifiedExpressions.MouthUpperUpRight, "/mouthUpperUpRight", 0f }, |
| 67 | + { UnifiedExpressions.MouthLowerDownLeft, "/mouthLowerDownLeft", 0f }, |
| 68 | + { UnifiedExpressions.MouthLowerDownRight, "/mouthLowerDownRight", 0f }, |
| 69 | + { UnifiedExpressions.MouthPressLeft, "/mouthPressLeft", 0f }, |
| 70 | + { UnifiedExpressions.MouthPressRight, "/mouthPressRight", 0f }, |
| 71 | + { UnifiedExpressions.MouthStretchLeft, "/mouthStretchLeft", 0f }, |
| 72 | + { UnifiedExpressions.MouthStretchRight, "/mouthStretchRight", 0f }, |
| 73 | + { UnifiedExpressions.TongueOut, "/tongueOut", 0f }, |
| 74 | + { UnifiedExpressions.TongueUp, "/tongueUp", 0f }, |
| 75 | + { UnifiedExpressions.TongueDown, "/tongueDown", 0f }, |
| 76 | + { UnifiedExpressions.TongueLeft, "/tongueLeft", 0f }, |
| 77 | + { UnifiedExpressions.TongueRight, "/tongueRight", 0f }, |
| 78 | + { UnifiedExpressions.TongueRoll, "/tongueRoll", 0f }, |
| 79 | + { UnifiedExpressions.TongueBendDown, "/tongueBendDown", 0f }, |
| 80 | + { UnifiedExpressions.TongueCurlUp, "/tongueCurlUp", 0f }, |
| 81 | + { UnifiedExpressions.TongueSquish, "/tongueSquish", 0f }, |
| 82 | + { UnifiedExpressions.TongueFlat, "/tongueFlat", 0f }, |
| 83 | + { UnifiedExpressions.TongueTwistLeft, "/tongueTwistLeft", 0f }, |
| 84 | + { UnifiedExpressions.TongueTwistRight, "/tongueTwistRight", 0 } |
51 | 85 | };
|
52 | 86 | }
|
0 commit comments