public void BlendShapeTest() { var settings = Google.Protobuf.JsonFormatter.Settings.Default.WithPreserveProtoFieldNames(true); var q = "\""; { var data = new VrmProtobuf.BlendShapeGroup(); data.IgnoreBlink = true; var json = new Google.Protobuf.JsonFormatter(settings).Format(data); Assert.AreEqual($"{{ {q}ignoreBlink{q}: true }}", json); } { var blendShape = new VrmLib.BlendShape(VrmLib.BlendShapePreset.Blink, "blink", true) { IgnoreBlink = true, IgnoreLookAt = true, IgnoreMouth = true, }; // export var gltf = Vrm10.BlendShapeAdapter.ToGltf(blendShape, new List <VrmLib.Node>(), new List <VrmLib.Material>()); Assert.AreEqual(true, gltf.IgnoreBlink); Assert.AreEqual(true, gltf.IgnoreLookAt); Assert.AreEqual(true, gltf.IgnoreMouth); // import var imported = Vrm10.BlendShapeAdapter.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); } }
public static VrmProtobuf.BlendShapeGroup ToGltf(this BlendShape x, List <MeshGroup> meshes, List <Material> materials) { var g = new VrmProtobuf.BlendShapeGroup { Preset = (VrmProtobuf.BlendShapeGroup.Types.BlendShapePreset)x.Preset, Name = x.Name, IsBinary = x.IsBinary, IgnoreBlink = x.IgnoreBlink, IgnoreLookAt = x.IgnoreLookAt, IgnoreMouth = x.IgnoreMouth, }; foreach (var y in x.BlendShapeValues) { g.Binds.Add(y.ToGltf(meshes)); } foreach (var y in x.MaterialValues) { g.MaterialValues.Add(y.ToGltf(materials)); } return(g); }