65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
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<string> info;
|
|
|
|
/// <summary>
|
|
/// 构件的id
|
|
/// </summary>
|
|
public string Id { get => id; set => id = value; }
|
|
/// <summary>
|
|
/// 变换矩阵
|
|
/// </summary>
|
|
public double[] Transform { get => transform; set => transform = value; }
|
|
/// <summary>
|
|
/// 可见性
|
|
/// </summary>
|
|
public double Visible { get => visible; set => visible = value; }
|
|
/// <summary>
|
|
/// 对应网格数组中的序号
|
|
/// </summary>
|
|
public int Mesh { get => mesh; set => mesh = value; }
|
|
/// <summary>
|
|
/// 对应材质数组中的序号
|
|
/// </summary>
|
|
public List<string> 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<double,string>(x=>x.ToString("f1"))),
|
|
visible.ToString("f1"),
|
|
mesh,
|
|
string.Join(",\n", info)
|
|
);
|
|
|
|
return "\n{" + result + "\n}";
|
|
}
|
|
}
|
|
}
|