static void Traverse(ListTreeNode <JsonValue> node, JsonFormatter f, UnityPath dir) { if (node.IsArray()) { f.BeginList(); foreach (var x in node.ArrayItems()) { TraverseItem(x, f, dir); } f.EndList(); } else if (node.IsMap()) { f.BeginMap(); foreach (var kv in node.ObjectItems()) { f.Key(kv.Key.GetUtf8String()); TraverseItem(kv.Value, f, dir); } f.EndMap(); } else { f.Value(node); } }
public static List <glTF_VCI_Material> Parse(ListTreeNode <JsonValue> json) { var materials = json.DeserializeList <glTF_VCI_Material>(); var jsonItems = json.ArrayItems().ToArray(); for (var i = 0; i < materials.Count; ++i) { materials[i].floatProperties = jsonItems[i][s_floatProperties].ObjectItems() .ToDictionary(x => x.Key.GetString(), x => x.Value.GetSingle()); materials[i].vectorProperties = jsonItems[i][s_vectorProperties].ObjectItems().ToDictionary(x => x.Key.GetString(), x => { return(x.Value.ArrayItems().Select(y => y.GetSingle()).ToArray()); }); materials[i].keywordMap = jsonItems[i][s_keywordMap].ObjectItems() .ToDictionary(x => x.Key.GetString(), x => x.Value.GetBoolean()); materials[i].tagMap = jsonItems[i][s_tagMap].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetString()); materials[i].textureProperties = jsonItems[i][s_textureProperties].ObjectItems() .ToDictionary(x => x.Key.GetString(), x => x.Value.GetInt32()); } return(materials); }
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 List <ColliderShape> Deserialize_Shapes(ListTreeNode <JsonValue> parsed) { var value = new List <ColliderShape>(); foreach (var x in parsed.ArrayItems()) { value.Add(Deserialize_Shapes_ITEM(x)); } return(value); }
public static List <VRM.glTF_VRM_HumanoidBone> Deserialize_vrm_humanoid_humanBones(ListTreeNode <JsonValue> parsed) { var value = new List <glTF_VRM_HumanoidBone>(); foreach (var x in parsed.ArrayItems()) { value.Add(Deserialize_vrm_humanoid_humanBones_LIST(x)); } return(value); }
public static List <VRM.glTF_VRM_Material> Deserialize_vrm_materialProperties(ListTreeNode <JsonValue> parsed) { var value = new List <glTF_VRM_Material>(); foreach (var x in parsed.ArrayItems()) { value.Add(Deserialize_vrm_materialProperties_LIST(x)); } return(value); }
public static List <VRM.glTF_VRM_MeshAnnotation> Deserialize_vrm_firstPerson_meshAnnotations(ListTreeNode <JsonValue> parsed) { var value = new List <glTF_VRM_MeshAnnotation>(); foreach (var x in parsed.ArrayItems()) { value.Add(Deserialize_vrm_firstPerson_meshAnnotations_LIST(x)); } return(value); }
static IEnumerable <float> DeserializeFloat2(ListTreeNode <JsonValue> json) { if (json.Value.ValueType == ValueNodeType.Array) { foreach (var a in json.ArrayItems()) { yield return(a.GetSingle()); } } }
public static List <VRM.glTF_VRM_MaterialValueBind> Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(ListTreeNode <JsonValue> parsed) { var value = new List <glTF_VRM_MaterialValueBind>(); foreach (var x in parsed.ArrayItems()) { value.Add(Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_LIST(x)); } return(value); }
public static List <VRM.glTF_VRM_SecondaryAnimationColliderGroup> Deserialize_vrm_secondaryAnimation_colliderGroups(ListTreeNode <JsonValue> parsed) { var value = new List <glTF_VRM_SecondaryAnimationColliderGroup>(); foreach (var x in parsed.ArrayItems()) { value.Add(Deserialize_vrm_secondaryAnimation_colliderGroups_LIST(x)); } return(value); }
public static List <SpringBoneJoint> Deserialize_Joints(ListTreeNode <JsonValue> parsed) { var value = new List <SpringBoneJoint>(); foreach (var x in parsed.ArrayItems()) { value.Add(Deserialize_Joints_ITEM(x)); } return(value); }
public static bool[] Deserialize_FreezeAxes(ListTreeNode <JsonValue> parsed) { var value = new bool[parsed.GetArrayCount()]; int i = 0; foreach (var x in parsed.ArrayItems()) { value[i++] = x.GetBoolean(); } return(value); }
public static Single[] Deserialize_vrm_materialProperties__vectorProperties_DICT(ListTreeNode <JsonValue> parsed) { var value = new Single[parsed.GetArrayCount()]; int i = 0; foreach (var x in parsed.ArrayItems()) { value[i++] = x.GetSingle(); } return(value); }
public static float[] Deserialize_OutlineFactor(ListTreeNode <JsonValue> parsed) { var value = new float[parsed.GetArrayCount()]; int i = 0; foreach (var x in parsed.ArrayItems()) { value[i++] = x.GetSingle(); } return(value); }
public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__colliderGroups(ListTreeNode <JsonValue> parsed) { var value = new Int32[parsed.GetArrayCount()]; int i = 0; foreach (var x in parsed.ArrayItems()) { value[i++] = x.GetInt32(); } return(value); }
public static int[] Deserialize_Colliders(ListTreeNode <JsonValue> parsed) { var value = new int[parsed.GetArrayCount()]; int i = 0; foreach (var x in parsed.ArrayItems()) { value[i++] = x.GetInt32(); } return(value); }
public static Single[] Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(ListTreeNode <JsonValue> parsed) { var value = new Single[parsed.GetArrayCount()]; int i = 0; foreach (var x in parsed.ArrayItems()) { value[i++] = x.GetSingle(); } return(value); }
public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalUp_curve(ListTreeNode <JsonValue> parsed) { var value = new Single[parsed.GetArrayCount()]; int i = 0; foreach (var x in parsed.ArrayItems()) { value[i++] = x.GetSingle(); } return(value); }
static List <string> Deserialize(ListTreeNode <JsonValue> json) { var targetNames = new List <string>(); if (json.Value.ValueType == ValueNodeType.Array) { foreach (var name in json.ArrayItems()) { targetNames.Add(name.GetString()); } } return(targetNames); }
/// <summary> /// MaterialValue の仕様変更 /// /// * MaterialColorBind /// * TextureTransformBind /// /// の2種類になった。 /// /// </summary> /// <param name="gltf"></param> /// <param name="json"></param> /// <param name="expression"></param> static void ToMaterialColorBinds(UniGLTF.glTF gltf, ListTreeNode <JsonValue> json, UniGLTF.Extensions.VRMC_vrm.Expression expression) { foreach (var x in json.ArrayItems()) { var materialName = x["materialName"].GetString(); var materialIndex = gltf.materials.IndexOf(gltf.materials.First(y => y.name == materialName)); var propertyName = x["propertyName"].GetString(); var targetValue = x["targetValue"].ArrayItems().Select(y => y.GetSingle()).ToArray(); if (propertyName.EndsWith("_ST")) { expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind { Material = materialIndex, Scaling = new float[] { targetValue[0], targetValue[1] }, Offset = new float[] { targetValue[2], targetValue[3] } }); } else if (propertyName.EndsWith("_ST_S")) { expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind { Material = materialIndex, Scaling = new float[] { targetValue[0], 1 }, Offset = new float[] { targetValue[2], 0 } }); } else if (propertyName.EndsWith("_ST_T")) { expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind { Material = materialIndex, Scaling = new float[] { 1, targetValue[1] }, Offset = new float[] { 0, targetValue[3] } }); } else { // color expression.MaterialColorBinds.Add(new UniGLTF.Extensions.VRMC_vrm.MaterialColorBind { Material = materialIndex, Type = ToMaterialType(propertyName), TargetValue = targetValue, }); } } }
static IEnumerable <UniGLTF.Extensions.VRMC_vrm.MorphTargetBind> ToMorphTargetBinds(UniGLTF.glTF gltf, ListTreeNode <JsonValue> json) { foreach (var x in json.ArrayItems()) { var meshIndex = x["mesh"].GetInt32(); var morphTargetIndex = x["index"].GetInt32(); var weight = x["weight"].GetSingle(); var bind = new UniGLTF.Extensions.VRMC_vrm.MorphTargetBind(); // https://github.com/vrm-c/vrm-specification/pull/106 // https://github.com/vrm-c/vrm-specification/pull/153 bind.Node = gltf.nodes.IndexOf(gltf.nodes.First(y => y.mesh == meshIndex)); bind.Index = morphTargetIndex; // https://github.com/vrm-c/vrm-specification/issues/209 bind.Weight = weight * 0.01f; yield return(bind); } }
TreeNode Traverse(TreeNodeCollection parent, string key, ListTreeNode <JsonValue> node) { if (node.IsArray()) { var current = new TreeNode($"{key}({node.GetArrayCount()})"); parent.Add(current); m_nodeMap.Add(current, node); int i = 0; foreach (var x in node.ArrayItems()) { Traverse(current.Nodes, (i++).ToString(), x); } return(current); } else if (node.IsMap()) { var current = new TreeNode(key); parent.Add(current); m_nodeMap.Add(current, node); foreach (var kv in node.ObjectItems()) { Traverse(current.Nodes, kv.Key.GetString(), kv.Value); } return(current); } else { var current = new TreeNode($"{key}: {node.ToString()}"); parent.Add(current); m_nodeMap.Add(current, node); return(current); } }
public static List <T> DeserializeList <T>(this ListTreeNode <JsonValue> jsonList) { return(jsonList.ArrayItems().Select(x => { return JsonUtility.FromJson <T>(new Utf8String(x.Value.Bytes).ToString()); }).ToList()); }