Skip to content

Commit

Permalink
Plz run in mono.
Browse files Browse the repository at this point in the history
  • Loading branch information
benaclejames committed Feb 19, 2022
1 parent 44e0a69 commit c31841c
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 25 deletions.
10 changes: 7 additions & 3 deletions VRCFaceTracking/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void Msg(string msgStr)
#if DLL
MelonLogger.Msg(msgStr);
#else
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " " + msgStr);
Console.WriteLine("["+DateTime.Now.ToString("HH:mm:ss") + "] " + msgStr);
#endif
}

Expand All @@ -23,7 +23,9 @@ public static void Warning(string warningStr)
#if DLL
MelonLogger.Warning(warningStr);
#else
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " [WARNING] " + warningStr);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("["+DateTime.Now.ToString("HH:mm:ss") + "] [WARNING] " + warningStr);
Console.ResetColor();
#endif
}

Expand All @@ -32,7 +34,9 @@ public static void Error(string errorStr)
#if DLL
MelonLogger.Error(errorStr);
#else
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " [ERROR] " + errorStr);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("["+DateTime.Now.ToString("HH:mm:ss") + "] [ERROR] " + errorStr);
Console.ResetColor();
#endif
}
}
Expand Down
30 changes: 27 additions & 3 deletions VRCFaceTracking/MainStandalone.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using ParamLib;
Expand All @@ -12,18 +13,41 @@ public static class MainStandalone
public static readonly bool HasAdmin =
new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);

private static IEnumerable<OscMessage> ConstructMessages(IEnumerable<BaseParam> parameters) => parameters.Select(param => new OscMessage("/avatar/parameters/" + param.ParamName, param.ParamValue));
private static Dictionary<BaseParam, double> cachedValues = new Dictionary<BaseParam, double>();
private static IEnumerable<OscMessage> ConstructMessages(IEnumerable<BaseParam> parameters)
{
var paramList = new List<OscMessage>();
foreach (var param in parameters) {
if (!cachedValues.ContainsKey(param))
{
cachedValues.Add(param, param.ParamValue);
paramList.Add(new OscMessage("/avatar/parameters/" + param.ParamName, param.ParamValue));
}

if (cachedValues[param] != param.ParamValue)
{
cachedValues[param] = param.ParamValue;
paramList.Add(new OscMessage("/avatar/parameters/" + param.ParamName, param.ParamValue));
}
}

return paramList;
}

