glTF_VRM_BlendShape.cs
3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Collections.Generic;
using UniGLTF;
using UniJSON;
namespace VRM
{
[Serializable]
[JsonSchema(Title = "vrm.blendshape.materialbind")]
public class glTF_VRM_MaterialValueBind : UniGLTF.JsonSerializableBase
{
public string materialName;
public string propertyName;
public float[] targetValue;
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.KeyValue(() => materialName);
f.KeyValue(() => propertyName);
f.KeyValue(() => targetValue);
}
}
[Serializable]
[JsonSchema(Title = "vrm.blendshape.bind")]
public class glTF_VRM_BlendShapeBind : UniGLTF.JsonSerializableBase
{
[JsonSchema(Required = true, Minimum = 0)]
public int mesh = -1;
[JsonSchema(Required = true, Minimum = 0)]
public int index = -1;
[JsonSchema(Required =true, Minimum = 0, Maximum = 100, Description = @"SkinnedMeshRenderer.SetBlendShapeWeight")]
public float weight = 0;
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.KeyValue(() => mesh);
f.KeyValue(() => index);
f.KeyValue(() => weight);
}
}
public enum BlendShapePreset
{
Unknown,
Neutral,
A,
I,
U,
E,
O,
Blink,
// 喜怒哀楽
Joy,
Angry,
Sorrow,
Fun,
// LookAt
LookUp,
LookDown,
LookLeft,
LookRight,
Blink_L,
Blink_R,
}
[Serializable]
[JsonSchema(Title = "vrm.blendshape.group", Description = "BlendShapeClip of UniVRM")]
public class glTF_VRM_BlendShapeGroup : UniGLTF.JsonSerializableBase
{
[JsonSchema(Description = "Expression name")]
public string name;
[JsonSchema(Description = "Predefined Expression name", EnumValues = new object[] {
"unknown",
"neutral",
"a",
"i",
"u",
"e",
"o",
"blink",
"joy",
"angry",
"sorrow",
"fun",
"lookup",
"lookdown",
"lookleft",
"lookright",
"blink_l",
"blink_r",
}, EnumSerializationType = EnumSerializationType.AsString)]
public string presetName;
[JsonSchema(Description = "Low level blendshape references. ")]
public List<glTF_VRM_BlendShapeBind> binds = new List<glTF_VRM_BlendShapeBind>();
[JsonSchema(Description = "Material animation references.")]
public List<glTF_VRM_MaterialValueBind> materialValues = new List<glTF_VRM_MaterialValueBind>();
[JsonSchema(Description = "0 or 1. Do not allow an intermediate value. Value should rounded")]
public bool isBinary;
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.KeyValue(() => name);
f.KeyValue(() => presetName);
f.KeyValue(() => isBinary);
f.Key("binds"); f.GLTFValue(binds);
f.Key("materialValues"); f.GLTFValue(materialValues);
}
}
[Serializable]
[JsonSchema(Title = "vrm.blendshape", Description = "BlendShapeAvatar of UniVRM")]
public class glTF_VRM_BlendShapeMaster : UniGLTF.JsonSerializableBase
{
public List<glTF_VRM_BlendShapeGroup> blendShapeGroups = new List<glTF_VRM_BlendShapeGroup>();
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.Key("blendShapeGroups"); f.GLTFValue(blendShapeGroups);
}
}
}