mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-31 06:56:40 -05:00
generate expression
OverrideBlink, OverrideLookAt, OverrideMouth
This commit is contained in:
parent
78bd0aafb9
commit
4173d00c9a
|
|
@ -80,9 +80,9 @@ namespace UniVRM10
|
|||
m_expressionNameProp = serializedObject.FindProperty(nameof(targetObject.ExpressionName));
|
||||
m_presetProp = serializedObject.FindProperty(nameof(targetObject.Preset));
|
||||
m_isBinaryProp = serializedObject.FindProperty(nameof(targetObject.IsBinary));
|
||||
m_ignoreBlinkProp = serializedObject.FindProperty(nameof(targetObject.IgnoreBlink));
|
||||
m_ignoreLookAtProp = serializedObject.FindProperty(nameof(targetObject.IgnoreLookAt));
|
||||
m_ignoreMouthProp = serializedObject.FindProperty(nameof(targetObject.IgnoreMouth));
|
||||
m_ignoreBlinkProp = serializedObject.FindProperty(nameof(targetObject.OverrideBlink));
|
||||
m_ignoreLookAtProp = serializedObject.FindProperty(nameof(targetObject.OverrideLookAt));
|
||||
m_ignoreMouthProp = serializedObject.FindProperty(nameof(targetObject.OverrideMouth));
|
||||
|
||||
m_morphTargetBindings = new ReorderableMorphTargetBindingList(serializedObject, previewSceneManager, 20);
|
||||
m_materialColorBindings = new ReorderableMaterialColorBindingList(serializedObject, previewSceneManager?.MaterialNames, 20);
|
||||
|
|
|
|||
|
|
@ -46,15 +46,15 @@ namespace UniVRM10
|
|||
|
||||
var expression = m_clipMap[kv.Key];
|
||||
|
||||
if (expression.IgnoreBlink && kv.Value > 0)
|
||||
if (expression.OverrideBlink == VrmLib.ExpressionOverrideType.Block && kv.Value > 0)
|
||||
{
|
||||
IgnoreBlink = true;
|
||||
}
|
||||
if (expression.IgnoreLookAt && kv.Value > 0)
|
||||
if (expression.OverrideLookAt == VrmLib.ExpressionOverrideType.Block && kv.Value > 0)
|
||||
{
|
||||
IgnoreLookAt = true;
|
||||
}
|
||||
if (expression.IgnoreMouth && kv.Value > 0)
|
||||
if (expression.OverrideMouth == VrmLib.ExpressionOverrideType.Block && kv.Value > 0)
|
||||
{
|
||||
IgnoreMouth = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,19 +83,19 @@ namespace UniVRM10
|
|||
/// この Expression と Blink(Blink, BlinkLeft, BlinkRight) が同時に有効な場合、Blink の Weight を 0 にする
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public bool IgnoreBlink;
|
||||
public VrmLib.ExpressionOverrideType OverrideBlink;
|
||||
|
||||
/// <summary>
|
||||
/// この Expression と LookAt(LookUp, LookDown, LookLeft, LookRight) が同時に有効な場合、LookAt の Weight を 0 にする
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public bool IgnoreLookAt;
|
||||
public VrmLib.ExpressionOverrideType OverrideLookAt;
|
||||
|
||||
/// <summary>
|
||||
/// この Expression と Mouth(Aa, Ih, Ou, Ee, Oh) が同時に有効な場合、Mouth の Weight を 0 にする
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public bool IgnoreMouth;
|
||||
public VrmLib.ExpressionOverrideType OverrideMouth;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1674,18 +1674,18 @@ public static Expression Deserialize_Expressions_ITEM(ListTreeNode<JsonValue> pa
|
|||
continue;
|
||||
}
|
||||
|
||||
if(key=="ignoreBlink"){
|
||||
value.IgnoreBlink = kv.Value.GetBoolean();
|
||||
if(key=="overrideBlink"){
|
||||
value.OverrideBlink = (ExpressionOverrideType)Enum.Parse(typeof(ExpressionOverrideType), kv.Value.GetString(), true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="ignoreLookAt"){
|
||||
value.IgnoreLookAt = kv.Value.GetBoolean();
|
||||
if(key=="overrideLookAt"){
|
||||
value.OverrideLookAt = (ExpressionOverrideType)Enum.Parse(typeof(ExpressionOverrideType), kv.Value.GetString(), true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key=="ignoreMouth"){
|
||||
value.IgnoreMouth = kv.Value.GetBoolean();
|
||||
if(key=="overrideMouth"){
|
||||
value.OverrideMouth = (ExpressionOverrideType)Enum.Parse(typeof(ExpressionOverrideType), kv.Value.GetString(), true);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -427,6 +427,14 @@ namespace UniGLTF.Extensions.VRMC_vrm
|
|||
public float[] Offset;
|
||||
}
|
||||
|
||||
public enum ExpressionOverrideType
|
||||
{
|
||||
none,
|
||||
block,
|
||||
blend,
|
||||
|
||||
}
|
||||
|
||||
public class Expression
|
||||
{
|
||||
// Dictionary object with extension-specific objects.
|
||||
|
|
@ -454,14 +462,17 @@ namespace UniGLTF.Extensions.VRMC_vrm
|
|||
// Interpret non-zero values as 1
|
||||
public bool? IsBinary;
|
||||
|
||||
// Disable Blink when this Expression is enabled
|
||||
public bool? IgnoreBlink;
|
||||
// Override values of Blink expressions when this Expression is enabled
|
||||
[JsonSchema(EnumSerializationType = EnumSerializationType.AsString)]
|
||||
public ExpressionOverrideType OverrideBlink;
|
||||
|
||||
// Disable LookAt when this Expression is enabled
|
||||
public bool? IgnoreLookAt;
|
||||
// Override values of LookAt expressions when this Expression is enabled
|
||||
[JsonSchema(EnumSerializationType = EnumSerializationType.AsString)]
|
||||
public ExpressionOverrideType OverrideLookAt;
|
||||
|
||||
// Disable Mouth when this Expression is enabled
|
||||
public bool? IgnoreMouth;
|
||||
// Override values of Mouth expressions when this Expression is enabled
|
||||
[JsonSchema(EnumSerializationType = EnumSerializationType.AsString)]
|
||||
public ExpressionOverrideType OverrideMouth;
|
||||
}
|
||||
|
||||
public class VRMC_vrm
|
||||
|
|
|
|||
|
|
@ -1416,19 +1416,19 @@ public static void Serialize_Expressions_ITEM(JsonFormatter f, Expression value)
|
|||
f.Value(value.IsBinary.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if(value.IgnoreBlink.HasValue){
|
||||
f.Key("ignoreBlink");
|
||||
f.Value(value.IgnoreBlink.GetValueOrDefault());
|
||||
if(true){
|
||||
f.Key("overrideBlink");
|
||||
f.Value(value.OverrideBlink.ToString());
|
||||
}
|
||||
|
||||
if(value.IgnoreLookAt.HasValue){
|
||||
f.Key("ignoreLookAt");
|
||||
f.Value(value.IgnoreLookAt.GetValueOrDefault());
|
||||
if(true){
|
||||
f.Key("overrideLookAt");
|
||||
f.Value(value.OverrideLookAt.ToString());
|
||||
}
|
||||
|
||||
if(value.IgnoreMouth.HasValue){
|
||||
f.Key("ignoreMouth");
|
||||
f.Value(value.IgnoreMouth.GetValueOrDefault());
|
||||
if(true){
|
||||
f.Key("overrideMouth");
|
||||
f.Value(value.OverrideMouth.ToString());
|
||||
}
|
||||
|
||||
f.EndMap();
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ namespace UniVRM10
|
|||
x.Name,
|
||||
x.IsBinary.HasValue && x.IsBinary.Value)
|
||||
{
|
||||
IgnoreBlink = x.IgnoreBlink.GetValueOrDefault(),
|
||||
IgnoreLookAt = x.IgnoreLookAt.GetValueOrDefault(),
|
||||
IgnoreMouth = x.IgnoreMouth.GetValueOrDefault(),
|
||||
OverrideBlink = EnumUtil.Cast<VrmLib.ExpressionOverrideType>(x.OverrideBlink),
|
||||
OverrideLookAt = EnumUtil.Cast<VrmLib.ExpressionOverrideType>(x.OverrideLookAt),
|
||||
OverrideMouth = EnumUtil.Cast<VrmLib.ExpressionOverrideType>(x.OverrideMouth),
|
||||
};
|
||||
|
||||
if (x.MorphTargetBinds != null)
|
||||
|
|
@ -112,9 +112,9 @@ namespace UniVRM10
|
|||
Preset = (UniGLTF.Extensions.VRMC_vrm.ExpressionPreset)x.Preset,
|
||||
Name = x.Name,
|
||||
IsBinary = x.IsBinary,
|
||||
IgnoreBlink = x.IgnoreBlink,
|
||||
IgnoreLookAt = x.IgnoreLookAt,
|
||||
IgnoreMouth = x.IgnoreMouth,
|
||||
OverrideBlink = EnumUtil.Cast<UniGLTF.Extensions.VRMC_vrm.ExpressionOverrideType>(x.OverrideBlink),
|
||||
OverrideLookAt = EnumUtil.Cast<UniGLTF.Extensions.VRMC_vrm.ExpressionOverrideType>(x.OverrideLookAt),
|
||||
OverrideMouth = EnumUtil.Cast<UniGLTF.Extensions.VRMC_vrm.ExpressionOverrideType>(x.OverrideMouth),
|
||||
};
|
||||
foreach (var blendShapeBind in x.MorphTargetBinds)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -157,9 +157,9 @@ namespace UniVRM10
|
|||
clip.Preset = expression.Preset;
|
||||
clip.ExpressionName = expression.Name;
|
||||
clip.IsBinary = expression.IsBinary;
|
||||
clip.IgnoreBlink = expression.IgnoreBlink;
|
||||
clip.IgnoreLookAt = expression.IgnoreLookAt;
|
||||
clip.IgnoreMouth = expression.IgnoreMouth;
|
||||
clip.OverrideBlink = expression.OverrideBlink;
|
||||
clip.OverrideLookAt = expression.OverrideLookAt;
|
||||
clip.OverrideMouth = expression.OverrideMouth;
|
||||
|
||||
clip.MorphTargetBindings = expression.MorphTargetBinds.Select(x => x.Build10(asset.Root, asset.Map))
|
||||
.ToArray();
|
||||
|
|
|
|||
|
|
@ -126,9 +126,9 @@ namespace UniVRM10
|
|||
VrmLib.Expression ToVrmLib(VRM10Expression clip, GameObject root)
|
||||
{
|
||||
var expression = new VrmLib.Expression(clip.Preset, clip.ExpressionName, clip.IsBinary);
|
||||
expression.IgnoreBlink = clip.IgnoreBlink;
|
||||
expression.IgnoreLookAt = clip.IgnoreLookAt;
|
||||
expression.IgnoreMouth = clip.IgnoreMouth;
|
||||
expression.OverrideBlink = EnumUtil.Cast<VrmLib.ExpressionOverrideType>(clip.OverrideBlink);
|
||||
expression.OverrideLookAt = EnumUtil.Cast<VrmLib.ExpressionOverrideType>(clip.OverrideLookAt);
|
||||
expression.OverrideMouth = EnumUtil.Cast<VrmLib.ExpressionOverrideType>(clip.OverrideMouth);
|
||||
|
||||
foreach (var binding in clip.MorphTargetBindings)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ namespace UniVRM10
|
|||
|
||||
{
|
||||
var data = new UniGLTF.Extensions.VRMC_vrm.Expression();
|
||||
data.IgnoreBlink = true;
|
||||
data.OverrideBlink = UniGLTF.Extensions.VRMC_vrm.ExpressionOverrideType.block;
|
||||
|
||||
var json = Serialize(data, UniGLTF.Extensions.VRMC_vrm.GltfSerializer.Serialize_Expressions_ITEM);
|
||||
Assert.AreEqual($"{{{q}preset{q}:{q}custom{q},{q}ignoreBlink{q}:true}}", json);
|
||||
|
|
@ -244,22 +244,22 @@ namespace UniVRM10
|
|||
{
|
||||
var expression = new VrmLib.Expression(VrmLib.ExpressionPreset.Blink, "blink", true)
|
||||
{
|
||||
IgnoreBlink = true,
|
||||
IgnoreLookAt = true,
|
||||
IgnoreMouth = true,
|
||||
OverrideBlink = VrmLib.ExpressionOverrideType.Block,
|
||||
OverrideLookAt = VrmLib.ExpressionOverrideType.Block,
|
||||
OverrideMouth = VrmLib.ExpressionOverrideType.Block,
|
||||
};
|
||||
|
||||
// export
|
||||
var gltf = UniVRM10.ExpressionAdapter.ToGltf(expression, new List<VrmLib.Node>(), new List<VrmLib.Material>());
|
||||
Assert.AreEqual(true, gltf.IgnoreBlink);
|
||||
Assert.AreEqual(true, gltf.IgnoreLookAt);
|
||||
Assert.AreEqual(true, gltf.IgnoreMouth);
|
||||
Assert.AreEqual(true, gltf.OverrideBlink);
|
||||
Assert.AreEqual(true, gltf.OverrideLookAt);
|
||||
Assert.AreEqual(true, gltf.OverrideMouth);
|
||||
|
||||
// import
|
||||
var imported = UniVRM10.ExpressionAdapter.FromGltf(gltf, new List<VrmLib.Node>(), new List<VrmLib.Material>());
|
||||
Assert.AreEqual(true, imported.IgnoreBlink);
|
||||
Assert.AreEqual(true, imported.IgnoreLookAt);
|
||||
Assert.AreEqual(true, imported.IgnoreMouth);
|
||||
Assert.AreEqual(true, imported.OverrideBlink);
|
||||
Assert.AreEqual(true, imported.OverrideLookAt);
|
||||
Assert.AreEqual(true, imported.OverrideMouth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@ using System.Numerics;
|
|||
|
||||
namespace VrmLib
|
||||
{
|
||||
public enum ExpressionOverrideType
|
||||
{
|
||||
None,
|
||||
Block,
|
||||
Blend,
|
||||
}
|
||||
|
||||
public class Expression
|
||||
{
|
||||
public readonly ExpressionPreset Preset;
|
||||
|
|
@ -12,9 +19,9 @@ namespace VrmLib
|
|||
|
||||
public bool IsBinary;
|
||||
|
||||
public bool IgnoreBlink;
|
||||
public bool IgnoreLookAt;
|
||||
public bool IgnoreMouth;
|
||||
public ExpressionOverrideType OverrideBlink;
|
||||
public ExpressionOverrideType OverrideLookAt;
|
||||
public ExpressionOverrideType OverrideMouth;
|
||||
|
||||
public readonly List<MorphTargetBind> MorphTargetBinds = new List<MorphTargetBind>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user