using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GraphicsStudy { public class Instance { string id; double[] transform; double visible; int mesh; List info; /// /// 构件的id /// public string Id { get => id; set => id = value; } /// /// 变换矩阵 /// public double[] Transform { get => transform; set => transform = value; } /// /// 可见性 /// public double Visible { get => visible; set => visible = value; } /// /// 对应网格数组中的序号 /// public int Mesh { get => mesh; set => mesh = value; } /// /// 对应材质数组中的序号 /// public List Info { get => info; set => info = value; } public Instance() { } public string ToJson() { string result = null; result = string.Format ( "\n \"id\":{0}," + "\n \"transform\":[{1}]," + "\n \"visible\":{2}," + "\n \"mesh\":{3}," + "\n \"info\":{{{4}\n}}", id, string.Join(",\n",transform.Select(x=>x.ToString("f1"))), visible.ToString("f1"), mesh, string.Join(",\n", info) ); return "\n{" + result + "\n}"; } } }