public void writeMatrix() { if (matrix != null) { CommaNL(); matrix.Write(); } else { if (translation != null && (translation.items[0] != 0f || translation.items[1] != 0f || translation.items[2] != 0f)) { CommaNL(); translation.Write(); } if (scale != null && (scale.items[0] != 1f || scale.items[1] != 1f || scale.items[2] != 1f)) { CommaNL(); scale.Write(); } if (rotation != null && (rotation.items[0] != 0f || rotation.items[1] != 0f || rotation.items[2] != 0f || rotation.items[3] != 0f)) { CommaNL(); rotation.Write(); } } }
public override void Write() { Indent(); jsonWriter.Write("{\n"); IndentIn(); Indent(); CommaNL(); jsonWriter.Write("\"name\": \"" + name + "\""); if (cameraName != null) { CommaNL(); Indent(); jsonWriter.Write("\"camera\": \"" + cameraName + "\""); } else if (lightName != null) { CommaNL(); Indent(); jsonWriter.Write("\"light\": \"" + lightName + "\""); } else if (meshIndex != -1) { CommaNL(); Indent(); jsonWriter.Write("\"mesh\": " + meshIndex); } if (childrenIDs != null && childrenIDs.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"children\": [\n"); IndentIn(); foreach (string ch in childrenIDs) { CommaNL(); Indent(); jsonWriter.Write(GlTF_Writer.nodeIDs.IndexOf(ch)); } jsonWriter.WriteLine(); IndentOut(); Indent(); jsonWriter.Write("]"); } if (matrix != null) { CommaNL(); matrix.Write(); } else { if (translation != null && (translation.items[0] != 0f || translation.items[1] != 0f || translation.items[2] != 0f)) { CommaNL(); translation.Write(); } if (scale != null && (scale.items[0] != 1f || scale.items[1] != 1f || scale.items[2] != 1f)) { CommaNL(); scale.Write(); } if (rotation != null && (rotation.items[0] != 0f || rotation.items[1] != 0f || rotation.items[2] != 0f || rotation.items[3] != 0f)) { CommaNL(); rotation.Write(); } } if (skinIndex > -1) { CommaNL(); Indent(); jsonWriter.Write("\"skin\": " + skinIndex + "\n"); } else { jsonWriter.Write("\n"); } IndentOut(); Indent(); jsonWriter.Write("}"); }
public override void Write() { Indent(); jsonWriter.Write("{\n"); IndentIn(); Indent(); CommaNL(); jsonWriter.Write("\"name\": \"" + id + "\""); if (cameraName != null) { CommaNL(); Indent(); jsonWriter.Write("\"camera\": \"" + cameraName + "\""); } else if (lightName != null) { CommaNL(); Indent(); jsonWriter.Write("\"light\": \"" + lightName + "\""); } else if (meshIndexes.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"meshes\": [\n"); IndentIn(); foreach (int m in meshIndexes) { CommaNL(); Indent(); jsonWriter.Write(m); } jsonWriter.WriteLine(); IndentOut(); Indent(); jsonWriter.Write("]"); } if (childrenNames != null && childrenNames.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"children\": [\n"); IndentIn(); foreach (string ch in childrenNames) { CommaNL(); Indent(); jsonWriter.Write(GlTF_Writer.nodeNames.IndexOf(ch)); } jsonWriter.WriteLine(); IndentOut(); Indent(); jsonWriter.Write("]"); } if (jointName.Length > 0) { CommaNL(); Indent(); jsonWriter.Write("\"jointName\": \"" + jointName + "\""); } if (matrix != null) { CommaNL(); matrix.Write(); } else { if (translation != null && (translation.items[0] != 0f || translation.items[1] != 0f || translation.items[2] != 0f)) { CommaNL(); translation.Write(); } if (scale != null && (scale.items[0] != 1f || scale.items[1] != 1f || scale.items[2] != 1f)) { CommaNL(); scale.Write(); } if (rotation != null && (rotation.items[0] != 0f || rotation.items[1] != 0f || rotation.items[2] != 0f || rotation.items[3] != 0f)) { CommaNL(); rotation.Write(); } } jsonWriter.Write("\n"); if (skeletons.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"skeletons\": [\n"); IndentIn(); if (skeletons.Count > 0) { foreach (string s in skeletons) { CommaNL(); Indent(); jsonWriter.Write("" + GlTF_Writer.nodeNames.IndexOf(s) + "\n"); } } IndentOut(); Indent(); jsonWriter.Write("]"); } if (skinIndex > -1) { CommaNL(); Indent(); jsonWriter.Write("\"skin\": " + skinIndex + "\n"); } IndentOut(); Indent(); jsonWriter.Write("}"); }
public override void Write() { Indent(); jsonWriter.Write("\"" + name + "\": {\n"); IndentIn(); Indent(); jsonWriter.Write("\"name\": \"" + name + "\",\n"); if (cameraName != null) { CommaNL(); Indent(); jsonWriter.Write("\"camera\": \"" + cameraName + "\""); } else if (lightName != null) { CommaNL(); Indent(); jsonWriter.Write("\"light\": \"" + lightName + "\""); } else if (meshNames.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"meshes\": [\n"); IndentIn(); foreach (string m in meshNames) { CommaNL(); Indent(); jsonWriter.Write("\"" + m + "\""); } jsonWriter.WriteLine(); IndentOut(); Indent(); jsonWriter.Write("]"); } if (childrenNames != null && childrenNames.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"children\": [\n"); IndentIn(); foreach (string ch in childrenNames) { CommaNL(); Indent(); jsonWriter.Write("\"" + ch + "\""); } jsonWriter.WriteLine(); IndentOut(); Indent(); jsonWriter.Write("]"); } if (matrix != null) { CommaNL(); matrix.Write(); } if (translation != null && (translation.items[0] != 0f || translation.items[1] != 0f || translation.items[2] != 0f)) { CommaNL(); translation.Write(); } if (scale != null && (scale.items[0] != 1f || scale.items[1] != 1f || scale.items[2] != 1f)) { CommaNL(); scale.Write(); } if (rotation != null && (rotation.items[0] != 0f || rotation.items[1] != 0f || rotation.items[2] != 0f || rotation.items[3] != 0f)) { CommaNL(); rotation.Write(); } if (jointName != null) { CommaNL(); Indent(); jsonWriter.Write("\"jointName\": \"" + jointName + "\""); } if (skinName != null) { CommaNL(); Indent(); jsonWriter.Write("\"skin\": \"" + skinName + "\""); } if (skeletonNames.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"skeletons\": [\n"); IndentIn(); foreach (var n in skeletonNames) { CommaNL(); Indent(); jsonWriter.Write("\"" + n + "\""); } IndentOut(); jsonWriter.WriteLine(); Indent(); jsonWriter.Write("]"); } jsonWriter.WriteLine(); IndentOut(); Indent(); jsonWriter.Write("}"); }
public override void Write() { List <GlTF_Writer> extensions = new List <GlTF_Writer>(); Indent(); jsonWriter.Write("{\n"); IndentIn(); Indent(); CommaNL(); string nodeName; nodeName = GlTF_Writer.nodeNames.TryGetValue(uuid, out nodeName) ? nodeName : id; jsonWriter.Write("\"name\": \"" + nodeName + "\""); if (cameraName != null) { CommaNL(); Indent(); jsonWriter.Write("\"camera\": " + cameraIndex); } if (lightIndex != -1) { var lightWriter = new GlTF_Light_EX(); lightWriter.index = lightIndex; extensions.Add(lightWriter); } if (meshIndex != -1) { CommaNL(); Indent(); jsonWriter.Write("\"mesh\": " + meshIndex); } if (seinNode != null) { extensions.Add(seinNode); } if (physicBody != null) { extensions.Add(physicBody); } if (animator != null) { extensions.Add(animator); } if (childrenIDs != null && childrenIDs.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"children\": [\n"); IndentIn(); foreach (int ch in childrenIDs) { CommaNL(); int index = GlTF_Writer.nodeIDs.IndexOf(ch); Indent(); jsonWriter.Write(index); } jsonWriter.WriteLine(); IndentOut(); Indent(); jsonWriter.Write("]"); } if (matrix != null) { CommaNL(); matrix.Write(); } else { if (translation != null && (translation.items[0] != 0f || translation.items[1] != 0f || translation.items[2] != 0f)) { CommaNL(); translation.Write(); } if (scale != null && (scale.items[0] != 1f || scale.items[1] != 1f || scale.items[2] != 1f)) { CommaNL(); scale.Write(); } if (rotation != null && (rotation.items[0] != 0f || rotation.items[1] != 0f || rotation.items[2] != 0f || rotation.items[3] != 0f)) { CommaNL(); rotation.Write(); } } jsonWriter.Write("\n"); if (skinIndex > -1) { CommaNL(); Indent(); jsonWriter.Write("\"skin\": " + skinIndex + "\n"); } if (extensions.Count > 0) { CommaNL(); Indent(); jsonWriter.Write("\"extensions\": {\n"); IndentIn(); for (var i = 0; i < extensions.Count; i += 1) { var extension = extensions[i]; Indent(); extension.Write(); if (i != extensions.Count - 1) { jsonWriter.Write(","); } jsonWriter.Write("\n"); } IndentOut(); Indent(); jsonWriter.Write("}\n"); } IndentOut(); Indent(); jsonWriter.Write("}"); }