public static void Main()
{
bool isMono = Type.GetType("Mono.Runtime") != null;
if (!isMono)
Logger.Error("Currently running in non-mono mode. While this will work, it is not recommended and may cause some parameter values to be laggy.\n" +
"Please restart using the command line using the command 'mono VRCFaceTracking.exe'");

Logger.Msg("VRCFT Standalone Initializing!");
DependencyManager.Init();
Logger.Msg("Initialized DependencyManager Successfully");
UnifiedLibManager.Initialize();
Logger.Msg("Initialized UnifiedLibManager Successfully");

var allParams = UnifiedTrackingData.AllParameters.SelectMany(param => param.GetBase().Where(b => b.GetType() == typeof(FloatParameter) || b.GetType() == typeof(FloatBaseParam)));

while (true)
{
UnifiedTrackingData.OnUnifiedParamsUpdated.Invoke(UnifiedTrackingData.LatestEyeData,
Expand Down
28 changes: 14 additions & 14 deletions VRCFaceTracking/Params/Lip/LipShapeMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,50 @@ public static class LipShapeMerger
{"SmileSad", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthSmileLeft, LipShape_v2.MouthSmileRight}, new LipShape_v2[]{LipShape_v2.MouthSadLeft, LipShape_v2.MouthSadRight})},
{"TongueY", new PositiveNegativeShape(LipShape_v2.TongueUp, LipShape_v2.TongueDown)},
{"TongueX", new PositiveNegativeShape(LipShape_v2.TongueRight, LipShape_v2.TongueLeft)},
/*{"PuffSuckRight", new PositiveNegativeShape(LipShape_v2.CheekPuffRight, LipShape_v2.CheekSuck)},
{"PuffSuckLeft", new PositiveNegativeShape(LipShape_v2.CheekPuffLeft, LipShape_v2.CheekSuck)},
{"PuffSuck", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.CheekPuffLeft, LipShape_v2.CheekPuffRight}, new LipShape_v2[]{LipShape_v2.CheekSuck}, true)},
//{"PuffSuckRight", new PositiveNegativeShape(LipShape_v2.CheekPuffRight, LipShape_v2.CheekSuck)},
//{"PuffSuckLeft", new PositiveNegativeShape(LipShape_v2.CheekPuffLeft, LipShape_v2.CheekSuck)},
//{"PuffSuck", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.CheekPuffLeft, LipShape_v2.CheekPuffRight}, new LipShape_v2[]{LipShape_v2.CheekSuck}, true)},

//Additional combined shapes created with the help of the VRCFT Discord!

//JawOpen based params
{"JawOpenApe", new PositiveNegativeShape(LipShape_v2.JawOpen, LipShape_v2.MouthApeShape)},
/*{"JawOpenApe", new PositiveNegativeShape(LipShape_v2.JawOpen, LipShape_v2.MouthApeShape)},
{"JawOpenPuff", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.JawOpen}, new LipShape_v2[]{LipShape_v2.CheekPuffLeft, LipShape_v2.CheekPuffRight})},
{"JawOpenPuffRight", new PositiveNegativeShape(LipShape_v2.JawOpen, LipShape_v2.CheekPuffRight)},
{"JawOpenPuffLeft", new PositiveNegativeShape(LipShape_v2.JawOpen, LipShape_v2.CheekPuffLeft)},
{"JawOpenSuck", new PositiveNegativeShape(LipShape_v2.JawOpen, LipShape_v2.CheekSuck)},
{"JawOpenForward", new PositiveNegativeShape(LipShape_v2.JawOpen, LipShape_v2.JawForward)},
{"JawOpenForward", new PositiveNegativeShape(LipShape_v2.JawOpen, LipShape_v2.JawForward)},*/

//MouthUpperUpRight based params
{"MouthUpperUpRightUpperInside", new PositiveNegativeShape(LipShape_v2.MouthUpperUpRight, LipShape_v2.MouthUpperInside)},
/*{"MouthUpperUpRightUpperInside", new PositiveNegativeShape(LipShape_v2.MouthUpperUpRight, LipShape_v2.MouthUpperInside)},
{"MouthUpperUpRightPuffRight", new PositiveNegativeShape(LipShape_v2.MouthUpperUpRight, LipShape_v2.CheekPuffRight)},
{"MouthUpperUpRightApe", new PositiveNegativeShape(LipShape_v2.MouthUpperUpRight, LipShape_v2.MouthApeShape)},
{"MouthUpperUpRightPout", new PositiveNegativeShape(LipShape_v2.MouthUpperUpRight, LipShape_v2.MouthPout)},
{"MouthUpperUpRightOverlay", new PositiveNegativeShape(LipShape_v2.MouthUpperUpRight, LipShape_v2.MouthLowerOverlay)},
{"MouthUpperUpRightOverlay", new PositiveNegativeShape(LipShape_v2.MouthUpperUpRight, LipShape_v2.MouthLowerOverlay)},*/

//MouthUpperUpLeft based params
{"MouthUpperUpLeftUpperInside", new PositiveNegativeShape(LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperInside)},
/*{"MouthUpperUpLeftUpperInside", new PositiveNegativeShape(LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperInside)},
{"MouthUpperUpLeftPuffLeft", new PositiveNegativeShape(LipShape_v2.MouthUpperUpLeft, LipShape_v2.CheekPuffLeft)},
{"MouthUpperUpLeftApe", new PositiveNegativeShape(LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthApeShape)},
{"MouthUpperUpLeftPout", new PositiveNegativeShape(LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthPout)},
{"MouthUpperUpLeftOverlay", new PositiveNegativeShape(LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthLowerOverlay)},
{"MouthUpperUpLeftOverlay", new PositiveNegativeShape(LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthLowerOverlay)},*/

// MouthUpperUp Left+Right base params
{"MouthUpperUpUpperInside", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.MouthUpperInside })},
/*{"MouthUpperUpUpperInside", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.MouthUpperInside })},
{"MouthUpperUpInside", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.MouthUpperInside, LipShape_v2.MouthLowerInside}, true)},
{"MouthUpperUpPuff", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.CheekPuffLeft, LipShape_v2.CheekPuffRight})},
{"MouthUpperUpPuffLeft", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.CheekPuffLeft})},
{"MouthUpperUpPuffRight", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.CheekPuffRight})},
{"MouthUpperUpApe", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.MouthApeShape})},
{"MouthUpperUpPout", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.MouthPout})},
{"MouthUpperUpOverlay", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.MouthUpperUpLeft, LipShape_v2.MouthUpperUpRight}, new LipShape_v2[]{LipShape_v2.MouthLowerOverlay})},
*/
//MouthLowerDownRight based params
{"MouthLowerDownRightLowerInside", new PositiveNegativeShape(LipShape_v2.MouthLowerDownRight, LipShape_v2.MouthLowerInside)},
/*{"MouthLowerDownRightLowerInside", new PositiveNegativeShape(LipShape_v2.MouthLowerDownRight, LipShape_v2.MouthLowerInside)},
{"MouthLowerDownRightPuffRight", new PositiveNegativeShape(LipShape_v2.MouthLowerDownRight, LipShape_v2.CheekPuffRight)},
{"MouthLowerDownRightApe", new PositiveNegativeShape(LipShape_v2.MouthLowerDownRight, LipShape_v2.MouthApeShape)},
{"MouthLowerDownRightPout", new PositiveNegativeShape(LipShape_v2.MouthLowerDownRight, LipShape_v2.MouthPout)},
{"MouthLowerDownRightOverlay", new PositiveNegativeShape(LipShape_v2.MouthLowerDownRight, LipShape_v2.MouthLowerOverlay)},
{"MouthLowerDownRightOverlay", new PositiveNegativeShape(LipShape_v2.MouthLowerDownRight, LipShape_v2.MouthLowerOverlay)},*/

