|
1 | | - |
| 1 | +using ETVRTrackingModule.ExpressionStrategies; |
2 | 2 | using Microsoft.Extensions.Logging; |
3 | | -using VRCFaceTracking.Core.Params.Data; |
4 | | -using VRCFaceTracking.Core.Params.Expressions; |
| 3 | +using VRCFaceTracking; |
5 | 4 |
|
6 | 5 | namespace ETVRTrackingModule |
7 | 6 | { |
8 | 7 | public class ExpressionsMapper |
9 | 8 | { |
10 | | - private Dictionary<string, float> parameterValues = new() |
11 | | - { |
12 | | - // v1, legacy support |
13 | | - { "RightEyeLidExpandedSqueeze", 0f }, |
14 | | - { "LeftEyeLidExpandedSqueeze", 0f }, |
15 | | - { "LeftEyeX", 0f }, |
16 | | - { "RightEyeX", 0f }, |
17 | | - { "EyesY", 0f }, |
18 | | - // v2 |
19 | | - { "EyeX", 0f }, |
20 | | - { "EyeLeftX", 0f }, |
21 | | - { "EyeRightX", 0f }, |
22 | | - { "EyeLeftY", 0f }, |
23 | | - { "EyeRightY", 0f }, |
24 | | - { "EyeLid", 0f }, |
25 | | - { "EyeLidLeft", 0f }, |
26 | | - { "EyeLidRight", 0f }, |
27 | | - }; |
28 | | - |
| 9 | + private IExpressionMapper _mappingStrategy; |
| 10 | + |
29 | 11 | ILogger _logger; |
30 | 12 | public ExpressionsMapper(ILogger logger) |
31 | 13 | { |
32 | 14 | _logger = logger; |
| 15 | + _mappingStrategy = new V2Mapper(); |
33 | 16 | } |
34 | 17 | public void MapMessage(OSCMessage msg) |
35 | 18 | { |
36 | 19 | if (!msg.success) |
37 | 20 | return; |
38 | | - if (IsV2Param(msg)) |
| 21 | + |
| 22 | + var nextStrategy = IsV2Param(msg) ? (IExpressionMapper) new V2Mapper() : new V1Mapper(); |
| 23 | + if (_mappingStrategy.GetType() != nextStrategy.GetType()) |
39 | 24 | { |
40 | | - string paramToMap = GetParamToMap(msg.address); |
41 | | - if (parameterValues.ContainsKey(paramToMap)) |
42 | | - { |
43 | | - parameterValues[paramToMap] = msg.value; |
44 | | - } |
| 25 | + _mappingStrategy = nextStrategy; |
45 | 26 | } |
| 27 | + _mappingStrategy.handleOSCMessage(msg); |
46 | 28 | } |
47 | 29 |
|
48 | 30 | private bool IsV2Param(OSCMessage oscMessage) |
49 | 31 | { |
50 | 32 | return oscMessage.address.Contains("/v2/"); |
51 | 33 | } |
52 | 34 |
|
53 | | - private static string GetParamToMap(string oscAddress) |
54 | | - { |
55 | | - var oscUrlSplit = oscAddress.Split("/"); |
56 | | - return oscUrlSplit[^1]; |
57 | | - } |
58 | | - |
59 | 35 | public void UpdateVRCFTEyeData() |
60 | 36 | { |
| 37 | + _mappingStrategy.UpdateVRCFTEyeData(ref UnifiedTracking.Data.Eye, ref UnifiedTracking.Data.Shapes); |
61 | 38 | } |
62 | 39 | } |
63 | 40 | } |
0 commit comments