refactor VmcExtBlendVal to have a new constructor option

This commit is contained in:
Cassandra de la Cruz-Munoz 2023-08-16 19:03:54 -04:00
parent 64fcc22ea2
commit c72cb2d6ec

View File

@ -42,57 +42,94 @@ namespace godotVmcSharp
return;
}
var blendShape = (string)m.Data[0].Value;
if (blendShape == "Joy" || blendShape == "Angry" || blendShape == "Sorrow" || blendShape == "Fun" ||
blendShape == "A" || blendShape == "I" || blendShape == "U" || blendShape == "E" || blendShape == "O" ||
blendShape == "Blink_L" || blendShape == "Blink_R")
if (isVrm0BlendShape(blendShape))
{
name = blendShape;
value = (float)m.Data[1].Value;
return;
} else if (blendShape == "happy" || blendShape == "angry" || blendShape == "sad" || blendShape == "relaxed" ||
blendShape == "aa" || blendShape == "ih" || blendShape == "ou" || blendShape == "ee" || blendShape == "oh" ||
blendShape == "blinkLeft" || blendShape == "blinkRight")
{
name = blendShape;
value = (float)m.Data[1].Value;
return;
} else if (blendShape == "browInnerUp" ||
blendShape == "browDownLeft" || blendShape == "browDownRight" ||
blendShape == "browOuterUpLeft" || blendShape == "browOuterUpRight" ||
blendShape == "eyeLookUpLeft" || blendShape == "eyeLookUpRight" ||
blendShape == "eyeLookDownLeft" || blendShape == "eyeLookDownRight" ||
blendShape == "eyeLookInLeft" || blendShape == "eyeLookInRight" ||
blendShape == "eyeLookOutLeft" || blendShape == "eyeLookOutRight" ||
blendShape == "eyeBlinkLeft" || blendShape == "eyeBlinkRight" ||
blendShape == "eyeSquintLeft" || blendShape == "eyeSquintRight" ||
blendShape == "eyeWideLeft" || blendShape == "eyeWideRight" ||
blendShape == "cheekPuff" ||
blendShape == "cheekSquintLeft" || blendShape == "cheekSquintRight" ||
blendShape == "noseSneerLeft" || blendShape == "noseSneerRight" ||
blendShape == "jawOpen" || blendShape == "jawForward" ||
blendShape == "jawLeft" || blendShape == "jawRight" ||
blendShape == "mouthFunnel" || blendShape == "mouthPucker" ||
blendShape == "mouthLeft" || blendShape == "mouthRight" ||
blendShape == "mouthRollUpper" || blendShape == "mouthRollLower" ||
blendShape == "mouthShrugUpper" || blendShape == "mouthShrugLower" ||
blendShape == "mouthClose" ||
blendShape == "mouthSmileLeft" || blendShape == "mouthSmileRight" ||
blendShape == "mouthFrownLeft" || blendShape == "mouthFrownRight" ||
blendShape == "mouthDimpleLeft" || blendShape == "mouthDimpleRight" ||
blendShape == "mouthUpperUpLeft" || blendShape == "mouthUpperUpRight" ||
blendShape == "mouthLowerDownLeft" || blendShape == "mouthLowerDownRight" ||
blendShape == "mouthPressLeft" || blendShape == "mouthPressRight" ||
blendShape == "mouthStretchLeft" || blendShape == "mouthStretchRight" ||
blendShape == "tongueOut")
{
name = blendShape;
value = (float)m.Data[1].Value;
return;
} else
{
GD.Print($"Invalid argument for /VMC/Ext/Blend/Val. BlendShape \"{blendShape}\" not in list.");
return;
}
if (isVrm1Expression(blendShape))
{
name = blendShape;
value = (float)m.Data[1].Value;
return;
}
if (isArkitBlendShape(blendShape))
{
name = blendShape;
value = (float)m.Data[1].Value;
return;
}
GD.Print($"Invalid argument for {addr}. BlendShape \"{blendShape}\" not in list.");
}
public VmcExtBlendVal(string _name, float _value) : base(new godotOscSharp.Address("VMC/Ext/Blend/Val"))
{
if (isVrm0BlendShape(_name))
{
name = _name;
value = _value;
return;
}
if (isVrm1Expression(_name))
{
name = _name;
value = _value;
return;
}
if (isArkitBlendShape(_name))
{
name = _name;
value = _value;
return;
}
GD.Print($"Invalid argument for {addr}. BlendShape \"{_name}\" not in list.");
}
private bool isVrm0BlendShape(string name)
{
return name == "Joy" || name == "Angry" || name == "Sorrow" || name == "Fun" ||
name == "A" || name == "I" || name == "U" || name == "E" || name == "O" ||
name == "Blink_L" || name == "Blink_R";
}
private bool isVrm1Expression(string name)
{
return name == "happy" || name == "angry" || name == "sad" || name == "relaxed" ||
name == "aa" || name == "ih" || name == "ou" || name == "ee" || name == "oh" ||
name == "blinkLeft" || name == "blinkRight";
}
private bool isArkitBlendShape(string name)
{
return name == "browInnerUp" ||
name == "browDownLeft" || name == "browDownRight" ||
name == "browOuterUpLeft" || name == "browOuterUpRight" ||
name == "eyeLookUpLeft" || name == "eyeLookUpRight" ||
name == "eyeLookDownLeft" || name == "eyeLookDownRight" ||
name == "eyeLookInLeft" || name == "eyeLookInRight" ||
name == "eyeLookOutLeft" || name == "eyeLookOutRight" ||
name == "eyeBlinkLeft" || name == "eyeBlinkRight" ||
name == "eyeSquintLeft" || name == "eyeSquintRight" ||
name == "eyeWideLeft" || name == "eyeWideRight" ||
name == "cheekPuff" ||
name == "cheekSquintLeft" || name == "cheekSquintRight" ||
name == "noseSneerLeft" || name == "noseSneerRight" ||
name == "jawOpen" || name == "jawForward" ||
name == "jawLeft" || name == "jawRight" ||
name == "mouthFunnel" || name == "mouthPucker" ||
name == "mouthLeft" || name == "mouthRight" ||
name == "mouthRollUpper" || name == "mouthRollLower" ||
name == "mouthShrugUpper" || name == "mouthShrugLower" ||
name == "mouthClose" ||
name == "mouthSmileLeft" || name == "mouthSmileRight" ||
name == "mouthFrownLeft" || name == "mouthFrownRight" ||
name == "mouthDimpleLeft" || name == "mouthDimpleRight" ||
name == "mouthUpperUpLeft" || name == "mouthUpperUpRight" ||
name == "mouthLowerDownLeft" || name == "mouthLowerDownRight" ||
name == "mouthPressLeft" || name == "mouthPressRight" ||
name == "mouthStretchLeft" || name == "mouthStretchRight" ||
name == "tongueOut";
}
}
}