//MouthLowerDownLeft based params
{"MouthLowerDownLeftLowerInside", new PositiveNegativeShape(LipShape_v2.MouthLowerDownLeft, LipShape_v2.MouthLowerInside)},
Expand Down Expand Up @@ -122,7 +122,7 @@ public static class LipShapeMerger
{"PuffOverturn", new PositiveNegativeAveragedShape(new LipShape_v2[]{LipShape_v2.CheekPuffRight, LipShape_v2.CheekPuffLeft}, new LipShape_v2[]{LipShape_v2.MouthUpperOverturn, LipShape_v2.MouthLowerOverturn}, true)},

//Combine both TongueSteps (-1 fully in, 0 on edge, 1 fully out)
{"TongueSteps", new PositiveNegativeShape(LipShape_v2.TongueLongStep1, LipShape_v2.TongueLongStep2, true)},*/
{"TongueSteps", new PositiveNegativeShape(LipShape_v2.TongueLongStep1, LipShape_v2.TongueLongStep2, true)},
};

// Make a list called LipParameters containing the results from both GetOptimizedLipParameters and GetAllLipParameters
Expand Down
1 change: 0 additions & 1 deletion VRCFaceTracking/Params/ParamContainers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public EParam(Func<EyeTrackingData, Dictionary<LipShape_v2, float>, float?> getV

Name = paramName;
_parameter = paramLiterals.ToArray();
Logger.Msg("Constructing EParam name " + Name);
}

public EParam(Func<EyeTrackingData, float> getValueFunc, string paramName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Lip
{
public enum LipShape_v2
{
None = -1,
//None = -1,
JawRight = 0, // +JawX
JawLeft = 1, // -JawX
JawForward = 2,
Expand Down Expand Up @@ -48,7 +48,7 @@ public enum LipShape_v2
TongueUpRightMorph = 33,
TongueDownLeftMorph = 36,
TongueDownRightMorph = 35,
Max = 37,
//Max = 37,
}

[StructLayout(LayoutKind.Sequential)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SRanipal_Lip_v2
public const int ANIPAL_TYPE_LIP_V2 = 3;

public const int ImageWidth = 800, ImageHeight = 400, ImageChannel = 1;
public const int WeightingCount = (int)LipShape_v2.Max;
public const int WeightingCount = 37;
private static Error LastUpdateResult = Error.FAILED;
public static LipData_v2 LipData;
private static Dictionary<LipShape_v2, float> Weightings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Action GetUpdateThreadFunc()
while (!_cancellationToken.IsCancellationRequested)
{
Update();
Thread.Sleep(10);
//Thread.Sleep(10);
}
};
}
Expand Down
1 change: 1 addition & 0 deletions VRCFaceTracking/UnifiedLibManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static List<Type> LoadExternalModules()

private static void FindAndInitRuntimes(bool eye = true, bool lip = true)
{
Logger.Msg("Finding and initializing runtimes...");
#if DLL
IL2CPP.il2cpp_thread_attach(IL2CPP.il2cpp_domain_get());
#endif
Expand Down

0 comments on commit c31841c

Please sign in to comment.