static void Traverse(glTF self, JsonNode node, JsonFormatter f, Utf8String parentKey) { if (node.IsMap()) { f.BeginMap(); foreach (var kv in node.ObjectItems()) { if (parentKey == s_extensions) { if (!UsedExtension(self, kv.Key.GetString())) { // skip extension not in used continue; } } f.Key(kv.Key.GetUtf8String()); Traverse(self, kv.Value, f, kv.Key.GetUtf8String()); } f.EndMap(); } else if (node.IsArray()) { f.BeginList(); foreach (var x in node.ArrayItems()) { Traverse(self, x, f, default(Utf8String)); } f.EndList(); } else { f.Value(node); } }
void Traverse(ListTreeNode <JsonValue> node, JsonFormatter f, Utf8String parentKey) { if (node.IsMap()) { f.BeginMap(); foreach (var kv in node.ObjectItems()) { if (parentKey == s_extensions) { if (!UsedExtension(kv.Key.GetString())) { continue; } } f.Key(kv.Key.GetUtf8String()); Traverse(kv.Value, f, kv.Key.GetUtf8String()); } f.EndMap(); } else if (node.IsArray()) { f.BeginList(); foreach (var x in node.ArrayItems()) { Traverse(x, f, default(Utf8String)); } f.EndList(); } else { f.Value(node); } }
public static void Serialize_gltf_scenes__nodes(JsonFormatter f, Int32[] value) { f.BeginList(); foreach (var item in value) { f.Value(item); } f.EndList(); }
protected override void SerializeMembers(JsonFormatter f) { f.Key("targetNames"); f.BeginList(); foreach (var x in targetNames) { f.Value(x); } f.EndList(); }
public static void Serialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(JsonFormatter f, Single[] value) { f.BeginList(); foreach (var item in value) { f.Value(item); } f.EndList(); }
public static void Serialize_gltf_materials__emissiveFactor(JsonFormatter f, Single[] value) { f.BeginList(); foreach (var item in value) { f.Value(item); } f.EndList(); }
public static void Serialize_gltf_samplers(JsonFormatter f, List <glTFTextureSampler> value) { f.BeginList(); foreach (var item in value) { Serialize_gltf_samplers_ITEM(f, item); } f.EndList(); }
public static void Serialize_gltf_materials(JsonFormatter f, List <glTFMaterial> value) { f.BeginList(); foreach (var item in value) { Serialize_gltf_materials_ITEM(f, item); } f.EndList(); }
public static void Serialize_gltf_bufferViews(JsonFormatter f, List <glTFBufferView> value) { f.BeginList(); foreach (var item in value) { Serialize_gltf_bufferViews_ITEM(f, item); } f.EndList(); }
public static void Serialize_gltf_accessors__min(JsonFormatter f, Single[] value) { f.BeginList(); foreach (var item in value) { f.Value(item); } f.EndList(); }
public static void Serialize_gltf_animations__channels(JsonFormatter f, List <glTFAnimationChannel> value) { f.BeginList(); foreach (var item in value) { Serialize_gltf_animations__channels_ITEM(f, item); } f.EndList(); }
public static void Serialize_gltf_extensionsRequired(JsonFormatter f, List <String> value) { f.BeginList(); foreach (var item in value) { f.Value(item); } f.EndList(); }
public static void Serialize_gltf_nodes__weights(JsonFormatter f, Single[] value) { f.BeginList(); foreach (var item in value) { f.Value(item); } f.EndList(); }
public static void Serialize_gltf_meshes__primitives__targets(JsonFormatter f, List <gltfMorphTarget> value) { f.BeginList(); foreach (var item in value) { Serialize_gltf_meshes__primitives__targets_ITEM(f, item); } f.EndList(); }
public static glTFExtension Serialize(params string[] args) { var f = new JsonFormatter(); f.BeginList(); foreach (var arg in args) { // エスケープとかあるし f.Value(arg); } f.EndList(); return(new glTFExtensionExport().Add(ExtraName, f.GetStore().Bytes)); }
public string ToJson() { var f = new JsonFormatter(); f.BeginMap(); if (!string.IsNullOrEmpty(name)) { f.KeyValue(() => name); } if (children != null && children.Any()) { f.Key("children"); f.BeginList(); foreach (var child in children) { f.Value(child); } f.EndList(); } if (matrix != null) { f.KeyValue(() => matrix); } if (translation != null) { f.KeyValue(() => translation); } if (rotation != null) { f.KeyValue(() => rotation); } if (scale != null) { f.KeyValue(() => scale); } if (mesh >= 0) { f.KeyValue(() => mesh); } if (skin >= 0) { f.KeyValue(() => skin); } if (camera >= 0) { f.KeyValue(() => camera); } f.EndMap(); return(f.ToString()); }
protected override void SerializeMembers(JsonFormatter f) { if (children != null && children.Any()) { f.Key("children"); f.BeginList(); foreach (var child in children) { f.Value(child); } f.EndList(); } if (!string.IsNullOrEmpty(name)) { f.KeyValue(() => name); } if (matrix != null) { f.KeyValue(() => matrix); } if (translation != null) { f.KeyValue(() => translation); } if (rotation != null) { f.KeyValue(() => rotation); } if (scale != null) { f.KeyValue(() => scale); } if (mesh >= 0) { f.KeyValue(() => mesh); } if (camera >= 0) { f.KeyValue(() => camera); } if (skin >= 0) { f.KeyValue(() => skin); f.KeyValue(() => extras); } }
public static void Serialize(glTFMesh gltfMesh, IEnumerable <string> targetNames) { // targetNames var f = new JsonFormatter(); f.BeginList(); foreach (var n in targetNames) { f.Value(n); } f.EndList(); var targetNamesJson = f.GetStore().Bytes; var meshExtras = glTFExtensionExport.GetOrCreate(ref gltfMesh.extras); meshExtras.Add(ExtraName, targetNamesJson); foreach (var prim in gltfMesh.primitives) { var primExtras = glTFExtensionExport.GetOrCreate(ref prim.extras); primExtras.Add(ExtraName, targetNamesJson); } }
static void CopyJson(IReadOnlyList <string> extensionUsed, JsonFormatter dst, JsonNode src, int level) { if (src.IsArray()) { dst.BeginList(); foreach (var v in src.ArrayItems()) { CopyJson(extensionUsed, dst, v, level + 1); } dst.EndList(); } else if (src.IsMap()) { if (level == 0) { // 最上層だけ extensionsUsed の処理をする var done = false; dst.BeginMap(); foreach (var kv in src.ObjectItems()) { var key = kv.Key.GetString(); if (key == EXTENSION_USED_KEY) { if (extensionUsed.Count == 0) { // skip } else { dst.Key(key); // replace dst.BeginList(); foreach (var ex in extensionUsed) { dst.Value(ex); } dst.EndList(); // 処理済 } done = true; } else { dst.Key(key); CopyJson(extensionUsed, dst, kv.Value, level + 1); } } if (!done && level == 0 && extensionUsed.Count > 0) { // add dst.Key(EXTENSION_USED_KEY); dst.BeginList(); foreach (var ex in extensionUsed) { dst.Value(ex); } dst.EndList(); } dst.EndMap(); } else { dst.BeginMap(); foreach (var kv in src.ObjectItems()) { dst.Key(kv.Key.GetUtf8String()); CopyJson(extensionUsed, dst, kv.Value, level + 1); } dst.EndMap(); } } else { // leaf dst.Value(src); } }