forked from alvani/Unity-glTF-Exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlTF_Mesh.cs
49 lines (43 loc) · 1.12 KB
/
GlTF_Mesh.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class GlTF_Mesh : GlTF_Writer {
public List<GlTF_Primitive> primitives;
public GlTF_Mesh() { primitives = new List<GlTF_Primitive>(); }
public static string GetNameFromObject(Object o)
{
return "mesh_" + GlTF_Writer.GetNameFromObject(o, true);
}
public void Populate (Mesh m)
{
if (primitives.Count > 0)
{
// only populate first attributes because the data are shared between primitives
primitives[0].attributes.Populate(m);
}
foreach (GlTF_Primitive p in primitives)
{
p.Populate (m);
}
}
public override void Write ()
{
Indent(); jsonWriter.Write ("\"" + name + "\": {\n");
IndentIn();
Indent(); jsonWriter.Write ("\"name\": \"" + name + "\",\n");
Indent(); jsonWriter.Write ("\"primitives\": [\n");
IndentIn();
foreach (GlTF_Primitive p in primitives)
{
CommaNL();
Indent(); jsonWriter.Write ("{\n");
p.Write ();
Indent(); jsonWriter.Write ("}");
}
jsonWriter.WriteLine();
IndentOut();
Indent(); jsonWriter.Write ("]\n");
IndentOut();
Indent(); jsonWriter.Write ("}");
}
}