mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-06-14 20:10:36 -05:00
Implemented VrmLib.ExpressionPreset.Surprised
This commit is contained in:
parent
f42ab7a172
commit
e4ad2dda11
|
|
@ -152,6 +152,18 @@ namespace UniVRM10
|
|||
{
|
||||
case ExpressionPreset.Custom:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.custom;
|
||||
// 喜怒哀楽驚
|
||||
case ExpressionPreset.Happy:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.happy;
|
||||
case ExpressionPreset.Angry:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.angry;
|
||||
case ExpressionPreset.Sad:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.sad;
|
||||
case ExpressionPreset.Relaxed:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.relaxed;
|
||||
case ExpressionPreset.Surprised:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.surprised;
|
||||
// Procedural(LipSync)
|
||||
case ExpressionPreset.Aa:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.aa;
|
||||
case ExpressionPreset.Ih:
|
||||
|
|
@ -162,16 +174,14 @@ namespace UniVRM10
|
|||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.ee;
|
||||
case ExpressionPreset.Oh:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.oh;
|
||||
// Procedural(Blink)
|
||||
case ExpressionPreset.Blink:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blink;
|
||||
case ExpressionPreset.Joy:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.happy;
|
||||
case ExpressionPreset.Angry:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.angry;
|
||||
case ExpressionPreset.Sorrow:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.sad;
|
||||
case ExpressionPreset.Fun:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.relaxed;
|
||||
case ExpressionPreset.BlinkLeft:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blinkLeft;
|
||||
case ExpressionPreset.BlinkRight:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blinkRight;
|
||||
// Procedural(LookAt)
|
||||
case ExpressionPreset.LookUp:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookUp;
|
||||
case ExpressionPreset.LookDown:
|
||||
|
|
@ -180,10 +190,7 @@ namespace UniVRM10
|
|||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookLeft;
|
||||
case ExpressionPreset.LookRight:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookRight;
|
||||
case ExpressionPreset.BlinkLeft:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blinkLeft;
|
||||
case ExpressionPreset.BlinkRight:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blinkRight;
|
||||
// Other
|
||||
case ExpressionPreset.Neutral:
|
||||
return UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.neutral;
|
||||
default:
|
||||
|
|
@ -202,13 +209,12 @@ namespace UniVRM10
|
|||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.ee: return ExpressionPreset.Ee;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.oh: return ExpressionPreset.Oh;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.blink: return ExpressionPreset.Blink;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.happy: return ExpressionPreset.Joy;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.happy: return ExpressionPreset.Happy;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.angry: return ExpressionPreset.Angry;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.sad: return ExpressionPreset.Sorrow;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.relaxed: return ExpressionPreset.Fun;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.sad: return ExpressionPreset.Sad;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.relaxed: return ExpressionPreset.Relaxed;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookUp: return ExpressionPreset.LookUp;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.surprised:
|
||||
throw new NotImplementedException();
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.surprised: return ExpressionPreset.Surprised;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookDown: return ExpressionPreset.LookDown;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookLeft: return ExpressionPreset.LookLeft;
|
||||
case UniGLTF.Extensions.VRMC_vrm.ExpressionPreset.lookRight: return ExpressionPreset.LookRight;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VrmLib
|
||||
{
|
||||
|
|
@ -35,5 +37,23 @@ namespace VrmLib
|
|||
|
||||
return (T)Enum.Parse(typeof(T), src.ToString(), ignoreCase);
|
||||
}
|
||||
|
||||
class GenericCache<T> where T : Enum
|
||||
{
|
||||
public static T[] Values = GetValues().ToArray();
|
||||
|
||||
static IEnumerable<T> GetValues()
|
||||
{
|
||||
foreach (var t in Enum.GetValues(typeof(Texture)))
|
||||
{
|
||||
yield return (T)t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static T[] Values<T>() where T : Enum
|
||||
{
|
||||
return GenericCache<T>.Values;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,101 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VrmLib
|
||||
{
|
||||
public class ExpressionPresetMigrationStringAttribute : System.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// vrm-0.X での名前
|
||||
/// </summary>
|
||||
public string Vrm0;
|
||||
|
||||
public ExpressionPresetMigrationStringAttribute(string name)
|
||||
{
|
||||
Vrm0 = name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// VRM-1.0 順に並べ替え。
|
||||
///
|
||||
/// VRM-0.X とは変換表が必用デス
|
||||
/// </summary>
|
||||
public enum ExpressionPreset
|
||||
{
|
||||
[ExpressionPresetMigrationString("unknown")]
|
||||
Custom,
|
||||
Aa,
|
||||
Ih,
|
||||
Ou,
|
||||
Ee,
|
||||
Oh,
|
||||
Blink,
|
||||
Joy,
|
||||
// 喜怒哀楽驚
|
||||
[ExpressionPresetMigrationString("joy")]
|
||||
Happy,
|
||||
[ExpressionPresetMigrationString("angry")]
|
||||
Angry,
|
||||
Sorrow,
|
||||
Fun,
|
||||
LookUp,
|
||||
LookDown,
|
||||
LookLeft,
|
||||
LookRight,
|
||||
[ExpressionPresetMigrationString("sorrow")]
|
||||
Sad,
|
||||
[ExpressionPresetMigrationString("fun")]
|
||||
Relaxed,
|
||||
[ExpressionPresetMigrationString(null)]
|
||||
Surprised,
|
||||
// Procedural(LipSync)
|
||||
[ExpressionPresetMigrationString("a")]
|
||||
Aa,
|
||||
[ExpressionPresetMigrationString("i")]
|
||||
Ih,
|
||||
[ExpressionPresetMigrationString("u")]
|
||||
Ou,
|
||||
[ExpressionPresetMigrationString("e")]
|
||||
Ee,
|
||||
[ExpressionPresetMigrationString("o")]
|
||||
Oh,
|
||||
// Procedural(Blink)
|
||||
[ExpressionPresetMigrationString("blink")]
|
||||
Blink,
|
||||
[ExpressionPresetMigrationString("blink_l")]
|
||||
BlinkLeft,
|
||||
[ExpressionPresetMigrationString("blink_r")]
|
||||
BlinkRight,
|
||||
// Procedural(LookAt)
|
||||
[ExpressionPresetMigrationString("lookup")]
|
||||
LookUp,
|
||||
[ExpressionPresetMigrationString("lookdown")]
|
||||
LookDown,
|
||||
[ExpressionPresetMigrationString("lookleft")]
|
||||
LookLeft,
|
||||
[ExpressionPresetMigrationString("lookright")]
|
||||
LookRight,
|
||||
// other
|
||||
[ExpressionPresetMigrationString("neutral")]
|
||||
Neutral,
|
||||
}
|
||||
|
||||
public static class ExpressionPresetMigration
|
||||
{
|
||||
static readonly Dictionary<string, ExpressionPreset> s_map = GetValues().ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
static IEnumerable<KeyValuePair<string, ExpressionPreset>> GetValues()
|
||||
{
|
||||
var t = typeof(ExpressionPreset);
|
||||
foreach (var x in EnumUtil.Values<ExpressionPreset>())
|
||||
{
|
||||
var mi = t.GetMember(x.ToString()).FirstOrDefault(m => m.DeclaringType == t);
|
||||
var attr = mi.GetCustomAttributes(typeof(ExpressionPresetMigrationStringAttribute), true).First();
|
||||
if (attr is ExpressionPresetMigrationStringAttribute vrmAttr && !string.IsNullOrEmpty(vrmAttr.Vrm0))
|
||||
{
|
||||
yield return new KeyValuePair<string, ExpressionPreset>(vrmAttr.Vrm0, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ExpressionPreset FromVrm0String(string src)
|
||||
{
|
||||
if (s_map.TryGetValue(src, out ExpressionPreset preset))
|
||||
{
|
||||
return preset;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ExpressionPreset.Custom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user